postinst is in nbd-server 1:3.13-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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #! /bin/bash
# postinst script for nbd
#
# see: dh_installdeb(1)
set -e
. /usr/share/debconf/confmodule
# Quotes each argument for shell expression inclusion, to prevent
# interpretation of special characters.
function shell_quote () {
local first=true
while [ "$#" -gt 0 ]; do
if [ ! "$first" ]; then
echo -n ' '
fi
# sed expression transforms instances of ' to '\''
echo -n "'$(echo "$1" | sed -e "s/'/'\\\\''/g")'"
first=
shift
done
}
case "$1" in
configure)
if [ -f /etc/nbd-server -o -f /etc/nbd-server.oldconf ]
then
db_get nbd-server/convert
if [ "$RET" = "true" ]
then
convert_config;
exit 0;
fi
fi
db_get nbd-server/number
NUMBER=${RET:-0}
umask 066
if [ "$NUMBER" -gt 0 ]
then
TMPFILE=`mktemp /tmp/nbd-server.XXXXXX`
cat /usr/share/nbd-server/nbd-server.conf.tmpl > $TMPFILE
for i in $(seq 0 $(( $NUMBER - 1 )) )
do
# stay downward compatible
if [ "$i" -eq 0 ]
then
unset i
fi
db_get nbd-server/name$i
NAME=$RET
db_get nbd-server/filename$i
FN=$RET
( echo "[$NAME]"
echo " exportname = $FN"
) >> $TMPFILE
done
ucf --debconf-ok $TMPFILE /etc/nbd-server/config
else
ucf --debconf-ok /usr/share/nbd-server/nbd-server.conf.tmpl /etc/nbd-server/config
fi
if ! id nbd >/dev/null 2>&1; then
adduser --system --group --home /etc/nbd-server --no-create-home nbd
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'">&2
exit 0
;;
esac
db_stop
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
if [ -x "/etc/init.d/nbd-server" ]; then
update-rc.d nbd-server defaults >/dev/null
fi
if [ -x "/etc/init.d/nbd-server" ] || [ -e "/etc/init/nbd-server.conf" ]; then
invoke-rc.d nbd-server start || exit $?
fi
fi
# End automatically added section
exit 0
|