5 CONFIGFILE
=/etc
/aiccu.conf
9 BROKERS_LIST
=/usr
/share
/aiccu
/conf-templates
/brokers.list
11 TMPCONF
=$
(tempfile
-p aiccu
-s conf
)
12 TMPFILE
=$
(tempfile
-p aiccu
-s temp
)
13 BROKERS
=$
(tempfile
-p aiccu
-s brokers
)
15 trap 'rm -f $TMPCONF $TMPFILE $BROKERS' TERM INT EXIT QUIT
17 # Make sure that files we create are not readable by anyone but us (root)
20 # Source debconf library.
21 .
/usr
/share
/debconf
/confmodule
23 if [ -e $CONFIGFILE ]; then
24 USERNAME
=$
(grep ^username
$CONFIGFILE |
awk '{print $2}')
25 PASSWORD
=$
(grep ^password
$CONFIGFILE |
awk '{print $2}')
26 PROTO
=$
(grep ^protocol
$CONFIGFILE |
awk '{print $2}')
27 SERVER
=$
(grep ^server
$CONFIGFILE |
awk '{print $2}')
28 TUNNEL
=$
(grep ^tunnel_id
$CONFIGFILE |
awk '{print $2}')
30 if [ "$USERNAME" != "" ]; then
31 db_set aiccu
/username
"$USERNAME"
34 if [ "$PASSWORD" != "" ]; then
35 db_set aiccu
/password
"$PASSWORD"
38 if [ "$PROTO" != "" -a "$SERVER" != "" ]; then
39 db_set aiccu
/brokername
"$PROTO://$SERVER"
42 if [ "$TUNNEL" != "" ]; then
43 db_set aiccu
/tunnelname
"$TUNNEL"
48 if [ "$DEBCONF_RECONFIGURE" = "1" -o "$1" = "reconfigure" ]; then
50 elif [ "$TUNNEL" != "" -a "$PROTO" != "" -a "$SERVER" != "" ]; then
51 # Assume that we do not need further configuration.
55 # Fetch the list of tunnel brokers
57 $DIG _aiccu.sixxs.net TXT
+short
+time=5 +tries
=2 |
58 sed -e "s/\"$/|/" -e "s/\" \"/|/g" -e "s/\"//" -e "/^[#;]/d" |
sort > $BROKERS
61 $HOST -t TXT
-W 5 _aiccu.sixxs.net |
62 sed -e "s/^_.*text //" -e "s/\"$/|/" -e "s/\" \"/|/g" -e "s/\"//" -e "/^[#;]/d" |
66 sed -e "/^#/d" $BROKERS_LIST > $BROKERS
70 # Copy default if dig/host gave error
71 if [ ${PIPESTATUS[0]} -ne 0 ]; then
72 sed -e "/^#/d" $BROKERS_LIST > $BROKERS
76 # 1 Get Tunnel Brokername
80 while [ $STATE -ge 1 -a $STATE -le 2 ]; do
84 BROKERS_
=$
(cat $BROKERS | cut
-f1 -d'|' |
awk '{print $0","}')
85 BROKERS_
=$
(echo -n $BROKERS_ |
sed 'N;s/\n//g' |
sed 's/,$//g')
86 db_get aiccu
/brokername
87 if [ "$RET" != "" ]; then
88 SELECTED
=$
(grep "$RET" $BROKERS | cut
-f1 -d'|')
89 db_set aiccu
/brokername
"$SELECTED"
91 db_subst aiccu
/brokername brokers
"$BROKERS_"
92 db_input high aiccu
/brokername || true
95 # Convert brokername to URL of broker
96 db_get aiccu
/brokername || true
97 URL
=$
(grep $RET $BROKERS | cut
-f2 -d'|')
98 db_set aiccu
/brokername
"$URL"
102 # Request User / Pass
103 db_input high aiccu
/username || true
104 db_input high aiccu
/password || true
110 STATE
=$
(($STATE + 1))
114 rm -f $TMPCONF $TMPFILE $BROKERS