postinst is in nbd-server 1:2.9.25-2ubuntu1.
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 | #! /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
}
# Convert an old-style configuration file to a new-style one
function convert_config () {
[ -f /etc/nbd-server.oldconf ] && . /etc/nbd-server.oldconf
[ -f /etc/nbd-server ] && . /etc/nbd-server
TMPFILE=$(mktemp /tmp/nbd-server.XXXXXX)
if [ "$AUTO_GEN" = "n" ]
then
db_input critical nbd-server/autogen
db_go
exit 1
fi
cat /usr/share/nbd-server/nbd-server.conf.tmpl > $TMPFILE
while [ ! -z ${NBD_FILE[$i]} ]
do
nbd-server -o "export-$i" ${NBD_PORT[$i]} ${NBD_FILE[$i]} ${NBD_SERVER_OPTS[$i]} >> $TMPFILE
i=$(( $i + 1 ))
done
}
# 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>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
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
db_get nbd-server/useports
DOPORTS="$RET"
if [ "$DOPORTS" ]
then
echo " oldstyle = true" >> $TMPFILE
fi
for i in $(seq 0 $(( $NUMBER - 1 )) )
do
# stay downward compatible
if [ "$i" -eq 0 ]
then
unset i
fi
db_get nbd-server/port$i
PORT=$RET
db_get nbd-server/name$i
NAME=$RET
db_get nbd-server/filename$i
FN=$RET
( echo "[$NAME]"
echo " exportname = $FN"
) >> $TMPFILE
if [ $DOPORTS ]
then
echo " port = $PORT" >> $TMPFILE
fi
done
ucf --debconf-ok $TMPFILE /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 [ -x "/etc/init.d/nbd-server" ]; then
if [ ! -e "/etc/init/nbd-server.conf" ]; then
update-rc.d nbd-server defaults >/dev/null
fi
invoke-rc.d nbd-server start || exit $?
fi
# End automatically added section
exit 0
|