2 # postinst script for aiccu
4 # Abort if any command returns an error value
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
14 configure|reconfigure
)
16 .
/usr
/share
/debconf
/confmodule
18 ### find out what the user answered.
19 db_get aiccu
/username || true
22 db_get aiccu
/password || true
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
35 # Register configuration file with ucf
36 ucfr aiccu
$CONFIGFILE
38 if [ "$USERNAME" = "" ]; then
39 # Not configured yet, thus skip
40 cp $TEMPLATE $CONFIGFILE
44 # Defaults when nothing gets chosen
45 # This might happen because of broken DNS
46 if [ "$PROTO" = "" ]; then
50 if [ "$SERVER" = "" ]; then
51 SERVER
="tic.sixxs.net"
54 # Make sure that files we create are not readable by anyone but us (root)
57 # Note that it is under debconf control
58 echo $CTLINFO >> $TMPCONF
60 # Replace the example lines so that they become normals
62 /^#username /c username $USERNAME
63 /^#protocol /c protocol $PROTO
64 /^#server /c server $SERVER
65 " < $TEMPLATE >> $TMPCONF
67 if [ "$PASSWORD" != "" ]; then
68 sed -i -e "/^#password /c password $PASSWORD" $TMPCONF
71 if [ "$TUNNEL" != "" ]; then
72 sed -i -e "/^#tunnel_id /c tunnel_id $TUNNEL" $TMPCONF
75 # Remove config if equal to template
76 if diff -q $TEMPLATE $CONFIGFILE; then
80 # Put config file into place
81 if [ -f $CONFIGFILE ]; then
82 ucf
--debconf-ok $TMPCONF $CONFIGFILE
85 mv $TMPCONF $CONFIGFILE
88 # Just in case, make sure the permissions are perfect and dandy
91 # Remove password from database
92 db_reset aiccu
/password
94 ### END (re)configure ###
97 abort-upgrade|abort-remove|abort-deconfigure
)
101 echo "postinst called with unknown argument \`$1'" >&2
106 # dh_installdeb will replace this with shell code automatically
107 # generated by other debhelper scripts.