* ask questions in the obvious cases.
[citadel.git] / webcit / debian / citadel-webcit.config
1 #!/bin/sh
2 set -e
3 . /usr/share/debconf/confmodule
4
5 CONFIGURE=no
6
7 if test -e /etc/default/webcit; then
8   source /etc/default/webcit
9 else
10    CONFIGURE=yes
11     export WEBCIT_CITADEL_IP=127.0.0.1
12     export WEBCIT_CITADEL_PORT=504
13 fi
14
15 db_capb backup 
16
17
18 # are we unconfigured?
19 db_get ciatdel/WebcitWebserver &&WWWTYPE="$RET"
20 if test -z "$WWWTYPE"; then 
21    CONFIGURE=yes
22 fi;
23
24 if test -n "$2"; then
25 # do we want to reconfigure?
26     if test "`echo $2 | sed -e 's/[.-]//g'`" -lt 127 \
27         -o $1 = reconfigure
28         then
29         CONFIGURE=yes
30     fi
31 else 
32 # are we in first install?
33     if test "$1" = "configure"; then
34         CONFIGURE=yes
35     fi
36 fi
37
38 if test "$CONFIGURE" = "yes"; then
39     STATE=1
40     LASTSTATE=2
41     while [ "$STATE" != 0 -a "$STATE" -le "$LASTSTATE" ]; do
42         case "$STATE" in
43             1)
44                 db_input high citadel/WebcitApacheIntegration
45                 ;;
46             2)
47                 db_get citadel/WebcitApacheIntegration
48                 if test "$RET" = "Internal"; then
49                     db_input high citadel/WebcitHttpPort
50                 else
51                     db_set citadel/WebcitHttpPort 8504
52                 fi
53                 ;;
54             3)               
55                 db_get citadel/WebcitApacheIntegration
56                 if test "$RET" = "Internal"; then
57                     db_input high citadel/WebcitHttpsPort
58                     db_set citadel/WebcitBindIp 0.0.0.0
59                 else
60                     db_set citadel/WebcitHttpsPort -1
61                     db_set citadel/WebcitBindIp 127.0.0.1
62                 fi
63                 ;;
64             4)
65                 db_input high citadel/WebcitInstallnote
66                 ;;
67         esac
68         if db_go; then
69             STATE=$(($STATE + 1))
70         else
71             STATE=$(($STATE - 1))
72         fi
73         
74     done
75     db_go
76     db_get ciatdel/WebcitWebserver &&WWWTYPE="$RET"
77     db_get citadel/WebcitHttpPort && WEBCIT_HTTP_PORT="$RET"
78     db_get citadel/WebcitHttpsPort && WEBCIT_HTTPS_PORT="$RET"
79     db_get citadel/WebcitBindIp && WEBCIT_LISTEN_IP="$RET"
80     
81     set |grep WEBCIT |sed "s;^;export ;;" >/etc/default/webcit
82 fi
83
84
85
86 exit 0