root/alternc/trunk/debian/config

Revision 2266, 4.3 kB (checked in by anarcat, 2 months ago)

add templates for the new options

Line 
1 #! /bin/sh
2
3 set -e
4
5 # Source debconf library.
6 . /usr/share/debconf/confmodule
7 db_title AlternC
8
9 db_input critical alternc/welcomeconfirm || true
10
11 db_go
12 # Check the answer.
13 db_get alternc/welcomeconfirm || true
14
15 if [ "$RET" = "false" ]; then
16         # reset the welcomeconfirm flag if user refuses so it gets asked again next time
17         db_reset alternc/welcomeconfirm || true
18         db_fset alternc/welcomeconfirm "seen" "false" || true
19         exit 1
20 fi
21
22 # default values for local.sh
23 MYSQL_HOST=127.0.0.1
24 MYSQL_DATABASE=alternc
25 MYSQL_USER=sysusr
26 MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `"
27 MYSQL_CLIENT=localhost
28 FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`"
29 INTERNAL_IP="`/sbin/ifconfig|grep "inet addr:" | grep -v 127.0.0.1| head -1 | sed -e 's/^.*addr:\([0-9\.]*\).*$/\1/' 2>/dev/null || hostname -f`"
30 PUBLIC_IP="$INTERNAL_IP"
31 DEFAULT_MX="`cat /etc/mailname 2>/dev/null || hostname -f`"
32 ALTERNC_LOC=/var/alternc
33 NS1_HOSTNAME="$FQDN"
34 NS2_HOSTNAME="$FQDN"
35 HOSTING="AlternC"
36 SQLBACKUP_TYPE="rotate"
37 SQLBACKUP_OVERWRITE="no"
38
39 if [ -r /etc/alternc/local.sh ]; then
40     # source the current config
41     . /etc/alternc/local.sh
42 fi
43 if [ -r /etc/alternc/my.cnf ]; then
44     # make mysql configuration available as shell variables
45     # to convert from .cnf to shell syntax, we:
46     # * match only lines with "equal" in them (/=/)
47     # * remove whitespace around the = and add a left quote operator ' (;s)
48     # * add a right quote operator at the end of line (;s)
49     # * convert mysql variables into our MYSQL_ naming convention (;s)
50     # * print the result (;p)
51     eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
52 fi
53
54 # mettre les valeurs de local.sh comme "default" pour debconf
55 db_get alternc/hostingname
56 if [ -z "$RET" ]
57     then
58     db_set alternc/hostingname "$HOSTING"
59 fi
60
61 db_get alternc/desktopname
62 if [ -z "$RET" ]
63     then
64 db_set alternc/desktopname "$FQDN"
65 fi
66
67 db_get alternc/public_ip
68 if [ -z "$RET" ]
69     then
70 db_set alternc/public_ip "$PUBLIC_IP"
71 fi
72
73 db_get alternc/internal_ip
74 if [ -z "$RET" ]
75     then
76 db_set alternc/internal_ip "$INTERNAL_IP"
77 fi
78
79 db_get alternc/monitor_ip
80 if [ -z "$RET" ]
81     then
82 db_set alternc/monitor_ip "$MONITOR_IP"
83 fi
84
85 db_get alternc/ns1
86 if [ -z "$RET" ]
87     then
88 db_set alternc/ns1 "$NS1_HOSTNAME"
89 fi
90
91 db_get alternc/ns2
92 if [ -z "$RET" ]
93     then
94 db_set alternc/ns2 "$NS2_HOSTNAME"
95 fi
96
97 db_get alternc/bind_internal
98 if [ -z "$RET" ]
99     then
100 db_set alternc/bind_internal "$BIND_INTERNAL"
101 fi
102
103 db_get alternc/default_mx
104 if [ -z "$RET" ]
105     then
106 db_set alternc/default_mx "$DEFAULT_MX"
107 fi
108
109 db_get alternc/mysql/host
110 if [ -z "$RET" ]
111     then
112 db_set alternc/mysql/host "$MYSQL_HOST"
113 fi
114
115 db_get alternc/mysql/db
116 if [ -z "$RET" ]
117     then
118 db_set alternc/mysql/db "$MYSQL_DATABASE"
119 fi
120
121 db_get alternc/mysql/user
122 if [ -z "$RET" ]
123     then
124 db_set alternc/mysql/user "$MYSQL_USER"
125 fi
126
127 db_get alternc/mysql/password
128 if [ -z "$RET" ]
129     then
130 db_set alternc/mysql/password "$MYSQL_PASS"
131 fi
132
133 db_get alternc/mysql/client
134 if [ -z "$RET" ]
135     then
136 db_set alternc/mysql/client "$MYSQL_CLIENT"
137 fi
138
139 db_get alternc/sql/backup_type
140 if [ -z "$RET" ]
141     then
142 db_set alternc/sql/backup_type "$SQLBACKUP_TYPE"
143 fi
144
145 db_get alternc/sql/backup_overwrite
146 if [ -z "$RET" ]
147     then
148 db_set alternc/sql/backup_overwrite "$SQLBACKUP_OVERWRITE"
149 fi
150
151 db_get alternc/alternc_location
152 if [ -z "$RET" ]
153     then
154 db_set alternc/alternc_location "$ALTERNC_LOC"
155 fi
156
157 db_get alternc/mynetwork
158 if [ -z "$RET" ]
159     then
160 db_set alternc/mynetwork "$SMTP_RELAY_NETWORKS"
161 fi
162
163 db_input medium alternc/desktopname || true
164 db_input medium alternc/hostingname || true
165 db_input medium alternc/internal_ip || true
166 db_input medium alternc/public_ip || true
167 db_input medium alternc/default_mx || true
168 db_input medium alternc/ns1 || true
169 db_input medium alternc/ns2 || true
170 db_input low alternc/alternc_location || true
171 db_input low alternc/mysql/host || true
172 db_input low alternc/mysql/db || true
173 db_input low alternc/mysql/user || true
174 db_input low alternc/mysql/password || true
175 db_input low alternc/mysql/client || true
176 db_input low alternc/sql/backup_type || true
177 db_input low alternc/sql/overwrite || true
178 db_input low alternc/monitor_ip || true
179 db_input low alternc/bind_internal || true
180 db_input low alternc/mynetwork || true
181 db_go
182
183 # vim: et sw=4
Note: See TracBrowser for help on using the browser.