f7c19b26fca257d8e457ada64d75de284c4801e4
[oweals/gnunet.git] / contrib / packages / alpine / gnunet / gnunet.post-install
1 #!/bin/sh
2
3 # Enumerate users.
4 users=`awk -F ':' '$3>=1000 && $3<2000 {print $1}' /etc/passwd`
5
6 # Install gnunet.conf for existing users.
7 for user in $users; do
8         install -m644 -o $user -g $user -D /etc/skel/.config/gnunet.conf \
9                 /home/$user/.config/gnunet.conf
10 done
11
12 # Enable GNS proxy for users, if desired.
13 echo "Use GNU Name System in Firefox/Chromium by default? [y,N]"
14 read -r yn
15 case $yn in
16 y|Y )
17         # Enable GNS proxy for existant users.
18         for user in $users; do
19                 port=$((8000+$(id -u $user)))
20                 gnunet-config -c /home/$user/.config/gnunet.conf \
21                         --rewrite \
22                         --section=gns-proxy \
23                         --option=IMMEDIATE_START \
24                         --value=YES
25                 gnunet-config -c /home/$user/.config/gnunet.conf \
26                         --rewrite \
27                         --section=gns-proxy \
28                         --option=OPTIONS \
29                         --value="-p $port"
30         done
31
32         # Enable GNS proxy for future users.
33         echo "[gns-proxy]" >> /etc/skel/.config/gnunet.conf
34         echo "IMMEDIATE_START = YES" >> /etc/skel/.config/gnunet.conf
35         ;;
36 * )
37         ;;
38 esac
39
40 exit 0