-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_apt_proxy.sh
executable file
·46 lines (36 loc) · 1.05 KB
/
set_apt_proxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Copyright Felix Wolfsteller 2017
# Licensed under the GPLv3+
# Configures apt to use a apt-cacher-ng instance.
# Exit on errors
set -euo pipefail
#Acquire::http { Proxy "http://192.168.0.105:3142"; };
#Acquire::https { Proxy "https://"; };
PROXY_SETTINGS=<<END
END
PROXY_SETTINGS=$(cat <<'END_HEREDOC'
Acquire::http { Proxy \\"http://192.168.0.105:3142\\"; };
Acquire::https { Proxy \\"https://\\"; };
END_HEREDOC
)
echo "$PROXY_SETTINGS"
is_proxy_set() {
grep "192.168.0.105" /etc/apt/apt.conf.d/01proxy
}
maybe_set_proxy() {
zenity --question --text "Ubuntu Sieben Linden Beschleunigung aktivieren?"
[ "$?" -eq 0 ] && gksudo "bash -c 'echo \\\"$PROXY_SETTINGS\\\" >> /etc/apt/apt.conf.d/01proxy'"
}
maybe_unset_proxy() {
zenity --question --text "Ubuntu Sieben Linden Beschleunigung deaktivieren?"
[ "$?" -eq 0 ] && gksudo "bash -c 'echo \"\" > /etc/apt/apt.conf.d/01proxy'"
}
if is_proxy_set
then
#zenity --info --text "Already set"
maybe_unset_proxy
else
#zenity --info --text "Not yet set"
maybe_set_proxy
fi
exit 0