| 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 | db_input critical alternc/warningaclquota || true |
|---|
| 23 | |
|---|
| 24 | # default values for local.sh |
|---|
| 25 | MYSQL_HOST=127.0.0.1 |
|---|
| 26 | MYSQL_DATABASE=alternc |
|---|
| 27 | MYSQL_USER=sysusr |
|---|
| 28 | MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" |
|---|
| 29 | MYSQL_CLIENT=localhost |
|---|
| 30 | FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`" |
|---|
| 31 | INTERNAL_IP="`env LANG=C /sbin/ifconfig|grep inet | grep -v 127.0.0.1| head -1 | cut -d: -f2 | sed -e 's/\([0-9\.]*\).*$/\1/' 2>/dev/null || hostname -f`" |
|---|
| 32 | PUBLIC_IP="$INTERNAL_IP" |
|---|
| 33 | DEFAULT_MX="`cat /etc/mailname 2>/dev/null || hostname -f`" |
|---|
| 34 | ALTERNC_LOC=/var/alternc |
|---|
| 35 | NS1_HOSTNAME="$FQDN" |
|---|
| 36 | NS2_HOSTNAME="$FQDN" |
|---|
| 37 | HOSTING="AlternC" |
|---|
| 38 | SQLBACKUP_TYPE="rotate" |
|---|
| 39 | SQLBACKUP_OVERWRITE="no" |
|---|
| 40 | |
|---|
| 41 | if [ -r /etc/alternc/local.sh ]; then |
|---|
| 42 | # source the current config |
|---|
| 43 | . /etc/alternc/local.sh |
|---|
| 44 | fi |
|---|
| 45 | if [ -r /etc/alternc/my.cnf ]; then |
|---|
| 46 | # make mysql configuration available as shell variables |
|---|
| 47 | # to convert from .cnf to shell syntax, we: |
|---|
| 48 | # * match only lines with "equal" in them (/=/) |
|---|
| 49 | # * remove whitespace around the = and add a left quote operator ' (;s) |
|---|
| 50 | # * add a right quote operator at the end of line (;s) |
|---|
| 51 | # * convert mysql variables into our MYSQL_ naming convention (;s) |
|---|
| 52 | # * print the result (;p) |
|---|
| 53 | eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf` |
|---|
| 54 | fi |
|---|
| 55 | |
|---|
| 56 | # mettre les valeurs de local.sh comme "default" pour debconf |
|---|
| 57 | db_get alternc/hostingname |
|---|
| 58 | if [ -z "$RET" ] |
|---|
| 59 | then |
|---|
| 60 | db_set alternc/hostingname "$HOSTING" |
|---|
| 61 | fi |
|---|
| 62 | |
|---|
| 63 | db_get alternc/desktopname |
|---|
| 64 | if [ -z "$RET" ] |
|---|
| 65 | then |
|---|
| 66 | db_set alternc/desktopname "$FQDN" |
|---|
| 67 | fi |
|---|
| 68 | |
|---|
| 69 | db_get alternc/public_ip |
|---|
| 70 | if [ -z "$RET" ] |
|---|
| 71 | then |
|---|
| 72 | db_set alternc/public_ip "$PUBLIC_IP" |
|---|
| 73 | fi |
|---|
| 74 | |
|---|
| 75 | db_get alternc/internal_ip |
|---|
| 76 | if [ -z "$RET" ] |
|---|
| 77 | then |
|---|
| 78 | db_set alternc/internal_ip "$INTERNAL_IP" |
|---|
| 79 | fi |
|---|
| 80 | |
|---|
| 81 | db_get alternc/monitor_ip |
|---|
| 82 | if [ -z "$RET" ] |
|---|
| 83 | then |
|---|
| 84 | db_set alternc/monitor_ip "$MONITOR_IP" |
|---|
| 85 | fi |
|---|
| 86 | |
|---|
| 87 | db_get alternc/ns1 |
|---|
| 88 | if [ -z "$RET" ] |
|---|
| 89 | then |
|---|
| 90 | db_set alternc/ns1 "$NS1_HOSTNAME" |
|---|
| 91 | fi |
|---|
| 92 | |
|---|
| 93 | db_get alternc/ns2 |
|---|
| 94 | if [ -z "$RET" ] |
|---|
| 95 | then |
|---|
| 96 | db_set alternc/ns2 "$NS2_HOSTNAME" |
|---|
| 97 | fi |
|---|
| 98 | |
|---|
| 99 | db_get alternc/default_mx |
|---|
| 100 | if [ -z "$RET" ] |
|---|
| 101 | then |
|---|
| 102 | db_set alternc/default_mx "$DEFAULT_MX" |
|---|
| 103 | fi |
|---|
| 104 | |
|---|
| 105 | db_get alternc/mysql/host |
|---|
| 106 | if [ -z "$RET" ] |
|---|
| 107 | then |
|---|
| 108 | db_set alternc/mysql/host "$MYSQL_HOST" |
|---|
| 109 | fi |
|---|
| 110 | |
|---|
| 111 | db_get alternc/mysql/db |
|---|
| 112 | if [ -z "$RET" ] |
|---|
| 113 | then |
|---|
| 114 | db_set alternc/mysql/db "$MYSQL_DATABASE" |
|---|
| 115 | fi |
|---|
| 116 | |
|---|
| 117 | db_get alternc/mysql/user |
|---|
| 118 | if [ -z "$RET" ] |
|---|
| 119 | then |
|---|
| 120 | db_set alternc/mysql/user "$MYSQL_USER" |
|---|
| 121 | fi |
|---|
| 122 | |
|---|
| 123 | db_get alternc/mysql/password |
|---|
| 124 | if [ -z "$RET" ] |
|---|
| 125 | then |
|---|
| 126 | db_set alternc/mysql/password "$MYSQL_PASS" |
|---|
| 127 | fi |
|---|
| 128 | |
|---|
| 129 | db_get alternc/mysql/client |
|---|
| 130 | if [ -z "$RET" ] |
|---|
| 131 | then |
|---|
| 132 | db_set alternc/mysql/client "$MYSQL_CLIENT" |
|---|
| 133 | fi |
|---|
| 134 | |
|---|
| 135 | db_get alternc/sql/backup_type |
|---|
| 136 | if [ -z "$RET" ] |
|---|
| 137 | then |
|---|
| 138 | db_set alternc/sql/backup_type "$SQLBACKUP_TYPE" |
|---|
| 139 | fi |
|---|
| 140 | |
|---|
| 141 | db_get alternc/sql/backup_overwrite |
|---|
| 142 | if [ -z "$RET" ] |
|---|
| 143 | then |
|---|
| 144 | db_set alternc/sql/backup_overwrite "$SQLBACKUP_OVERWRITE" |
|---|
| 145 | fi |
|---|
| 146 | |
|---|
| 147 | db_get alternc/alternc_location |
|---|
| 148 | if [ -z "$RET" ] |
|---|
| 149 | then |
|---|
| 150 | db_set alternc/alternc_location "$ALTERNC_LOC" |
|---|
| 151 | fi |
|---|
| 152 | |
|---|
| 153 | db_input medium alternc/desktopname || true |
|---|
| 154 | db_input medium alternc/hostingname || true |
|---|
| 155 | db_input medium alternc/internal_ip || true |
|---|
| 156 | db_input medium alternc/public_ip || true |
|---|
| 157 | db_input medium alternc/default_mx || true |
|---|
| 158 | db_input medium alternc/ns1 || true |
|---|
| 159 | db_input medium alternc/ns2 || true |
|---|
| 160 | db_input low alternc/alternc_location || true |
|---|
| 161 | db_input low alternc/mysql/host || true |
|---|
| 162 | db_input low alternc/mysql/db || true |
|---|
| 163 | db_input low alternc/mysql/user || true |
|---|
| 164 | db_input low alternc/mysql/password || true |
|---|
| 165 | db_input low alternc/mysql/client || true |
|---|
| 166 | db_input low alternc/sql/backup_type || true |
|---|
| 167 | db_input low alternc/sql/overwrite || true |
|---|
| 168 | db_input low alternc/monitor_ip || true |
|---|
| 169 | db_input low alternc/slaves || true |
|---|
| 170 | db_go |
|---|
| 171 | |
|---|
| 172 | # vim: et sw=4 |
|---|