| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
set -e |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
TEMPLATE_DIR="/etc/alternc/templates" |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
CONFIG_FILES="" |
|---|
| 19 |
|
|---|
| 20 |
if [ -x /etc/init.d/apache ]; then |
|---|
| 21 |
CONFIG_FILES="$CONFIG_FILES etc/apache/httpd.conf etc/php4/apache/php.ini" |
|---|
| 22 |
fi |
|---|
| 23 |
if [ -x /etc/init.d/apache-ssl ]; then |
|---|
| 24 |
CONFIG_FILES="$CONFIG_FILES etc/apache-ssl/httpd.conf" |
|---|
| 25 |
fi |
|---|
| 26 |
if [ -x /usr/bin/php4-cgi ]; then |
|---|
| 27 |
CONFIG_FILES="$CONFIG_FILES etc/php4/cgi/php.ini" |
|---|
| 28 |
fi |
|---|
| 29 |
if [ -x /etc/init.d/bind9 ]; then |
|---|
| 30 |
CONFIG_FILES="$CONFIG_FILES etc/bind/templates/zone.template |
|---|
| 31 |
etc/bind/templates/named.template etc/bind/named.conf" |
|---|
| 32 |
fi |
|---|
| 33 |
if [ -x /etc/init.d/courier-pop ]; then |
|---|
| 34 |
CONFIG_FILES="$CONFIG_FILES etc/courier/authdaemonrc |
|---|
| 35 |
etc/courier/authmysqlrc" |
|---|
| 36 |
fi |
|---|
| 37 |
if [ -x /etc/init.d/mysql ]; then |
|---|
| 38 |
CONFIG_FILES="$CONFIG_FILES etc/mysql/my.cnf" |
|---|
| 39 |
fi |
|---|
| 40 |
if [ -x /etc/init.d/postfix ]; then |
|---|
| 41 |
CONFIG_FILES="$CONFIG_FILES etc/postfix/main.cf etc/postfix/myalias.cf |
|---|
| 42 |
etc/postfix/mydomain.cf etc/postfix/mygid.cf |
|---|
| 43 |
etc/postfix/myvirtual.cf etc/postfix/sasl/smtpd.conf" |
|---|
| 44 |
fi |
|---|
| 45 |
if [ -x /etc/init.d/proftpd ]; then |
|---|
| 46 |
CONFIG_FILES="$CONFIG_FILES etc/proftpd.conf etc/welcome.msg" |
|---|
| 47 |
fi |
|---|
| 48 |
if [ -d /usr/share/squirrelmail ]; then |
|---|
| 49 |
CONFIG_FILES="$CONFIG_FILES etc/squirrelmail/apache.conf" |
|---|
| 50 |
fi |
|---|
| 51 |
|
|---|
| 52 |
if [ -x /usr/sbin/saslauthd ]; then |
|---|
| 53 |
CONFIG_FILES="$CONFIG_FILES etc/default/saslauthd" |
|---|
| 54 |
fi |
|---|
| 55 |
|
|---|
| 56 |
INSTALLED_CONFIG_TAR="/var/backups/alternc/etc-installed.tar.gz" |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
if [ -f "$INSTALLED_CONFIG_TAR" ]; then |
|---|
| 62 |
CHANGED="`tar -zdf "$INSTALLED_CONFIG_TAR" -C / 2> /dev/null | |
|---|
| 63 |
sed -e 's/^\([^:]*\).*/ \1/' | sort -u`" |
|---|
| 64 |
if [ ! -z "$CHANGED" ]; then |
|---|
| 65 |
echo "The following configuration files has changed since last AlternC" |
|---|
| 66 |
echo "installation :" |
|---|
| 67 |
echo "$CHANGED" |
|---|
| 68 |
echo "" |
|---|
| 69 |
if [ "$1" = "force" ]; then |
|---|
| 70 |
echo "Replacing them as you requested." |
|---|
| 71 |
else |
|---|
| 72 |
echo "These configuration files should normally be modified by" |
|---|
| 73 |
echo "changing the template in $TEMPLATE_DIR and then calling" |
|---|
| 74 |
echo "$0 to perform the update." |
|---|
| 75 |
echo "" |
|---|
| 76 |
echo "Please examine the situation closely and call '$0 force'" |
|---|
| 77 |
echo "if you still want to actually overwrite these files." |
|---|
| 78 |
exit 1 |
|---|
| 79 |
fi |
|---|
| 80 |
fi |
|---|
| 81 |
fi |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
. /etc/alternc/local.sh |
|---|
| 88 |
|
|---|
| 89 |
WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again." |
|---|
| 90 |
|
|---|
| 91 |
VERSION="`dpkg -s alternc | sed -n -e 's/^Version: \(.*\)/\1/p'`" |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`" |
|---|
| 95 |
if [ "$FQDN_LETTER" = "$FQDN" ] |
|---|
| 96 |
then |
|---|
| 97 |
FQDN_LETTER="_" |
|---|
| 98 |
fi |
|---|
| 99 |
|
|---|
| 100 |
NS2_IP=`perl -e "\\$h = (gethostbyname(\"$NS2_HOSTNAME\"))[4]; |
|---|
| 101 |
@ip = unpack('C4', \\$h); |
|---|
| 102 |
print join (\".\", @ip);"` |
|---|
| 103 |
|
|---|
| 104 |
if [ ! -z "$BIND_INTERNAL" ]; then |
|---|
| 105 |
BIND_INTERNAL="$BIND_INTERNAL;" |
|---|
| 106 |
fi |
|---|
| 107 |
|
|---|
| 108 |
if [ -z "$MONITOR_IP" ]; then |
|---|
| 109 |
MONITOR_IP="127.0.0.1" |
|---|
| 110 |
fi |
|---|
| 111 |
|
|---|
| 112 |
SED_SCRIPT=" |
|---|
| 113 |
s\\%%hosting%%\\$HOSTING\\; |
|---|
| 114 |
s\\%%fqdn%%\\$FQDN\\; |
|---|
| 115 |
s\\%%public_ip%%\\$PUBLIC_IP\\; |
|---|
| 116 |
s\\%%internal_ip%%\\$INTERNAL_IP\\; |
|---|
| 117 |
s\\%%monitor_ip%%\\$MONITOR_IP\\; |
|---|
| 118 |
s\\%%ns1%%\\$NS1_HOSTNAME\\; |
|---|
| 119 |
s\\%%ns2%%\\$NS2_HOSTNAME\\; |
|---|
| 120 |
s\\%%bind_internal%%\\$BIND_INTERNAL\\; |
|---|
| 121 |
s\\%%mx%%\\$DEFAULT_MX\\; |
|---|
| 122 |
s\\%%dbhost%%\\$MYSQL_HOST\\; |
|---|
| 123 |
s\\%%dbname%%\\$MYSQL_DATABASE\\; |
|---|
| 124 |
s\\%%dbuser%%\\$MYSQL_USER\\; |
|---|
| 125 |
s\\%%dbpwd%%\\$MYSQL_PASS\\; |
|---|
| 126 |
s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\; |
|---|
| 127 |
s\\%%mynetwork%%\\$SMTP_RELAY_NETWORKS\\; |
|---|
| 128 |
s\\%%warning_message%%\\$WARNING\\; |
|---|
| 129 |
s\\%%fqdn_lettre%%\\$FQDN_LETTER\\; |
|---|
| 130 |
s\\%%version%%\\$VERSION\\; |
|---|
| 131 |
s\\%%ns2_ip%%\\$NS2_IP\\; |
|---|
| 132 |
" |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
BACKUP_FILE="/var/backups/alternc/etc-original-`date +%Y%m%d-%H%M`.tar.gz" |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
BACKUPS="" |
|---|
| 141 |
for file in $CONFIG_FILES; do |
|---|
| 142 |
TEMPLATE="$TEMPLATE_DIR/${file##etc/}" |
|---|
| 143 |
if [ -f "$TEMPLATE" ]; then |
|---|
| 144 |
BACKUPS="$BACKUPS $file" |
|---|
| 145 |
fi |
|---|
| 146 |
done |
|---|
| 147 |
|
|---|
| 148 |
tar -zcf "$BACKUP_FILE" -C / $BACKUPS || true |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
for file in $CONFIG_FILES; do |
|---|
| 154 |
TEMPLATE="$TEMPLATE_DIR/${file##etc/}" |
|---|
| 155 |
if [ -f "$TEMPLATE" ]; then |
|---|
| 156 |
sed -e "$SED_SCRIPT" < $TEMPLATE > /$file |
|---|
| 157 |
fi |
|---|
| 158 |
done |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
if [ -x /etc/init.d/mysql -a ! -d /var/alternc/db/mysql ]; then |
|---|
| 169 |
if /etc/init.d/mysql status | grep -v "MySQL is stopped." > /dev/null; then |
|---|
| 170 |
/etc/init.d/mysql stop |
|---|
| 171 |
fi |
|---|
| 172 |
|
|---|
| 173 |
echo "Setup MySQL and database..." |
|---|
| 174 |
/usr/share/alternc/install/mysql.sh "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE" |
|---|
| 175 |
|
|---|
| 176 |
/etc/init.d/mysql start |
|---|
| 177 |
fi |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
ln -nsf /var/alternc/bureau /var/alternc/dns/$FQDN_LETTER/$FQDN |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
/usr/share/alternc/install/dopo.sh |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
touch /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 190 |
chown root:bind /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 191 |
chmod 640 /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 192 |
touch /var/run/alternc/refresh_slave |
|---|
| 193 |
/usr/lib/alternc/slave_dns |
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
touch /var/alternc/apacheconf/override_php.conf |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
for file in body_checks header_checks; do |
|---|
| 200 |
if [ ! -e "/etc/postfix/$file" ]; then |
|---|
| 201 |
cp /usr/share/alternc/install/$file /etc/postfix |
|---|
| 202 |
fi |
|---|
| 203 |
done |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
for service in apache apache-ssl postfix bind9 courier-authdaemon \ |
|---|
| 209 |
courier-imap courier-imap-ssl courier-pop courier-pop-ssl \ |
|---|
| 210 |
cron proftpd; do |
|---|
| 211 |
test -x /etc/init.d/$service && /etc/init.d/$service force-reload || true |
|---|
| 212 |
done |
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
/usr/lib/alternc/basedir_prot.sh |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
HAS_ROOT="`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'root'" | tail -1`" |
|---|
| 223 |
if [ "$HAS_ROOT" != "1" ]; then |
|---|
| 224 |
echo "Creating root user..." |
|---|
| 225 |
su - www-data -c /usr/share/alternc/install/newone.php |
|---|
| 226 |
echo "" |
|---|
| 227 |
echo "*******************************************" |
|---|
| 228 |
echo "* *" |
|---|
| 229 |
echo "* Root account *" |
|---|
| 230 |
echo "* ------------ *" |
|---|
| 231 |
echo "* *" |
|---|
| 232 |
echo "* user: root password: root *" |
|---|
| 233 |
echo "* *" |
|---|
| 234 |
echo "* Please change this as soon as possible! *" |
|---|
| 235 |
echo "* *" |
|---|
| 236 |
echo "*******************************************" |
|---|
| 237 |
fi |
|---|
| 238 |
|
|---|