postinst is in libpam0g 1.1.8-3.2ubuntu2.
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | #!/bin/sh
# postinst based heavily on the postinst of libssl0.9.8, courtesy of
# Christoph Martin.
. /usr/share/debconf/confmodule
set -e
# element() is a helper function for file-rc:
element() {
local element list IFS
element="$1"
[ "$2" = "in" ] && shift
list="$2"
[ "$list" = "-" ] && return 1
[ "$list" = "*" ] && return 0
IFS=","
set -- $list
case $element in
"$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
return 0
esac
return 1
}
# filerc (runlevel, service) returns /etc/init.d/service, if service is
# running in $runlevel:
filerc() {
local runlevel basename
runlevel=$1
basename=$2
while read LINE
do
case $LINE in
\#*|"") continue
esac
set -- $LINE
SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
[ "$CMD" = "/etc/init.d/$basename" ] || continue
if element "$runlevel" in "$START" || element "S" in "$START"
then
echo "/etc/init.d/$basename"
return 0
fi
done < /etc/runlevel.conf
echo ""
}
installed_services() {
check="$@"
# Only get the ones that are installed, and configured
check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
# some init scripts don't match the package names
check=$(echo $check | \
sed -e's/\bapache2-common\b/apache2/g' \
-e's/\bat\b/atd/g' \
-e's/\bdovecot-common\b/dovecot/g' \
-e's/\bdante-server\b/danted/g' \
-e's/\bexim4-base\b/exim4/g' \
-e's/\bheartbeat-2\b/heartbeat/g' \
-e's/\bhylafax-server\b/hylafax/g' \
-e's/\bpartimage-server\b/partimaged/g' \
-e's/\bpostgresql-common\b/postgresql/g' \
-e's/\bsamba\b/smbd/g' \
-e's/\bsasl2-bin\b/saslauthd/g' \
)
for service in $check; do
idl="/etc/init.d/${service}"
if [ -n "$idl" ] && [ -x $idl ]; then
services="$service $services"
else
echo "WARNING: init script for $service not found." >&2
fi
done
echo "$services"
}
if [ "$1" = "configure" ]
then
if [ ! -z "$2" ]; then
if dpkg --compare-versions "$2" lt 1.1.3-2; then
db_version 2.0
echo -n "Checking for services that may need to be restarted..."
check="apache2-common at bayonne cherokee courier-authdaemon"
check="$check cron cups"
check="$check dante-server diald dovecot-common exim exim4-base"
check="$check fcron fireflier-server freeradius gdm heartbeat"
check="$check heartbeat-2 hylafax-server iiimf-server inn2"
check="$check kannel linesrv linesrv-mysql lsh-server"
check="$check muddleftpd netatalk nuauth partimage-server"
check="$check perdition pgpool popa3d"
check="$check postgresql-common proftpd pure-ftpd"
check="$check pure-ftpd-ldap pure-ftpd-mysql"
check="$check pure-ftpd-postgresql racoon samba sasl2-bin"
check="$check sfs-server solid-pop3d squid squid3 tac-plus"
check="$check vsftpd wu-ftpd wzdftpd xrdp yardradius yaws"
if ! who | awk '{print $2}'|grep -q ':[0-9]'; then
check="$check wdm xdm"
fi
echo "Checking init scripts..."
services=$(installed_services "$check")
if [ -n "$services" ]; then
db_reset libpam0g/restart-services
db_set libpam0g/restart-services "$services"
question_priority="critical"
# Do not prompt when we're running in the upgrade-manager
# and only default services need restarting.
nondefault_services=$(echo "$services" | sed \
-e's/\batd\b//g' \
-e's/\bcron\b//g' \
-e's/\bcups\b//g' \
-e's/\bgdm\b//g' \
-e's/\bsmbd\b//g' \
-e's/^ *//g')
if [ -n "$RELEASE_UPGRADE_IN_PROGRESS" ] && [ -z "$nondefault_services" ]; then
question_priority="medium"
fi
db_input "$question_priority" libraries/restart-without-asking || true
db_go || true
db_get libraries/restart-without-asking
if [ "$RET" != true ]; then
db_reset libpam0g/restart-services
db_set libpam0g/restart-services "$services"
db_input "$question_priority" libpam0g/restart-services || true
db_go || true
db_get libpam0g/restart-services
if [ "x$RET" != "x" ]
then
services=$RET
else
services=""
fi
fi
echo
if [ "$services" != "" ]; then
echo "Restarting services possibly affected by the upgrade:"
failed=""
rl=$(runlevel | sed 's/.*\ //')
for service in $services; do
idl="invoke-rc.d ${service}"
case "$service" in
gdm)
# If gdm isn't running, there's no need to reload it (LP: #745532)
if $idl status | grep -q stop/waiting; then
echo " $service: not running, no reload needed."
continue
fi
echo -n " $service: reloading..."
if $idl reload > /dev/null 2>&1; then
echo "done."
else
echo "FAILED! ($?)"
failed="$service $failed"
fi
continue
;;
esac
echo -n " $service: stopping..."
$idl stop > /dev/null 2>&1 || true
sleep 1
echo -n "starting..."
if $idl start > /dev/null 2>&1; then
echo "done."
else
echo "FAILED! ($?)"
failed="$service $failed"
fi
done
echo
if [ -n "$failed" ]; then
db_subst libpam0g/restart-failed services "$failed"
db_input critical libpam0g/restart-failed || true
db_go || true
else
echo "Services restarted successfully."
fi
echo
fi
else
echo "Nothing to restart."
fi
if who | awk '{print $2}' | grep -q ':[0-9]'; then
dms=""
for service in wdm xdm; do
case "$services" in
*$service*) ;;
*) dms="$dms $service"
esac
done
services=$(installed_services "$dms")
if [ -n "$services" ]; then
if [ -n "$RELEASE_UPGRADE_IN_PROGRESS" ] \
&& [ -x /usr/share/update-notifier/notify-reboot-required ]
then
/usr/share/update-notifier/notify-reboot-required
else
db_input critical libpam0g/xdm-needs-restart || true
db_go || true
fi
fi
fi
# Shut down the frontend, to make sure none of the
# restarted services keep a connection open to it
db_stop
fi # end upgrading and $2 lt 1.1.3-2
fi # Upgrading
fi
|