summaryrefslogtreecommitdiffstats
path: root/NetworkManager-openvpn/build/doinst.sh
blob: 5cdef5d87c3ff2b9451c805320dd1149b8433220 (plain)
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
41
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