alternc-slave.config 3.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#! /bin/sh

set -e

# Source debconf library.
. /usr/share/debconf/confmodule
db_title AlternC

# default values for local.sh
MYSQL_HOST=127.0.0.1
MYSQL_DATABASE=alternc
MYSQL_USER=sysusr
MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `"
MYSQL_CLIENT=localhost
FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`"
16
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`"
17 18
PUBLIC_IP="$INTERNAL_IP"
DEFAULT_MX="`cat /etc/mailname 2>/dev/null || hostname -f`"
19
ALTERNC_HTML="/var/www/alternc/"
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
NS1_HOSTNAME="$FQDN"
NS2_HOSTNAME="$FQDN"
HOSTING="AlternC"
SQLBACKUP_TYPE="rotate"
SQLBACKUP_OVERWRITE="no"

if [ -r /etc/alternc/local.sh ]; then
    # source the current config
    . /etc/alternc/local.sh
fi
if [ -r /etc/alternc/my.cnf ]; then
    # make mysql configuration available as shell variables
    # to convert from .cnf to shell syntax, we:
    # * match only lines with "equal" in them (/=/)
    # * remove whitespace around the = and add a left quote operator ' (;s)
    # * add a right quote operator at the end of line (;s)
    # * convert mysql variables into our MYSQL_ naming convention (;s)
    # * print the result (;p)
    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`
fi

# mettre les valeurs de local.sh comme "default" pour debconf
db_get alternc-slave/hostingname
if [ -z "$RET" ]
    then
    db_set alternc-slave/hostingname "$HOSTING"
fi

db_get alternc-slave/desktopname
if [ -z "$RET" ]
    then
db_set alternc-slave/desktopname "$FQDN"
fi

db_get alternc-slave/public_ip
if [ -z "$RET" ]
    then
db_set alternc-slave/public_ip "$PUBLIC_IP"
fi

db_get alternc-slave/internal_ip
if [ -z "$RET" ]
    then
db_set alternc-slave/internal_ip "$INTERNAL_IP"
fi

db_get alternc-slave/monitor_ip
if [ -z "$RET" ]
    then
db_set alternc-slave/monitor_ip "$MONITOR_IP"
fi

db_get alternc-slave/ns1
if [ -z "$RET" ]
    then
db_set alternc-slave/ns1 "$NS1_HOSTNAME"
fi

db_get alternc-slave/ns2
if [ -z "$RET" ]
    then
db_set alternc-slave/ns2 "$NS2_HOSTNAME"
fi

db_get alternc-slave/default_mx
if [ -z "$RET" ]
    then
db_set alternc-slave/default_mx "$DEFAULT_MX"
fi

db_get alternc-slave/mysql/host
if [ -z "$RET" ]
    then
db_set alternc-slave/mysql/host "$MYSQL_HOST"
fi

db_get alternc-slave/mysql/db
if [ -z "$RET" ]
    then
db_set alternc-slave/mysql/db "$MYSQL_DATABASE"
fi

db_get alternc-slave/mysql/user
if [ -z "$RET" ]
    then
db_set alternc-slave/mysql/user "$MYSQL_USER"
fi

db_get alternc-slave/mysql/password
if [ -z "$RET" ]
    then
db_set alternc-slave/mysql/password "$MYSQL_PASS"
fi

db_get alternc-slave/mysql/client
if [ -z "$RET" ]
    then
db_set alternc-slave/mysql/client "$MYSQL_CLIENT"
fi

db_get alternc-slave/sql/backup_type
if [ -z "$RET" ]
    then
db_set alternc-slave/sql/backup_type "$SQLBACKUP_TYPE"
fi

db_get alternc-slave/sql/backup_overwrite
if [ -z "$RET" ]
    then
db_set alternc-slave/sql/backup_overwrite "$SQLBACKUP_OVERWRITE"
fi

132
db_get alternc-slave/alternc_html
133 134
if [ -z "$RET" ]
    then
135
db_set alternc-slave/alternc_html "$ALTERNC_HTML"
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
fi

db_input medium alternc-slave/desktopname || true
db_input medium alternc-slave/hostingname || true
db_input medium alternc-slave/internal_ip || true
db_input medium alternc-slave/public_ip || true
db_input medium alternc-slave/default_mx || true
db_input medium alternc-slave/ns1 || true
db_input medium alternc-slave/ns2 || true
db_input low alternc-slave/mysql/host || true
db_input low alternc-slave/mysql/db || true
db_input low alternc-slave/mysql/user || true
db_input low alternc-slave/mysql/password || true
db_input low alternc-slave/mysql/client || true
db_input low alternc-slave/sql/backup_type || true
db_input low alternc-slave/sql/overwrite || true
db_input low alternc-slave/monitor_ip || true
db_go

# vim: et sw=4