2 # postinst script for nbd
4 # see: dh_installdeb(1)
8 .
/usr
/share
/debconf
/confmodule
10 # Quotes each argument for shell expression inclusion, to prevent
11 # interpretation of special characters.
12 function shell_quote
() {
14 while [ "$#" -gt 0 ]; do
15 if [ ! "$first" ]; then
18 # sed expression transforms instances of ' to '\''
19 echo -n "'$(echo "$1" | sed -e "s
/'/'\\\\''/g
")'"
25 # Convert an old-style configuration file to a new-style one
26 function convert_config
() {
27 [ -f /etc
/nbd-server.oldconf
] && .
/etc
/nbd-server.oldconf
28 [ -f /etc
/nbd-server
] && .
/etc
/nbd-server
29 TMPFILE
=$
(mktemp
/tmp
/nbd-server.XXXXXX
)
30 if [ "$AUTO_GEN" = "n" ]
32 db_input critical nbd-server
/autogen
36 cat /usr
/share
/nbd-server
/nbd-server.conf.tmpl
> $TMPFILE
37 while [ ! -z ${NBD_FILE[$i]} ]
39 nbd-server
-o "export-$i" ${NBD_PORT[$i]} ${NBD_FILE[$i]} ${NBD_SERVER_OPTS[$i]} >> $TMPFILE
44 # summary of how this script can be called:
45 # * <postinst> `configure' <most-recently-configured-version>
46 # * <old-postinst> `abort-upgrade' <new version>
47 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
49 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
50 # <failed-install-package> <version> `removing'
51 # <conflicting-package> <version>
52 # for details, see /usr/share/doc/packaging-manual/
54 # quoting from the policy:
55 # Any necessary prompting should almost always be confined to the
56 # post-installation script, and should be protected with a conditional
57 # so that unnecessary prompting doesn't happen if a package's
58 # installation fails and the `postinst' is called with `abort-upgrade',
59 # `abort-remove' or `abort-deconfigure'.
63 if [ -f /etc
/nbd-server
-o -f /etc
/nbd-server.oldconf
]
65 db_get nbd-server
/convert
66 if [ "$RET" = "true" ]
72 db_get nbd-server
/number
75 if [ "$NUMBER" -gt 0 ]
77 TMPFILE
=`mktemp /tmp/nbd-server.XXXXXX`
78 cat /usr
/share
/nbd-server
/nbd-server.conf.tmpl
> $TMPFILE
79 db_get nbd-server
/useports
83 echo " oldstyle = true" >> $TMPFILE
85 for i
in $
(seq 0 $
(( $NUMBER - 1 )) )
87 # stay downward compatible
92 db_get nbd-server
/port
$i
94 db_get nbd-server
/name
$i
96 db_get nbd-server
/filename
$i
99 echo " exportname = $FN"
103 echo " port = $PORT" >> $TMPFILE
106 ucf
--debconf-ok $TMPFILE /etc
/nbd-server
/config
108 if ! id nbd
>/dev
/null
2>&1; then
109 adduser
--system --group --home /etc
/nbd-server
--no-create-home nbd
113 abort-upgrade|abort-remove|abort-deconfigure
)
118 echo "postinst called with unknown argument \`$1'">&2
125 # dh_installdeb will replace this with shell code automatically
126 # generated by other debhelper scripts.