Skip to content

Commit

Permalink
Add support to enable/disable network proxy client configuration (RPi…
Browse files Browse the repository at this point in the history
  • Loading branch information
mecking committed Nov 7, 2017
1 parent 3929227 commit af04669
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions raspi-config
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,43 @@ do_net_names () {
fi
}

do_net_proxy () {
CURRENT_HTTP_PROXY=`echo $http_proxy`
CURRENT_HTTPS_PROXY=`echo $https_proxy`
CURRENT_FTP_PROXY=`echo $ftp_proxy`

if [ "$INTERACTIVE" = True ]; then

NEW_HTTP_PROXY=$(whiptail --inputbox "Please enter HTTP Proxy address. Eg: http://user:pass@proxy:8080" 10 70 "$CURRENT_HTTP_PROXY" 3>&1 1>&2 2>&3)
sed -i '/http_proxy/d' /root/.bashrc
sed -i '/http_proxy/d' /home/pi/.bashrc
if [ ! -z $NEW_HTTP_PROXY ]; then
echo "http_proxy=$NEW_HTTP_PROXY" >> /root/.bashrc
echo "http_proxy=$NEW_HTTP_PROXY" >> /home/pi/.bashrc
ASK_TO_REBOOT=1
fi

NEW_HTTPS_PROXY=$(whiptail --inputbox "Please enter HTTPS Proxy address. Eg: http://user:pass@proxy:8080" 10 70 "$CURRENT_HTTPS_PROXY" 3>&1 1>&2 2>&3)
sed -i '/https_proxy/d' /root/.bashrc
sed -i '/https_proxy/d' /home/pi/.bashrc
if [ ! -z $NEW_HTTPS_PROXY ]; then
echo "https_proxy=$NEW_HTTPS_PROXY" >> /root/.bashrc
echo "https_proxy=$NEW_HTTPS_PROXY" >> /home/pi/.bashrc
ASK_TO_REBOOT=1
fi

NEW_FTP_PROXY=$(whiptail --inputbox "Please enter FTP Proxy address. Eg: http://user:pass@proxy:8080" 10 70 "$CURRENT_FTP_PROXY" 3>&1 1>&2 2>&3)
sed -i '/ftp_proxy/d' /root/.bashrc
sed -i '/ftp_proxy/d' /home/pi/.bashrc
if [ ! -z $NEW_FTP_PROXY ]; then
echo "ftp_proxy=$NEW_FTP_PROXY" >> /root/.bashrc
echo "ftp_proxy=$NEW_FTP_PROXY" >> /home/pi/.bashrc
ASK_TO_REBOOT=1
fi

fi
}

do_update() {
apt-get update &&
apt-get install raspi-config &&
Expand Down Expand Up @@ -1653,6 +1690,7 @@ do_network_menu() {
"N1 Hostname" "Set the visible name for this Pi on a network" \
"N2 Wi-fi" "Enter SSID and passphrase" \
"N3 Network interface names" "Enable/Disable predictable network interface names" \
"N4 Network Proxy client" "Enable/Disable network proxy client configuration" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
Expand All @@ -1662,6 +1700,7 @@ do_network_menu() {
N1\ *) do_hostname ;;
N2\ *) do_wifi_ssid_passphrase ;;
N3\ *) do_net_names ;;
N4\ *) do_net_proxy ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
Expand Down

0 comments on commit af04669

Please sign in to comment.