Jakub 7d599185e0
use Bourne shell as the actual postinst script does (#4638)
The `postinst` wrapper script into which these scripts are embedded as
`after_upgrade` and `after_install` functions are executed using Bourne
shell(`sh`), so we cannot use the Bash specific `[[ ]]` test or it fails:
```
/var/lib/dpkg/info/nimbus-beacon-node.postinst: 22: [[: not found
```

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2023-02-17 14:13:28 +02:00

29 lines
639 B
Bash

#!/bin/sh
set -e
DISTRO="UNKNOWN"
if [ -r /etc/os-release ]; then
. /etc/os-release
DISTRO="${ID}"
fi
if ! id -u nimbus > /dev/null 2>&1; then
case $DISTRO in
Ubuntu|ubuntu|Debian|debian)
# Debian uses `adduser` to create user...
adduser --system --no-create-home --group nimbus
;;
*)
# ... while `useradd` is more standard
useradd --system --no-create-home --user-group nimbus
;;
esac
fi
mkdir -p /var/lib/nimbus
chown nimbus:nimbus /var/lib/nimbus
# Systems like docker containers do not have systemd.
systemctl daemon-reload || echo "notice: systemd daemon not reloaded" >&2