#!/bin/bash -e
-RANDOMDEVICE=/dev/urandom
-allowed=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./
-declare -a RVAL
-
-second () {
- echo $2
-}
-
-create-random-pw() {
- if ! read -n 0 < $RANDOMDEVICE ; then
- echo 1>&2 "Warning, no random device found, password might be insecure"
- for i in 0 1 2 3 4 5 6 7; do
- RVAL[i]=$RANDOM
- done
- else
- for i in 0 1 2 3 4 5 6 7; do
- RVAL[i]=$(second $(od -N 1 -t d $RANDOMDEVICE))
- done
- fi
-
- PW=""
- for i in 0 1 2 3 4 5 6 7; do
- idx=$((${RVAL[i]} & 0x3F))
- PW="${PW}${allowed:$idx:1}"
- done
-
- printf "%s" $PW
-}
-
# this function comes from wwwconfig-common's apache.func script
getwwwoption() {
getwwwoption=""
db_set "diogenes/webgroup" "$webgroup"
fi
-db_input "high" "diogenes/databasemgr_type" || true
-db_go
-db_get "diogenes/databasemgr_type"
-dbtype="$RET"
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
+ . /usr/share/dbconfig-common/dpkg/config.mysql
+ dbc_go diogenes $@
+fi
-if [ "$dbtype" = "Automatic" ] ; then
- db_input "high" "diogenes/databasemgr_server" || true
- db_go
- db_input "high" "diogenes/dbmyadmin" || true
- db_go
- db_input "critical" "diogenes/dbadmpass" || true
- db_go
- db_input "medium" "diogenes/database_name" || true
- db_go
- db_input "medium" "diogenes/database_user" || true
- db_go
- db_input "medium" "diogenes/database_pass" || true
- db_go
- db_get "diogenes/database_pass"
- dbpass="$RET"
- if [ "$dbpass" = "auto" ]; then
- dbpass=$(create-random-pw)
- elif [ "$dbpass" = "none" ]; then
- dbpass=""
- fi
- db_set "diogenes/database_pass" "$dbpass"
-fi