hobo/debian/hobo-agent.postinst

48 lines
884 B
Bash

#! /bin/sh
set -e
NAME="hobo-agent"
USER=$NAME
GROUP=$NAME
case "$1" in
configure)
# make sure the administrative user exists
if ! getent passwd $USER >/dev/null; then
adduser --disabled-password --quiet --system \
--no-create-home --home /nonexistent \
--gecos "$NAME software user" --group $GROUP
fi
# ensure dirs ownership
chown $USER:$GROUP /var/log/$NAME
set +e
START_HOBO_AGENT=1
if [ -x /usr/sbin/policy-rc.d ]; then
/usr/sbin/policy-rc.d
RETVAL="$?"
if [ $RETVAL != 0 ]; then START_HOBO_AGENT=0; fi
fi
set -e
if [ $START_HOBO_AGENT = 1 ]; then
supervisorctl reread
supervisorctl restart hobo-agent
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0