
| Current Path : /var/lib/dpkg/info/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/lib/dpkg/info/asterisk.postinst |
#! /bin/sh
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
case "$1" in
configure)
# add asterisk user
if ! getent passwd asterisk > /dev/null ; then
echo 'Adding system user for Asterisk' 1>&2
adduser --system --group --quiet \
--home /var/lib/asterisk \
--no-create-home --disabled-login \
--gecos "Asterisk PBX daemon" \
asterisk
fi
# add asterisk to required groups
for group in dialout audio; do
if groups asterisk | grep -w -q -v $group; then
adduser asterisk $group
fi
done
# chown asterisk on all $dirs and their subdirectories
# do not harm the files, they should be empty on new installations
# and we don't want to mess-up anything on old installations
find /var/log/asterisk \
/var/lib/asterisk \
-type d | while read dir; do
if ! dpkg-statoverride --list "$dir" > /dev/null ; then
chown asterisk: "$dir"
fi
done
# this is not needed for new installations but is not such a bad idea
# removing this will _break_ upgrades from versions < 1:1.4.10.1~dfsg-1
#
# we are doing the same for subdirectories, since we are not shipping
# any and it's supposed to be user-modifiable
if ! dpkg-statoverride --list "/etc/asterisk" > /dev/null ; then
chown asterisk: /etc/asterisk
fi
# spool holds some sensitive information (e.g. monitor, voicemail etc.)
find /var/spool/asterisk -type d | while read dir; do
if ! dpkg-statoverride --list "$dir" > /dev/null ; then
chown asterisk: "$dir"
chmod 750 "$dir"
fi
done
# Create /usr/local directory; policy 9.1.2
if [ ! -e /usr/local/share/asterisk/sounds ]; then
if mkdir -p /usr/local/share/asterisk/sounds 2>/dev/null ; then
chown root:staff /usr/local/share/asterisk/sounds
chmod 2775 /usr/local/share/asterisk/sounds
fi
fi
### this is done here in case asterisk-config was installed/upgraded first
set +e # ignore errors temporarily
# find the name of the package providing config; either asterisk-config
# or a package providing asterisk-config-custom
ASTERISK_CONFIG=`dpkg-query -W -f='${Package}\t${Provides}\n' | \
sed -nr 's/(.*)\tasterisk-config-custom|(asterisk-config)(\t.*)?/\1\2/p'`
# find conffiles under /etc/asterisk belonging to asterisk-config
# and chown them to user asterisk.
dpkg-query -W -f='${Conffiles}\n' $ASTERISK_CONFIG 2>/dev/null | \
sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \
while read conffile; do
chown asterisk: "$conffile" 2>/dev/null
done
# handle them in the end with a glob since it's way faster
dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do
chown `echo $STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'` \
2>/dev/null
done
set -e
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_systemd_enable/12.9ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'asterisk.service' >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled 'asterisk.service'; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable 'asterisk.service' >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state 'asterisk.service' >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by dh_installinit/12.9ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/asterisk" ]; then
update-rc.d asterisk defaults >/dev/null
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
invoke-rc.d asterisk $_dh_action || exit 1
fi
fi
# End automatically added section
exit 0