1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
#!/bin/bash -e
# Source debconf library.
. /usr/share/debconf/confmodule
# Establish the preliminaries.
db_version 2.0
db_capb backup
# Use a state machine to allow jumping back to previous questions.
STATE=10
while [ "$STATE" != 0 -a "$STATE" != 90 ]; do
case "$STATE" in
10)
# First ask user which installation way he wants
# if the mysql default file doesn't exists, only Manual install is available.
if [ ! -f /etc/mysql/debian.cnf ]; then
db_input high bugzilla/bugzilla_installation_way_single || true
db_go || true
db_get bugzilla/bugzilla_installation_way_single || true
else
db_input high bugzilla/bugzilla_installation_way || true
db_go || true
db_get bugzilla/bugzilla_installation_way || true
fi
case "$RET" in
"Automatic")
# as bugzilla/bugzilla_installation_way
# is set to Automatic, postinst will try
# to do the stuff, but first we have to ask
# for bugziall admin name and so on :
STATE=60
;;
"Manual")
# Let's do all what we did before.
STATE=20
;;
"Later")
# Here we just stop the process and postinst won't do
# anything. User will have to run dpkg-reconfigure
# when he is ready.
exit 0
;;
esac
;;
20)
#will we need an admin access to the database
db_input high bugzilla/mysql_need_root || true
if db_go; then
db_get bugzilla/mysql_need_root || true
NEED_ADMIN=$RET
if [ "$NEED_ADMIN" = "true" ]; then
STATE=30
else
STATE=40
fi
else
STATE=10
fi
;;
30)
#pass this state if admin access in not needed
if [ "$NEED_ADMIN" = "false" ]; then
#the only way to be here is by back since in
#foward mode you pass directly from 1 to 3
STATE=20
continue
fi
#get the admin user name and passord
db_beginblock
db_input high bugzilla/mysql_root_name || true
db_input high bugzilla/mysql_root_pwd || true
db_endblock
if db_go; then
db_get bugzilla/mysql_root_name || true
if [ "$RET" = "" ]; then
#mysql admin user could not be empty
#TODO have an explicative note of the error
db_reset bugzilla/mysql_root_name || true
continue
fi
STATE=40
else
STATE=20
fi
;;
40)
db_beginblock
db_input high bugzilla/mysql_host || true
db_input high bugzilla/mysql_port || true
db_input high bugzilla/mysql_name || true
db_endblock
if db_go; then
for FIELD in mysql_host mysql_port mysql_name; do
db_get bugzilla/$FIELD || true
if [ "$RET" = "" ]; then
#none of theres field should be empty
db_reset bugzilla/$FIELD
continue 2
fi
done
STATE=50
else
STATE=30
fi
;;
50)
db_fget bugzilla/mysql_user_pwd seen
if [ "$RET" = "true" ]; then
db_get bugzilla/mysql_user_pwd || true
db_set bugzilla/pwd_check "$RET"
else
db_set bugzilla/pwd_check ""
fi
db_beginblock
db_input high bugzilla/mysql_user || true
#### If the password question is skipped we do not check it
if db_input high bugzilla/mysql_user_pwd || [ ! "$?" = "30" ] ; then
#### If we haven't admin access there will be no user creation
if [ "$NEED_ADMIN" = "true" ] ; then
db_input high bugzilla/pwd_check || true
fi
fi
db_endblock
if db_go; then
db_get bugzilla/mysql_user || true
if [ "$RET" = "" ]; then
#mysql admin user could not be empty
#TODO have an explicative note of the error
db_reset bugzilla/mysql_user
continue
fi
db_get bugzilla/mysql_user_pwd || true
#### If we haven't admin access there will be no user creation
if [ "$NEED_ADMIN" = "true" ] ; then
PWD=$RET
db_get bugzilla/pwd_check || true
if [ "$RET" != "$PWD" ]; then
#TODO have an explicative note of the error
db_reset bugzilla/pwd_check
db_reset bugzilla/mysql_user_pwd
continue
fi
fi
STATE=60
else
STATE=40
fi
;;
60)
db_fget bugzilla/bugzilla_admin_pwd seen
if [ "$RET" = "true" ]; then
db_get bugzilla/bugzilla_admin_pwd || true
db_set bugzilla/pwd_check "$RET"
else
db_set bugzilla/pwd_check ""
fi
db_beginblock
db_input high bugzilla/bugzilla_admin_name || true
db_input high bugzilla/bugzilla_admin_real_name || true
#### If the password question is skipped we do not check it
if db_input high bugzilla/bugzilla_admin_pwd || [ ! "$?" = "30" ] ; then
db_input high bugzilla/pwd_check || true
fi
db_endblock
if db_go; then
for FIELD in bugzilla_admin_name bugzilla_admin_real_name; do
db_get bugzilla/$FIELD || true
if [ "$RET" = "" ]; then
#none of theres field should be empty
db_reset bugzilla/$FIELD
continue 2
fi
done
db_get bugzilla/bugzilla_admin_pwd || true
PWD=$RET
db_get bugzilla/pwd_check || true
if [ "$RET" != "$PWD" ]; then
db_reset bugzilla/bugzilla_admin_pwd
db_reset bugzilla/pwd_check
continue
fi
STATE=70
else
STATE=50
fi
;;
70)
# As cgi as been moved from /usr/lib/cgi-bin to
# /usr/lib/cgi-bin/bugzilla, if /var/lib/bugzilla/web/index.html
# have been changed this version will be keep back with wrong links
# so I warm user if md5sum doesn't match old index.html version
# (this is in case of a preconfigure script) nor the current version
# (in case of configure)
if dpkg --compare-versions "$2" le-nl "2.13+cvs20010709-4"; then
if echo '3d7df628e56b3b76a57cb7a6f7c91934 /var/lib/bugzilla/web/index.html' | md5sum -c 2>&- \
|| echo 'b195bf3871949f2e123741320e8d06e7 /var/lib/bugzilla/web/index.html' | md5sum -c 2>&-;then
STATE=80
else
db_input high bugzilla/index_upgrade1 || true
if db_go; then
STATE=80
else
STATE=60
fi
fi
else
STATE=80
fi
;;
80)
#Since 2.16rc1 bugzilla use html template even for index so now index.htm only
#refesh to /cgi-bin/bugzilla/index.cgi. As administrator may have make some change
#on it, it is nice to inform him that his change will be lost and he had to make
#them again in a copy of /usr/share/bugzilla/template/en/default/index.html.tmpl
#that should go in /var/lib/bugzilla/template/en/custom.
if dpkg --compare-versions "$2" lt-nl "2.16rc1-2"; then
if echo 'b195bf3871949f2e123741320e8d06e7 /var/lib/bugzilla/web/index.html' | md5sum -c 2>&- \
|| echo 'dd5dfdb92fe5013a80e3c645d0610e00 /var/lib/bugzilla/web/index.html' | md5sum -c 2>&-;then
STATE=90
else
db_input high bugzilla/index_upgrade2 || true
if db_go; then
STATE=90
else
STATE=70
fi
fi
else
STATE=90
fi
;;
esac
done
db_reset bugzilla/pwd_check
|