Skip to content

Instantly share code, notes, and snippets.

@caseyfw
Last active December 10, 2017 23:36
Show Gist options
  • Save caseyfw/bbd1c513b2bbc9ff363022395eac6781 to your computer and use it in GitHub Desktop.
Save caseyfw/bbd1c513b2bbc9ff363022395eac6781 to your computer and use it in GitHub Desktop.
Quick scripts to toggle the FC corporate proxy on an Ubuntu machine
#!/bin/bash
# Remove proxy config from system environment.
sed -r -i.old '/https?_proxy/d' /etc/environment
# Remove proxy config from APT.
sed -i.old '/proxy/d' /etc/apt/apt.conf
# Stop CNTLM.
systemctl stop cntlm.service
# Remove flight centre specific config from time sync config.
sed -i.old '/flitech/d' /etc/systemd/timesyncd.conf
# Set proxy as disabled in dconf.
dconf write /system/proxy/mode "'none'"
# Notify user.
notify-send -i notification-network-disconnected 'Proxy disabled'
#!/bin/bash
# Start CNTLM.
systemctl start cntlm.service
# Add proxy config to system environment.
if ! grep -q http_proxy /etc/environment; then
echo 'http_proxy="http://localhost:3128/"' >> /etc/environment
echo 'https_proxy="http://localhost:3128/"' >> /etc/environment
fi
# Add proxy config to APT.
if ! grep -q proxy /etc/apt/apt.conf; then
echo 'Acquire::http::proxy "http://localhost:3128/";' >> /etc/apt/apt.conf
echo 'Acquire::https::proxy "http://localhost:3128/";' >> /etc/apt/apt.conf
fi
# Set ntp server to flight centre one in time sync config.
if ! grep -q flitech /etc/systemd/timesyncd.conf; then
echo 'NTP=time.au.flitech.net' >> /etc/systemd/timesyncd.conf
fi
# Set proxy as enabled in dconf.
dconf write /system/proxy/mode "'manual'"
# Notify user.
notify-send -i notification-network-connected 'Proxy enabled'
@caseyfw
Copy link
Author

caseyfw commented Sep 19, 2017

Consider binding these to F keys in System Settings -> Keyboard -> Shortcuts -> Custom. You'll need to run them with sudo, so if you put the scripts in /home/user/bin, make the shortcut something like sudo /home/user/bin/enable-proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment