summarylogtreecommitdiffstats
path: root/install
blob: a993838e013355fabacbc4e72f9a2d6e2e9bdc3c (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
create_or_update_user() {
  if getent passwd raiblocks &>/dev/null; then
    echo -n ">>> Updating nano-node service user from raiblocks... "
    if systemctl is-active --quiet raiblocks-node; then
      systemctl stop raiblocks-node
      usermod -l nano-node -m -d /var/lib/nano-node raiblocks
      groupmod -n nano-node raiblocks
      systemctl start nano-node
    else
      usermod -l nano-node -m -d /var/lib/nano-node raiblocks
      groupmod -n nano-node raiblocks
    fi
    echo "done. Data has been moved to /var/lib/nano-node"
  else
    getent passwd nano-node &>/dev/null || {
      echo -n ">>> Creating nano-node service user... "
      useradd --system --user-group -m --home /var/lib/nano-node nano-node
      echo "done"
    } # NOTE: we do not autoremove user due to security concerns (Arch policy)
    #chown nano-node:nano-node /var/lib/nano-node
  fi
}
post_install() {
  create_or_update_user
}

post_upgrade() {
  create_or_update_user
}