move contrib/alpine to contrib/packages/alpine
[oweals/gnunet.git] / contrib / packages / alpine / gnunet / gnunet.post-install
diff --git a/contrib/packages/alpine/gnunet/gnunet.post-install b/contrib/packages/alpine/gnunet/gnunet.post-install
new file mode 100644 (file)
index 0000000..f7c19b2
--- /dev/null
@@ -0,0 +1,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