diff options
Diffstat (limited to 'contrib/packages/alpine/gnunet/gnunet.xsession')
-rw-r--r-- | contrib/packages/alpine/gnunet/gnunet.xsession | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/packages/alpine/gnunet/gnunet.xsession b/contrib/packages/alpine/gnunet/gnunet.xsession new file mode 100644 index 000000000..f19d6baf7 --- /dev/null +++ b/contrib/packages/alpine/gnunet/gnunet.xsession | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/bin/sh | ||
2 | user=$(whoami) | ||
3 | gnunet_proxy=$(gnunet-config -c /etc/skel/.config/gnunet.conf -s gns-proxy|grep 'IMMEDIATE_START = YES') | ||
4 | |||
5 | # Enable GNS proxy for new users informed by /etc/skel. | ||
6 | if [ "$gnunet_proxy" ]; then | ||
7 | |||
8 | # Calculate user specific port | ||
9 | port=$((8000+$(id -u $user))) | ||
10 | |||
11 | gnunet-config -c /home/$user/.config/gnunet.conf \ | ||
12 | --rewrite \ | ||
13 | --section=gns-proxy \ | ||
14 | --option=OPTIONS \ | ||
15 | --value="-p $port" | ||
16 | |||
17 | # Firefox | ||
18 | if [ ! -d ~/.mozilla/firefox/*.default ];then | ||
19 | timeout 3s firefox --headless # dirty: create profile if not existent | ||
20 | fi | ||
21 | for ffprofile in ~/.mozilla/firefox/*.*/; do | ||
22 | js=$ffprofile/user.js | ||
23 | if [ -f $js ]; then | ||
24 | sed -i '/Preferences for using the GNU Name System/d' $js | ||
25 | sed -i '/network.proxy.socks/d' $js | ||
26 | sed -i '/network.proxy.socks_port/d' $js | ||
27 | sed -i '/network.proxy.socks_remote_dns/d' $js | ||
28 | sed -i '/network.proxy.type/d' $js | ||
29 | fi | ||
30 | echo "// Preferences for using the GNU Name System" >> $js | ||
31 | echo "user_pref(\"network.proxy.socks\", \"localhost\");" >> $js | ||
32 | echo "user_pref(\"network.proxy.socks_port\", $port);" >> $js | ||
33 | echo "user_pref(\"network.proxy.socks_remote_dns\", true);" >> $js | ||
34 | echo "user_pref(\"network.proxy.type\", 1);" >> $js | ||
35 | done | ||
36 | |||
37 | # Chromium | ||
38 | profile=/home/$user/.profile | ||
39 | if [ -f $profile ]; then | ||
40 | sed -i '/CHROMIUM_USER_FLAGS/d' $profile | ||
41 | fi | ||
42 | echo "export CHROMIUM_USER_FLAGS=--proxy-server=socks5://localhost:$port" \ | ||
43 | >> $profile | ||
44 | fi | ||
45 | |||
46 | # Create/Renew GNS certificate authority (CA) per user. | ||
47 | gnunet-gns-proxy-setup-ca | ||
48 | |||
49 | # In case a new user was added and gnunet-user-services has not been | ||
50 | # restarted afterwards, start user services after login. | ||
51 | if test -z "`ps|grep -v grep|grep $user|grep gnunet-service-arm`" > /dev/null 2>&1 | ||
52 | then | ||
53 | gnunet-arm -c /home/$user/.config/gnunet.conf -s | ||
54 | fi | ||