[19a8088] | 1 | #!/bin/sh -e |
---|
| 2 | |
---|
| 3 | . /usr/share/debconf/confmodule |
---|
| 4 | |
---|
| 5 | db_get bitlbee/serveport |
---|
| 6 | PORT="$RET" |
---|
| 7 | |
---|
| 8 | CONFDIR=/var/lib/bitlbee/ |
---|
| 9 | |
---|
| 10 | update-rc.d bitlbee defaults > /dev/null 2>&1 |
---|
| 11 | |
---|
| 12 | ## Load default option. Don't want to put this in debconf (yet?) |
---|
| 13 | BITLBEE_OPTS=-F |
---|
| 14 | BITLBEE_DISABLED=0 |
---|
| 15 | BITLBEE_UPGRADE_DONT_RESTART=0 |
---|
[fcd5003] | 16 | [ -r /etc/default/bitlbee ] && . /etc/default/bitlbee |
---|
[19a8088] | 17 | |
---|
[fcd5003] | 18 | if [ "$BITLBEE_DISABLED" = "0" ] && type update-inetd > /dev/null 2> /dev/null && |
---|
| 19 | ( expr "$2" : '0\..*' > /dev/null || expr "$2" : '1\.0\..*' > /dev/null ); then |
---|
| 20 | ## Make sure the inetd entry is gone (can still be there from a |
---|
| 21 | ## previous version. |
---|
[19a8088] | 22 | update-inetd --remove '.*/usr/sbin/bitlbee' |
---|
[379c08a] | 23 | if grep -q /usr/sbin/bitlbee /etc/inetd.conf 2> /dev/null; then |
---|
| 24 | # Thanks for breaking update-inetd! (bugs.debian.org/311111) |
---|
| 25 | # I hope that it works at least with xinetd, because this |
---|
| 26 | # emergency hack doesn't: |
---|
| 27 | perl -pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc/inetd.conf |
---|
[fcd5003] | 28 | killall -HUP inetd || true |
---|
[379c08a] | 29 | fi |
---|
[19a8088] | 30 | fi |
---|
| 31 | |
---|
| 32 | cat<<EOF>/etc/default/bitlbee |
---|
| 33 | ## /etc/default/bitlbee: Auto-generated/updated script. |
---|
| 34 | ## |
---|
| 35 | ## Don't edit this line, use dpkg-reconfigure bitlbee |
---|
| 36 | BITLBEE_PORT="$PORT" |
---|
| 37 | |
---|
| 38 | ## Use single-process or forking daemon mode? Can't be changed from debconf, |
---|
| 39 | ## but maintainer scripts will save your changes here. |
---|
| 40 | BITLBEE_OPTS="$BITLBEE_OPTS" |
---|
| 41 | |
---|
| 42 | ## In case you want to stick with inetd mode (or if you just want to disable |
---|
| 43 | ## the init scripts for some other reason), you can disable the init script |
---|
| 44 | ## here. (Just set it to 1) |
---|
| 45 | BITLBEE_DISABLED=$BITLBEE_DISABLED |
---|
| 46 | |
---|
| 47 | ## As a server operator, you can use the RESTART command to restart only the |
---|
| 48 | ## master process while keeping all the child processes and their IPC |
---|
| 49 | ## connections. By enabling this, the maintainer scripts won't restart |
---|
| 50 | ## BitlBee during upgrades so you can restart the master process by hand. |
---|
| 51 | BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART |
---|
| 52 | EOF |
---|
| 53 | |
---|
| 54 | ## Bye-bye DebConf, we don't need you anymore. |
---|
| 55 | db_stop |
---|
| 56 | |
---|
[7448e1b] | 57 | ## Restore the helpfile in case we weren't upgrading but just reconfiguring: |
---|
| 58 | if [ -e /usr/share/bitlbee/help.upgrading ]; then |
---|
| 59 | if [ -e /usr/share/bitlbee/help.txt ]; then |
---|
| 60 | rm -f /usr/share/bitlbee/help.upgrading |
---|
| 61 | else |
---|
| 62 | mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt |
---|
| 63 | fi |
---|
| 64 | fi |
---|
| 65 | |
---|
[5d3b4e8] | 66 | if ! grep -qi '^User *= *' /etc/bitlbee/bitlbee.conf; then |
---|
| 67 | echo 'Updating configuration file, enabling User-setting...' |
---|
| 68 | if ! sed -i -e 's/# *User *= *.*/User = bitlbee/i' /etc/bitlbee/bitlbee.conf; then |
---|
| 69 | echo 'Failed! BitlBee may run as root now, please check your configs.' |
---|
| 70 | fi |
---|
| 71 | fi |
---|
| 72 | |
---|
[19a8088] | 73 | if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then |
---|
[59c84c2] | 74 | if which invoke-rc.d >/dev/null 2>&1; then |
---|
| 75 | invoke-rc.d bitlbee restart |
---|
| 76 | else |
---|
| 77 | /etc/init.d/bitlbee restart |
---|
| 78 | fi |
---|
[19a8088] | 79 | fi |
---|
| 80 | |
---|
| 81 | ## If we're upgrading, we'll probably skip this next part |
---|
[d301872] | 82 | if [ -d $CONFDIR ] && chown -R bitlbee: $CONFDIR; then |
---|
[19a8088] | 83 | echo 'BitlBee (probably) already installed, skipping user/configdir installation' |
---|
| 84 | exit 0 |
---|
| 85 | fi |
---|
| 86 | |
---|
[628e601] | 87 | adduser --system --group --disabled-login --disabled-password --home /var/lib/bitlbee/ bitlbee |
---|
[19a8088] | 88 | chmod 700 /var/lib/bitlbee/ |
---|
| 89 | |
---|
| 90 | ## Can't do this in packaging phase: Don't know the UID yet. Access to |
---|
[628e601] | 91 | ## the file should be limited, now that it stores passwords. Added |
---|
| 92 | ## --group later for a little more security, but have to see if I can |
---|
| 93 | ## apply this change to existing installations on upgrades. Will think |
---|
| 94 | ## about that later. |
---|
| 95 | if getent group bitlbee > /dev/null; then |
---|
| 96 | chmod 640 /etc/bitlbee/bitlbee.conf |
---|
| 97 | chown root:bitlbee /etc/bitlbee/bitlbee.conf |
---|
| 98 | else |
---|
| 99 | chmod 600 /etc/bitlbee/bitlbee.conf |
---|
| 100 | chown bitlbee /etc/bitlbee/bitlbee.conf |
---|
| 101 | fi |
---|
[19a8088] | 102 | |
---|
| 103 | if [ -z "$2" ]; then |
---|
[59c84c2] | 104 | if which invoke-rc.d >/dev/null 2>&1; then |
---|
| 105 | invoke-rc.d bitlbee start |
---|
| 106 | else |
---|
| 107 | /etc/init.d/bitlbee start |
---|
| 108 | fi |
---|
[19a8088] | 109 | fi |
---|