aboutsummarylogtreecommitdiffstats
path: root/nordlayer.install
blob: 82105b3aa6988ac7a7d3696283bceb982e106029 (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
43
44
45
46
47
VAR_LIB=/var/lib/nordlayer

post_install() {

  # Allow the daemon executable to bind to port 500 and administer network
  setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN,CAP_NET_RAW+eip /usr/bin/nordlayerd
  setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN,CAP_NET_RAW+eip /usr/bin/nordlayer-openvpn

  groupadd -r -f nordlayer

  if ! id "nordlayer" >/dev/null 2>&1; then
    useradd -s /usr/bin/nologin -c "Used for running NordLayer" -r -M -d /run/nordlayer -g nordlayer nordlayer
  fi

  mkdir -p ${VAR_LIB}
  chmod 0770 -R ${VAR_LIB}
  chown nordlayer:nordlayer -R ${VAR_LIB}

  # Reload config
  systemctl daemon-reload

  # Create tmpfiles
  systemd-tmpfiles --create

  # Start service on boot
  systemctl enable nordlayer.socket
  systemctl enable nordlayer.service

  # Start service now
  systemctl start nordlayer.socket
  systemctl start nordlayer.service

}

post_upgrade() {
  post_install
}

pre_remove() {

  rm -rf ${VAR_LIB}
  systemctl disable nordlayer.service
  systemctl disable nordlayer.socket

  systemctl stop nordlayer.service
  systemctl stop nordlayer.socket
}