Last active
December 10, 2017 23:36
-
-
Save caseyfw/bbd1c513b2bbc9ff363022395eac6781 to your computer and use it in GitHub Desktop.
Quick scripts to toggle the FC corporate proxy on an Ubuntu machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 likesudo /home/user/bin/enable-proxy
.