more plugin fixups
[diogenes.git] / debian / diogenes.config
... / ...
CommitLineData
1#!/bin/bash -e
2
3RANDOMDEVICE=/dev/urandom
4allowed=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./
5declare -a RVAL
6
7second () {
8 echo $2
9}
10
11create-random-pw() {
12 if ! read -n 0 < $RANDOMDEVICE ; then
13 echo 1>&2 "Warning, no random device found, password might be insecure"
14 for i in 0 1 2 3 4 5 6 7; do
15 RVAL[i]=$RANDOM
16 done
17 else
18 for i in 0 1 2 3 4 5 6 7; do
19 RVAL[i]=$(second $(od -N 1 -t d $RANDOMDEVICE))
20 done
21 fi
22
23 PW=""
24 for i in 0 1 2 3 4 5 6 7; do
25 idx=$((${RVAL[i]} & 0x3F))
26 PW="${PW}${allowed:$idx:1}"
27 done
28
29 printf "%s" $PW
30}
31
32# this function comes from wwwconfig-common's apache.func script
33getwwwoption() {
34 getwwwoption=""
35 if [ -f $2 ] ; then
36 if grep $1 $2 | grep -v "#" > /dev/null 2>&1 ; then
37 getwwwoption=$(sed -ne "/^[[:space:]]*$1[[:space:]]\+/ s|[[:space:]]*$1[[:space:]]\+\([^[:space:]]\+\)[[:space:]]*$|\1|pg;" < $2)
38 fi
39 fi
40}
41
42
43# Use debconf baby
44. /usr/share/debconf/confmodule
45db_version 2.0
46db_title Diogenes
47
48db_input "low" "diogenes/welcome" || true
49db_go
50db_input "high" "diogenes/purge_removes_data" || true
51db_go
52
53### Required options no matter what ###
54db_input "high" "diogenes/webservers" || true
55db_go
56db_get "diogenes/webservers"
57webservers="$RET"
58
59# if a single webserver is selected,
60# try to get the user and group the webserver runs as
61nbsrv=0
62for i in $webservers ; do nbsrv=`expr $nbsrv + 1`; done
63
64if [ $nbsrv == 1 ]; then
65 server=$(echo $webservers | sed 's/,$//')
66 if [ -f /etc/$server/httpd.conf ]; then
67 getwwwoption User /etc/$server/httpd.conf
68 webuser=$(echo "$getwwwoption" | sed -e "q")
69 getwwwoption Group /etc/$server/httpd.conf
70 webgroup=$(echo "$getwwwoption" | sed -e "q")
71 fi
72fi
73
74if [ -z "$webuser" ]; then
75 db_input "high" "diogenes/webuser" || true
76 db_go
77else
78 db_set "diogenes/webuser" "$webuser"
79fi
80if [ -z "$webgroup" ]; then
81 db_input "high" "diogenes/webgroup" || true
82 db_go
83else
84 db_set "diogenes/webgroup" "$webgroup"
85fi
86
87db_input "high" "diogenes/databasemgr_type" || true
88db_go
89db_get "diogenes/databasemgr_type"
90dbtype="$RET"
91
92if [ "$dbtype" = "Automatic" ] ; then
93 db_input "high" "diogenes/databasemgr_server" || true
94 db_go
95 db_input "high" "diogenes/dbmyadmin" || true
96 db_go
97 db_input "critical" "diogenes/dbadmpass" || true
98 db_go
99 db_input "medium" "diogenes/database_name" || true
100 db_go
101 db_input "medium" "diogenes/database_user" || true
102 db_go
103 db_input "medium" "diogenes/database_pass" || true
104 db_go
105 db_get "diogenes/database_pass"
106 dbpass="$RET"
107 if [ "$dbpass" = "auto" ]; then
108 dbpass=$(create-random-pw)
109 elif [ "$dbpass" = "none" ]; then
110 dbpass=""
111 fi
112 db_set "diogenes/database_pass" "$dbpass"
113
114fi