postinst is in unicorn 4.7.0-1.
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 | #!/bin/sh
set -e
if [ $1 != "configure" ] ; then
exit 0
fi
if [ -f /etc/default/unicorn ]; then
. /etc/default/unicorn
fi
TIMEOUT=${TIMEOUT-60}
PID=${PID-/run/unicorn.pid}
OLD_PID="${PID}.oldbin"
invoke() {
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d $1 $2
else
/etc/init.d/$1 $2
fi
}
running() {
invoke $1 status >/dev/null 2>&1
}
sig() {
test -s $PID && kill -$1 `cat $PID`
}
oldsig() {
test -s $OLD_PID && kill -$1 `cat $OLD_PID`
}
upgrade() {
echo "Trying to upgrade running server"
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT ; then
n=$TIMEOUT
while test -s $OLD_PID && test $n -ge 0 ; do
printf '.' && sleep 1 && n=`expr $n - 1`
done
if test $n -lt 0 && test -s $OLD_PID; then
echo "$OLD_PID still exists after $TIMEOUT seconds. Killing and starting new."
sig KILL || true
oldsig KILL || true
invoke unicorn start || exit $?
fi
fi
}
if [ -x /etc/init.d/unicorn ]; then
if running unicorn; then
upgrade
else
invoke unicorn start || exit $?
fi
fi
# Automatically added by dh_installinit
if [ -x "/etc/init.d/unicorn" ]; then
if [ ! -e "/etc/init/unicorn.conf" ]; then
update-rc.d unicorn defaults >/dev/null
fi
fi
# End automatically added section
exit 0
|