5 .
/usr
/share
/debconf
/confmodule
7 db_get bitlbee
/serveport
10 CONFDIR
=/var
/lib
/bitlbee
/
12 update-rc.d bitlbee defaults
> /dev
/null
2>&1
14 ## Load default option. Don't want to put this in debconf (yet?)
17 BITLBEE_UPGRADE_DONT_RESTART
=0
18 [ -r /etc
/default
/bitlbee
] && .
/etc
/default
/bitlbee
20 if [ "$BITLBEE_DISABLED" = "0" ] && which update-inetd
> /dev
/null
2> /dev
/null
&&
21 ( expr "$2" : '0\..*' > /dev
/null ||
expr "$2" : '1\.0\..*' > /dev
/null
); then
22 ## Make sure the inetd entry is gone (can still be there from a
24 update-inetd
--remove '.*/usr/sbin/bitlbee'
25 if grep -q /usr
/sbin
/bitlbee
/etc
/inetd.conf
2> /dev
/null
; then
26 # Thanks for breaking update-inetd! (bugs.debian.org/311111)
27 # I hope that it works at least with xinetd, because this
28 # emergency hack doesn't:
29 perl
-pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc
/inetd.conf
30 killall
-HUP inetd || true
34 cat<<EOF>/etc/default/bitlbee
35 ## /etc/default/bitlbee: Auto-generated/updated script.
37 ## If running in (fork)daemon mode, listen on this TCP port.
40 ## Use single-process or forking daemon mode? Can't be changed from debconf,
41 ## but maintainer scripts will save your changes here.
42 BITLBEE_OPTS="$BITLBEE_OPTS"
44 ## In case you want to stick with inetd mode (or if you just want to disable
45 ## the init scripts for some other reason), you can disable the init script
46 ## here. (Just set it to 1)
47 BITLBEE_DISABLED=$BITLBEE_DISABLED
49 ## As a server operator, you can use the RESTART command to restart only the
50 ## master process while keeping all the child processes and their IPC
51 ## connections. By enabling this, the maintainer scripts won't restart
52 ## BitlBee during upgrades so you can restart the master process by hand.
53 BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART
56 ## Bye-bye DebConf, we don't need you anymore.
59 ## Restore the helpfile in case we weren't upgrading but just reconfiguring:
60 if [ -e /usr
/share
/bitlbee
/help.upgrading
]; then
61 if [ -e /usr
/share
/bitlbee
/help.txt
]; then
62 rm -f /usr
/share
/bitlbee
/help.upgrading
64 mv /usr
/share
/bitlbee
/help.upgrading
/usr
/share
/bitlbee
/help.txt
68 # The official way to check if we're upgrading is to check if $2 is
69 # non-empty. However, previous versions of BitlBee didn't have a
70 # bitlbee-common package so in that case the var will also be empty.
71 # Instead, check if the port is in use (if netstat is available). This
72 # works since the debconf code will pick a free port on new installs.
73 if [ "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then
75 if which netstat
> /dev
/null
2> /dev
/null
; then
76 netstat
-an |
grep -q :$PORT\\b.
*LISTEN
&& IS_UPGRADE
=1
78 [ -n "$2" ] && IS_UPGRADE
=1
80 if [ -n "$IS_UPGRADE" ]; then
81 invoke-rc.d bitlbee restart
85 ## If we're upgrading, we'll probably skip this next part
86 if [ -d $CONFDIR ] && chown
-R bitlbee
: $CONFDIR; then
87 echo 'BitlBee (probably) already installed, skipping user/configdir installation'
91 adduser
--system --group --disabled-login --disabled-password --home /var
/lib
/bitlbee
/ bitlbee
92 chmod 700 /var
/lib
/bitlbee
/
94 ## Can't do this in packaging phase: Don't know the UID yet. Access to
95 ## the file should be limited, now that it stores passwords. Added
96 ## --group later for a little more security, but have to see if I can
97 ## apply this change to existing installations on upgrades. Will think
99 if getent group bitlbee
> /dev
/null
; then
100 chmod 640 /etc
/bitlbee
/bitlbee.conf
101 chown root
:bitlbee
/etc
/bitlbee
/bitlbee.conf
103 chmod 600 /etc
/bitlbee
/bitlbee.conf
104 chown bitlbee
/etc
/bitlbee
/bitlbee.conf
108 invoke-rc.d bitlbee start