3 CONFIGFILE
="/etc/aiccu.conf"
4 TMPCONF
=/etc
/aiccu.conf.dpkg-tmp
5 EXAMPLE
=/usr
/share
/doc
/aiccu
/examples
/aiccu.conf
6 CTLINFO
="# Under control from debconf, please use 'dpkg-reconfigure aiccu' to reconfigure"
9 .
/usr
/share
/debconf
/confmodule
17 AICCUOUT
=$
($BINARY brokers
)
19 db_get aiccu
/brokername
20 URL
=$
(echo "$AICCUOUT" |
grep "$RET")
21 PROTO
=$
(echo $URL | cut
-f2 -d'|' | cut
-f1 -d:)
22 SERVER
=$
(echo $URL | cut
-f2 -d'|' | cut
-f3 -d/)
24 db_get aiccu
/tunnelname
29 if [ "$USERNAME" = "" ]; then
30 # Not configured yet, thus skip
34 # Defaults when nothing gets chosen
35 # This might happen because of broken DNS
36 if [ "$PROTO" = "" ]; then
40 if [ "$SERVER" = "" ]; then
41 SERVER
="tic.sixxs.net"
44 # Make sure that files we create are not readable by anyone but us (root)
47 # Check if the /etc/aiccu.conf is actually the example
48 if [ diff -q $EXAMPLE $CONFIGFILE 2>/dev
/null
>/dev
/null
]; then
54 # Install a default config when it didn't exist yet or it is the same as the example
55 # bash uses '==', dash uses '=', thus use '!=' as that is the same
56 if [ "$DEFAULTCONFIG" != "false" -o ! -e "$CONFIGFILE" ]; then
58 # Note that it is under debconf control
59 echo $CTLINFO >> $TMPCONF
61 # Replace the example lines so that they become normals
62 sed -e "s/^#username .*/username $USERNAME/; s/^#password .*/password $PASSWORD/; s/^#protocol .*/protocol $PROTO/; s/^#server .*/server $SERVER/; s/^#tunnel_id .*/tunnel_id $TUNNEL/;" < $EXAMPLE >> $TMPCONF
64 # Modify the existing one
66 # Note that it is under debconf control
67 if ! grep -q "^$CTLINFO" $CONFIGFILE; then
68 echo $CTLINFO >> $TMPCONF >>$TMPCONF
71 # Make sure that all the variables can be stored somewhere
72 if ! grep -q "^username" $CONFIGFILE; then
73 if [ "$USERNAME" != "" ]; then
74 echo "username $USERNAME" >> $TMPCONF
78 if ! grep -q "^password" $CONFIGFILE; then
79 if [ "$PASSWORD" != "" ]; then
80 echo "password $PASSWORD" >> $TMPCONF
84 if ! grep -q "^protocol" $CONFIGFILE; then
85 if [ "$PROTO" != "" ]; then
86 echo "protocol $PROTO" >> $TMPCONF
89 if ! grep -q "^server" $CONFIGFILE; then
90 if [ "$SERVER" != "" ]; then
91 echo "server $SERVER" >> $TMPCONF
95 if ! grep -q "^tunnel_id" $CONFIGFILE; then
96 if [ "$TUNNEL" != "" ]; then
97 echo "tunnel_id $TUNNEL" >> $TMPCONF
101 sed -e "s/^username .*/username $USERNAME/; s/^password .*/password $PASSWORD/; s/^protocol .*/protocol $PROTO/; s/^server .*/server $SERVER/; s/^tunnel_id .*/tunnel_id $TUNNEL/;" < $CONFIGFILE >> $TMPCONF
105 mv -f $TMPCONF $CONFIGFILE
106 # Just in case, make sure the permissions are perfect and dandy
107 chmod 600 $CONFIGFILE