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
|
#!/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" != 80 ]; do
case "$STATE" in
10)
#give some information about bugzilla
db_input high bugzilla/mysql_note || true
if db_go; then
STATE=20
else
STATE=10
fi
;;
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
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
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
;;
esac
done
db_reset bugzilla/pwd_check
|