10 September 2012
Using a Raspberry Pi in School
My first challenge after getting a Raspberry Pi was to modify the settings so that it would work in school. The problem was in two parts:
Part 1 Get through the firewall so that the RPi can surf the web and download files
Part 2 Change the settings for "apt" so that the RPi can download and install software
There are probably better methods, but my solutions are outlined below for anyone who would like to try them.
Solution to part 1 They key to this was to get the right command to set the appropriate proxy and to find a way to turn it on and off at will. I found a Linux forum that suggested using a hidden file called ".bash_profile" (all filenames that start with a dot are hidden by default. You need to create this file in your home folder.
sudo nano .bash_profile
Now make sure it contains the following
# No Proxy
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY ftp_proxy FTP_PROXY
export http_proxy https_proxy ftp_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY
For DJCS the domain is BSFADDCC, the proxy address from within school is 172.24.48.10 and the port is 8080. You will have to use your own username and password. Make sure to save and close, then reboot.
When you reboot you will now be able to turn proxy settings on and off. To turn on proxies enter setproxy at a command line (do it before starting windows via startx). To turn off again enter noproxy
Solution to part 2 The key here is that apt uses a file called /etc/apt/apt.conf to contain any proxy settings. I wrote a small bash script to create this file when needed and delete it when not needed. It's all a bit crude because I don't know much about bash scripting.
First create a folder to contain bash scripts in your home directory sudo mkdir bin
Now create the script sudo nano ./bin/setaptproxy.sh
It should contain
echo Turn aptproxy on or off?
echo "Choose 1(On) or 2(Off)"
if [ $CHOICE = 1 ]; then
cp /etc/apt/apt.conf.proxyyes /etc/apt/apt.conf
if [ $CHOICE = 2 ]; then
cp /etc/apt/apt.conf.proxyno /etc/apt/apt.conf
Now create the proxy settings sudo nano /etc/apt/apt.conf.proxyyes
It should contain
Acquire::https::proxy " http://Domain\username:password@address:port/";
The parts in red will need to be completed as for part 1.
Finally create a dummy file to remove settings (This is because I don't yet know how to test for the existence of a file before attempting to delete it) sudo nano /etc/apt/apt.conf.proxyno
This should contain
# Remove proxies
To use apt-get with the proxy, first type sudo setaptproxy.sh at the prompt and choose option 1. You can now use "apt get" to download and install programs. To remove the settings do it again with option 2