mirror of https://github.com/sipwise/sems.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.9 KiB
83 lines
1.9 KiB
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# don't do anything when called with other argument than configure
|
|
case "$1" in
|
|
configure)
|
|
;;
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "postinst called with unknown argument \$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
restart_handler() {
|
|
if [ -x "/etc/init.d/sems" ]; then
|
|
if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then
|
|
invoke-rc.d sems restart || exit $?
|
|
else
|
|
/etc/init.d/sems restart || exit $?
|
|
fi
|
|
fi
|
|
}
|
|
|
|
initscript_handler() {
|
|
if [ -x "/etc/init.d/sems" ]; then
|
|
update-rc.d sems defaults >/dev/null
|
|
invoke-rc.d sems start || exit $?
|
|
fi
|
|
}
|
|
|
|
init_handler() {
|
|
# just invoke init script wrappers on ce systems since
|
|
# they do not provide ngcp-check_active and we don't
|
|
# have to handle inactive nodes
|
|
if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then
|
|
restart_handler
|
|
initscript_handler
|
|
else # do not restart daemon on inactive node in pro systems
|
|
if ngcp-check_active ; then
|
|
echo "Active node detected, restarting sems"
|
|
restart_handler
|
|
else
|
|
echo "Inactive node detected, ignoring request to restart sems"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# add sems user
|
|
adduser --quiet --system --group --disabled-password --shell /bin/false \
|
|
--gecos "SIP Express Media Server" --home /var/run/sems sems || true
|
|
|
|
if [ -d /usr/doc -a ! -e /usr/doc/sems -a -d /usr/share/doc/sems ]; then
|
|
ln -sf ../share/doc/sems /usr/doc/sems
|
|
fi
|
|
|
|
# create voicebox spool directory if
|
|
if [ ! -d /var/spool/voicebox ]; then
|
|
mkdir -p /var/spool/voicebox/
|
|
fi
|
|
|
|
# make directory writable for sems user
|
|
if [ -d /var/spool/voicebox ]; then
|
|
chown sems /var/spool/voicebox
|
|
fi
|
|
|
|
init_handler
|
|
|
|
echo ""
|
|
echo "***"
|
|
echo "Configuration of sems has finished."
|
|
echo ""
|
|
echo "To restart it when configuration has changed use '/etc/init.d/sems restart'"
|
|
echo ""
|
|
echo "To change it's configuration use 'dpkg-reconfigure sems'"
|
|
echo "***"
|
|
echo ""
|
|
|
|
exit 0
|