postinst is in asterisk 1:13.18.3~dfsg-1ubuntu4.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | #! /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/11.1.4ubuntu1
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/11.1.4ubuntu1
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
|