aboutsummaryrefslogtreecommitdiff
path: root/contrib/alpine/gnunet/gnunet.post-install
blob: f7c19b26fca257d8e457ada64d75de284c4801e4 (plain) (blame)
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
#!/bin/sh

# Enumerate users.
users=`awk -F ':' '$3>=1000 && $3<2000 {print $1}' /etc/passwd`

# Install gnunet.conf for existing users.
for user in $users; do
        install -m644 -o $user -g $user -D /etc/skel/.config/gnunet.conf \
                /home/$user/.config/gnunet.conf
done

# Enable GNS proxy for users, if desired.
echo "Use GNU Name System in Firefox/Chromium by default? [y,N]"
read -r yn
case $yn in
y|Y )
        # Enable GNS proxy for existant users.
        for user in $users; do
                port=$((8000+$(id -u $user)))
                gnunet-config -c /home/$user/.config/gnunet.conf \
                        --rewrite \
                        --section=gns-proxy \
                        --option=IMMEDIATE_START \
                        --value=YES
                gnunet-config -c /home/$user/.config/gnunet.conf \
                        --rewrite \
                        --section=gns-proxy \
                        --option=OPTIONS \
                        --value="-p $port"
        done

        # Enable GNS proxy for future users.
        echo "[gns-proxy]" >> /etc/skel/.config/gnunet.conf
        echo "IMMEDIATE_START = YES" >> /etc/skel/.config/gnunet.conf
        ;;
* )
        ;;
esac

exit 0