summaryrefslogtreecommitdiffstats
path: root/NetworkManager-openvpn/build/doinst.sh
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkManager-openvpn/build/doinst.sh')
-rw-r--r--NetworkManager-openvpn/build/doinst.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/NetworkManager-openvpn/build/doinst.sh b/NetworkManager-openvpn/build/doinst.sh
new file mode 100644
index 00000000..5cdef5d8
--- /dev/null
+++ b/NetworkManager-openvpn/build/doinst.sh
@@ -0,0 +1,42 @@
+# Create the daemon account (nm-openvpn:nm-openvpn) and homedirectory:
+nmovuid=320
+nmovgid=320
+nmovhome=/var/lib/openvpn/chroot
+
+if ! chroot . getent group nm-openvpn > /dev/null; then
+ chroot . groupadd -g $nmovgid nm-openvpn
+ res=$?
+ if [ $res -ne 0 ]; then
+cat <<EOT
+A group with GID $nmovgid already exists!
+You'll have add a 'nm-openvpn' group manually. Run this command (as root):
+ groupadd -g GID nm-openvpn
+and select a free value for GID that is below 500 (check /etc/group)"
+Then, run an "upgradepkg --reinstall" of this package so that it can run the rest of the install script.
+EOT
+ fi
+fi
+if ! chroot . getent passwd nm-openvpn > /dev/null; then
+ chroot . useradd -c "NM OpenVPN Daemon" -d $nmovhome -u $nmovuid \
+ -g nm-openvpn -s /bin/false nm-openvpn
+ res=$?
+ if [ $res -ne 0 ]; then
+ cat <<EOT
+Could not create 'nm-openvpn' user account.
+Does an account with UID $nmovuid already exist?
+You'll have add a 'nm-openvpn' user manually. Run these commands (as root):
+ useradd -c "NM OpenVPN Daemon" -d $nmovhome -u UID -g nm-openvpn -s /bin/false nm-openvpn
+ passwd -l nm-openvpn
+and select a free value for UID that is below 500 (check /etc/passwd)
+Then, run an "upgradepkg --reinstall" of this package so that it can run the rest of the install script.
+EOT
+ fi
+fi
+
+# Set proper ownership:
+chroot . chown -R ${nmovuid}:${nmovgid} $nmovhome 1>/dev/null
+
+# Execute this regardless of the pre-existence of the nmov account:
+chroot . usermod -d $nmovhome nm-openvpn 1>/dev/null
+chroot . passwd -l nm-openvpn 1>/dev/null
+