root/alternc/tags/0.9.8/debian/config

Revision 2132, 3.9 kB (checked in by anarcat, 7 months ago)

fix mysql.cnf regexp for a last time, i hope

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
37 if [ -r /etc/alternc/local.sh ]; then
38     # source the current config
39     . /etc/alternc/local.sh
40 fi
41 if [ -r /etc/alternc/my.cnf ]; then
42     # make mysql configuration available as shell variables
43     # to convert from .cnf to shell syntax, we:
44     # * match only lines with "equal" in them (/=/)
45     # * remove whitespace around the = and add a left quote operator ' (;s)
46     # * add a right quote operator at the end of line (;s)
47     # * convert mysql variables into our MYSQL_ naming convention (;s)
48     # * print the result (;p)
49     eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_LOGIN/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
50 fi
51
52 # mettre les valeurs de local.sh comme "default" pour debconf
53 db_get alternc/hostingname
54 if [ -z "$RET" ]
55     then
56     db_set alternc/hostingname "$HOSTING"
57 fi
58
59 db_get alternc/desktopname
60 if [ -z "$RET" ]
61     then
62 db_set alternc/desktopname "$FQDN"
63 fi
64
65 db_get alternc/public_ip
66 if [ -z "$RET" ]
67     then
68 db_set alternc/public_ip "$PUBLIC_IP"
69 fi
70
71 db_get alternc/internal_ip
72 if [ -z "$RET" ]
73     then
74 db_set alternc/internal_ip "$INTERNAL_IP"
75 fi
76
77 db_get alternc/monitor_ip
78 if [ -z "$RET" ]
79     then
80 db_set alternc/monitor_ip "$MONITOR_IP"
81 fi
82
83 db_get alternc/ns1
84 if [ -z "$RET" ]
85     then
86 db_set alternc/ns1 "$NS1_HOSTNAME"
87 fi
88
89 db_get alternc/ns2
90 if [ -z "$RET" ]
91     then
92 db_set alternc/ns2 "$NS2_HOSTNAME"
93 fi
94
95 db_get alternc/bind_internal
96 if [ -z "$RET" ]
97     then
98 db_set alternc/bind_internal "$BIND_INTERNAL"
99 fi
100
101 db_get alternc/default_mx
102 if [ -z "$RET" ]
103     then
104 db_set alternc/default_mx "$DEFAULT_MX"
105 fi
106
107 db_get alternc/mysql/host
108 if [ -z "$RET" ]
109     then
110 db_set alternc/mysql/host "$MYSQL_HOST"
111 fi
112
113 db_get alternc/mysql/db
114 if [ -z "$RET" ]
115     then
116 db_set alternc/mysql/db "$MYSQL_DATABASE"
117 fi
118
119 db_get alternc/mysql/user
120 if [ -z "$RET" ]
121     then
122 db_set alternc/mysql/user "$MYSQL_USER"
123 fi
124
125 db_get alternc/mysql/password
126 if [ -z "$RET" ]
127     then
128 db_set alternc/mysql/password "$MYSQL_PASS"
129 fi
130
131 db_get alternc/mysql/client
132 if [ -z "$RET" ]
133     then
134 db_set alternc/mysql/client "$MYSQL_CLIENT"
135 fi
136
137 db_get alternc/alternc_location
138 if [ -z "$RET" ]
139     then
140 db_set alternc/alternc_location "$ALTERNC_LOC"
141 fi
142
143 db_get alternc/mynetwork
144 if [ -z "$RET" ]
145     then
146 db_set alternc/mynetwork "$SMTP_RELAY_NETWORKS"
147 fi
148
149 db_input medium alternc/desktopname || true
150 db_input medium alternc/hostingname || true
151 db_input medium alternc/internal_ip || true
152 db_input medium alternc/public_ip || true
153 db_input medium alternc/default_mx || true
154 db_input medium alternc/ns1 || true
155 db_input medium alternc/ns2 || true
156 db_input low alternc/alternc_location || true
157 db_input low alternc/mysql/host || true
158 db_input low alternc/mysql/db || true
159 db_input low alternc/mysql/user || true
160 db_input low alternc/mysql/password || true
161 db_input low alternc/mysql/client || true
162 db_input low alternc/monitor_ip || true
163 db_input low alternc/bind_internal || true
164 db_input low alternc/mynetwork || true
165 db_go
166
167 # vim: et sw=4
Note: See TracBrowser for help on using the browser.