removed db_stop from postinst
[aiccu.git] / debian / aiccu.postinst
blob1ad36d64b95b70695224be4fe527d1ebaee45f22
1 #!/bin/sh
2 # postinst script for aiccu
4 # Abort if any command returns an error value
5 set -e
7 CONFIGFILE="/etc/aiccu.conf"
8 TMPCONF=/etc/aiccu.conf.dpkg-tmp
9 TEMPLATE=/usr/share/aiccu/conf-templates/aiccu.conf
10 CTLINFO="# Under control from debconf, please use 'dpkg-reconfigure aiccu' to reconfigure"
11 BINARY=/usr/sbin/aiccu
13 case "$1" in
14 configure|reconfigure)
15 # Load debconf libary
16 . /usr/share/debconf/confmodule
18 ### find out what the user answered.
19 db_get aiccu/username || true
20 USERNAME="$RET"
22 db_get aiccu/password || true
23 PASSWORD="$RET"
25 AICCUOUT=$($BINARY brokers)
27 db_get aiccu/brokername || true
28 URL=$(echo "$AICCUOUT" | grep "$RET")
29 PROTO=$(echo $URL | cut -f2 -d'|' | cut -f1 -d:)
30 SERVER=$(echo $URL | cut -f2 -d'|' | cut -f3 -d/)
32 db_get aiccu/tunnelname || true
33 TUNNEL="$RET"
35 # Register configuration file with ucf
36 ucfr aiccu $CONFIGFILE
38 if [ "$USERNAME" = "" ]; then
39 # Not configured yet, thus skip
40 exit 0;
43 # Defaults when nothing gets chosen
44 # This might happen because of broken DNS
45 if [ "$PROTO" = "" ]; then
46 PROTO="tic"
49 if [ "$SERVER" = "" ]; then
50 SERVER="tic.sixxs.net"
53 # Make sure that files we create are not readable by anyone but us (root)
54 umask 077
56 # Note that it is under debconf control
57 echo $CTLINFO >> $TMPCONF
59 # Replace the example lines so that they become normals
60 sed -e "
61 /^#username /c username $USERNAME
62 /^#password /c password $PASSWORD
63 /^#protocol /c protocol $PROTO
64 /^#server /c server $SERVER
65 /^#tunnel_id /c tunnel_id $TUNNEL
66 " < $TEMPLATE >> $TMPCONF
68 # Put config file into place
69 if [ -f $CONFIGFILE ]; then
70 ucf --debconf-ok $TMPCONF $CONFIGFILE
71 rm -f $TMPCONF
72 else
73 mv $TMPCONF $CONFIGFILE
76 # Just in case, make sure the permissions are perfect and dandy
77 chmod 600 $CONFIGFILE
79 ### END (re)configure ###
82 abort-upgrade|abort-remove|abort-deconfigure)
86 echo "postinst called with unknown argument \`$1'" >&2
87 exit 1
89 esac
91 # dh_installdeb will replace this with shell code automatically
92 # generated by other debhelper scripts.
94 #DEBHELPER#
96 exit 0