openwebrx-clone/debian/openwebrx.postinst
2021-02-18 01:36:04 +01:00

33 lines
954 B
Bash
Executable File

#!/bin/bash
. /usr/share/debconf/confmodule
set -euo pipefail
OWRX_USER="openwebrx"
OWRX_DATADIR="/var/lib/openwebrx"
case "$1" in
configure|reconfigure)
adduser --system --group --no-create-home --home /nonexistent --quiet "${OWRX_USER}"
usermod -aG plugdev openwebrx
# create OpenWebRX data directory and set the correct permissions
if [ ! -d "${OWRX_DATADIR}" ] && [ ! -L "${OWRX_DATADIR}" ]; then mkdir "${OWRX_DATADIR}"; fi
chown "${OWRX_USER}". ${OWRX_DATADIR}
# create initial openwebrx user
db_get openwebrx/admin_user_password
if [ ! -z "${RET}" ] && [ "${RET}" != "__DONE__" ]; then
OWRX_PASSWORD="${RET}" openwebrx-admin --noninteractive --silent adduser admin
# remove actual password from debconf database, but leave a marker
db_set openwebrx/admin_user_password "__DONE__"
fi
;;
*)
echo "postinst called with unknown argument '$1'" 1>&2
exit 1
;;
esac
#DEBHELPER#