48 lines
1.5 KiB
Bash
Executable File
48 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
. /usr/share/debconf/confmodule
|
|
|
|
set -euo pipefail
|
|
|
|
OWRX_USER="openwebrx"
|
|
OWRX_DATADIR="/var/lib/openwebrx"
|
|
OWRX_USERS_FILE="${OWRX_DATADIR}/users.json"
|
|
|
|
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}
|
|
|
|
if [ ! -e "${OWRX_USERS_FILE}" ]; then
|
|
# create an empty users file now to avoid permission problems later
|
|
echo "[]" > "${OWRX_USERS_FILE}"
|
|
chown "${OWRX_USER}". "${OWRX_USERS_FILE}"
|
|
chmod 0600 "${OWRX_USERS_FILE}"
|
|
fi
|
|
|
|
db_get openwebrx/admin_user_password
|
|
if [ ! -z "${RET}" ]; then
|
|
if ! openwebrx admin --silent hasuser admin; then
|
|
# create initial openwebrx user
|
|
OWRX_PASSWORD="${RET}" openwebrx admin --noninteractive adduser admin
|
|
else
|
|
# change existing user's password
|
|
OWRX_PASSWORD="${RET}" openwebrx admin --noninteractive resetpassword admin
|
|
fi
|
|
fi
|
|
# remove password from debconf database
|
|
db_unregister openwebrx/admin_user_password
|
|
# set a marker that admin is configured to avoid future questions
|
|
db_set openwebrx/admin_user_configured true
|
|
;;
|
|
*)
|
|
echo "postinst called with unknown argument '$1'" 1>&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
#DEBHELPER#
|