| 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 | # default values for local.sh |
|---|
| 23 | MYSQL_HOST=127.0.0.1 |
|---|
| 24 | MYSQL_DATABASE=alternc |
|---|
| 25 | MYSQL_USER=sysusr |
|---|
| 26 | MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" |
|---|
| 27 | MYSQL_CLIENT=localhost |
|---|
| 28 | FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`" |
|---|
| 29 | INTERNAL_IP="`/sbin/ifconfig|grep "inet addr:" | grep -v 127.0.0.1| head -1 | sed -e 's/^.*addr:\([0-9\.]*\).*$/\1/' 2>/dev/null || hostname -f`" |
|---|
| 30 | PUBLIC_IP="$INTERNAL_IP" |
|---|
| 31 | DEFAULT_MX="`cat /etc/mailname 2>/dev/null || hostname -f`" |
|---|
| 32 | ALTERNC_LOC=/var/alternc |
|---|
| 33 | NS1_HOSTNAME="$FQDN" |
|---|
| 34 | NS2_HOSTNAME="$FQDN" |
|---|
| 35 | HOSTING="AlternC" |
|---|
| 36 | |
|---|
| 37 | if [ -r /etc/alternc/local.sh ]; then |
|---|
| 38 | # source the current config |
|---|
| 39 | . /etc/alternc/local.sh |
|---|
| 40 | fi |
|---|
| 41 | |
|---|
| 42 | # mettre les valeurs de local.sh comme "default" pour debconf |
|---|
| 43 | db_get alternc/hostingname |
|---|
| 44 | if [ -z "$RET" ] |
|---|
| 45 | then |
|---|
| 46 | db_set alternc/hostingname "$HOSTING" |
|---|
| 47 | fi |
|---|
| 48 | |
|---|
| 49 | db_get alternc/desktopname |
|---|
| 50 | if [ -z "$RET" ] |
|---|
| 51 | then |
|---|
| 52 | db_set alternc/desktopname "$FQDN" |
|---|
| 53 | fi |
|---|
| 54 | |
|---|
| 55 | db_get alternc/public_ip |
|---|
| 56 | if [ -z "$RET" ] |
|---|
| 57 | then |
|---|
| 58 | db_set alternc/public_ip "$PUBLIC_IP" |
|---|
| 59 | fi |
|---|
| 60 | |
|---|
| 61 | db_get alternc/internal_ip |
|---|
| 62 | if [ -z "$RET" ] |
|---|
| 63 | then |
|---|
| 64 | db_set alternc/internal_ip "$INTERNAL_IP" |
|---|
| 65 | fi |
|---|
| 66 | |
|---|
| 67 | db_get alternc/monitor_ip |
|---|
| 68 | if [ -z "$RET" ] |
|---|
| 69 | then |
|---|
| 70 | db_set alternc/monitor_ip "$MONITOR_IP" |
|---|
| 71 | fi |
|---|
| 72 | |
|---|
| 73 | db_get alternc/ns1 |
|---|
| 74 | if [ -z "$RET" ] |
|---|
| 75 | then |
|---|
| 76 | db_set alternc/ns1 "$NS1_HOSTNAME" |
|---|
| 77 | fi |
|---|
| 78 | |
|---|
| 79 | db_get alternc/ns2 |
|---|
| 80 | if [ -z "$RET" ] |
|---|
| 81 | then |
|---|
| 82 | db_set alternc/ns2 "$NS2_HOSTNAME" |
|---|
| 83 | fi |
|---|
| 84 | |
|---|
| 85 | db_get alternc/bind_internal |
|---|
| 86 | if [ -z "$RET" ] |
|---|
| 87 | then |
|---|
| 88 | db_set alternc/bind_internal "$BIND_INTERNAL" |
|---|
| 89 | fi |
|---|
| 90 | |
|---|
| 91 | db_get alternc/default_mx |
|---|
| 92 | if [ -z "$RET" ] |
|---|
| 93 | then |
|---|
| 94 | db_set alternc/default_mx "$DEFAULT_MX" |
|---|
| 95 | fi |
|---|
| 96 | |
|---|
| 97 | db_get alternc/mysql/host |
|---|
| 98 | if [ -z "$RET" ] |
|---|
| 99 | then |
|---|
| 100 | db_set alternc/mysql/host "$MYSQL_HOST" |
|---|
| 101 | fi |
|---|
| 102 | |
|---|
| 103 | db_get alternc/mysql/db |
|---|
| 104 | if [ -z "$RET" ] |
|---|
| 105 | then |
|---|
| 106 | db_set alternc/mysql/db "$MYSQL_DATABASE" |
|---|
| 107 | fi |
|---|
| 108 | |
|---|
| 109 | db_get alternc/mysql/user |
|---|
| 110 | if [ -z "$RET" ] |
|---|
| 111 | then |
|---|
| 112 | db_set alternc/mysql/user "$MYSQL_USER" |
|---|
| 113 | fi |
|---|
| 114 | |
|---|
| 115 | db_get alternc/mysql/password |
|---|
| 116 | if [ -z "$RET" ] |
|---|
| 117 | then |
|---|
| 118 | db_set alternc/mysql/password "$MYSQL_PASS" |
|---|
| 119 | fi |
|---|
| 120 | |
|---|
| 121 | db_get alternc/mysql/client |
|---|
| 122 | if [ -z "$RET" ] |
|---|
| 123 | then |
|---|
| 124 | db_set alternc/mysql/client "$MYSQL_CLIENT" |
|---|
| 125 | fi |
|---|
| 126 | |
|---|
| 127 | db_get alternc/alternc_location |
|---|
| 128 | if [ -z "$RET" ] |
|---|
| 129 | then |
|---|
| 130 | db_set alternc/alternc_location "$ALTERNC_LOC" |
|---|
| 131 | fi |
|---|
| 132 | |
|---|
| 133 | db_get alternc/mynetwork |
|---|
| 134 | if [ -z "$RET" ] |
|---|
| 135 | then |
|---|
| 136 | db_set alternc/mynetwork "$SMTP_RELAY_NETWORKS" |
|---|
| 137 | fi |
|---|
| 138 | |
|---|
| 139 | db_input medium alternc/desktopname || true |
|---|
| 140 | db_input medium alternc/hostingname || true |
|---|
| 141 | db_input medium alternc/internal_ip || true |
|---|
| 142 | db_input medium alternc/public_ip || true |
|---|
| 143 | db_input medium alternc/default_mx || true |
|---|
| 144 | db_input medium alternc/ns1 || true |
|---|
| 145 | db_input medium alternc/ns2 || true |
|---|
| 146 | db_input low alternc/alternc_location || true |
|---|
| 147 | db_input low alternc/mysql/host || true |
|---|
| 148 | db_input low alternc/mysql/db || true |
|---|
| 149 | db_input low alternc/mysql/user || true |
|---|
| 150 | db_input low alternc/mysql/password || true |
|---|
| 151 | db_input low alternc/mysql/client || true |
|---|
| 152 | db_input low alternc/monitor_ip || true |
|---|
| 153 | db_input low alternc/bind_internal || true |
|---|
| 154 | db_input low alternc/mynetwork || true |
|---|
| 155 | db_go |
|---|
| 156 | |
|---|
| 157 | # vim: et sw=4 |
|---|