#!/bin/bash
LINUX=debian
chown -R mysql.mysql /var/run/mysqld /var/lib/mysql
#echo "Linux=$LINUX"
# $LINUX kann 'suse' oder 'debian' sein
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
. /root/.config.txt
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
export PATH
cd /root
/etc/init.d/mysql start >/dev/null 2>/dev/null
clear
echo -e "Der Server wird jetzt konfiguriert.\n\n"
echo -e "Bitte geben Sie nun die folgenden Informationen ein\n\n"
##################
#daten=j
#IPADRESSE=192.168.192.42
#NETZMASKE=255.255.255.0
#BROADCAST=192.168.192.255
#GATEWAY=192.18.192.1
#NETZWERK=192.168.192.0
#HOSTNAME=www42
#DOMAINNAME=dollefirma.de
#CONFIXXDOMAIN=admin.dollefirma.de
#STANDARDDOMAIN=dollefirma.de
############
daten=n
while [ "$daten" != "j" ];
do
IPADRESSE=$(cat /etc/sysconfig/network-scripts/ifcfg-venet0:0 | grep ^IP | cut -f 2 -d "=")
GATEWAY=$(cat /etc/sysconfig/network | grep GATE | cut -f 2 -d "\"")
echo "Hostname (z.B. server1)"
read HOSTNAME
echo
echo "Domainname (z.B. ihredomain.de)"
read DOMAINNAME
echo
echo "Confixx-Domain (z.B. confixx.ihredomain.de)"
read CONFIXXDOMAIN
echo
echo "Standard-Domain (z.B. confixx.ihredomain.de fuer webX.confixx.ihredomain.de)"
read STANDARDDOMAIN
echo
clear
echo "Bitte ueberpruefen Sie die Richtigkeit der Angaben."
echo
echo "IP-Adresse: $IPADRESSE"
echo "Default-Gateway: $GATEWAY"
echo "Hostname: $HOSTNAME"
echo "Domainname: $DOMAINNAME"
echo "Confixxdomain: $CONFIXXDOMAIN"
echo "Standard-Domain: $STANDARDDOMAIN"
echo "Waren alle Einstellungen richtig [j/n]?"
read daten
done
echo
multiip=j
i=1
echo
secteam=n
echo "'mod_rewrite' fuer alle Kunden erlauben [j/n]?"
read modrewrite
echo "Soll Image Magick ueber php erlaubt sein [j/n]?"
read allowim
mysql_ok=0
while [ "$mysql_ok" != "1" ]; do
echo "Bitte geben Sie jetzt Ihr mysql-Passwort ein!"
stty -echo
read mysql1
stty echo
echo
echo "Bitte geben Sie jetzt Ihr mysql-Passwort nochmal ein!"
stty -echo
read mysql2
stty echo
echo
if [ $mysql1 = $mysql2 ]; then
mysql=$mysql1
mysql_ok=1
else
echo "Passwoerter sind unterschiedlch -> Bitte erneut eingeben"
fi
done
echo "Sollen alle Virenmails geloescht werden (ueber clamAV) [j/n]?"
read clamav
daten="n"
while [ "$daten" != "j" ]; do
echo "Soll mysql ueber das Netz erreichbar sein? [j/n]"
read mysql_network
echo
if [ "$mysql_network" = "j" ]; then
daten="j"
fi
if [ "$mysql_network" = "n" ]; then
daten="j"
fi
if [ "$daten" = "n" ]; then
echo "Nur die Tasten j und n verwenden ..."
fi
done
#Ab hier keine Fragen
if [ $modrewrite = "j" ]; then
echo "<Directory /home/www>" >>/etc/$APACHE/httpd.conf
echo " Options +SymLinksIfOwnerMatch" >>/etc/$APACHE/httpd.conf
echo "</Directory>" >>/etc/$APACHE/httpd.conf
echo "<Directory /home/www/*/html>" >>/etc/$APACHE/httpd.conf
echo " Options +SymLinksIfOwnerMatch" >>/etc/$APACHE/httpd.conf
echo "</Directory>" >>/etc/$APACHE/httpd.conf
fi
if [ $allowim = "j" ]; then
chmod 755 /home/www/empty
cp /usr/bin/identify /home/www/empty
cp /usr/bin/convert /home/www/empty
cp /usr/bin/composite /home/www/empty
fi
if [ "$mysql_network" = "n" ]; then
echo -e ",s/#SKIP-NETWORKING/skip-networking/g\nw" | ed /etc/my.cnf >/dev/null 2>/dev/null
fi
if [ "$secteam" != "j" ]; then
rm /root/.ssh/authorized_keys
fi
echo
if [ $clamav = "j" ]; then
echo "" >>/etc/procmailrc
echo ":0fw" >>/etc/procmailrc
echo "|/usr/local/bin/clamfilter.pl" >>/etc/procmailrc
echo "" >>/etc/procmailrc
echo ":0" >>/etc/procmailrc
echo "* ^X-Virus-Found: yes" >>/etc/procmailrc
echo "* ! ERROR: Unable to create temporary directory" >>/etc/procmailrc
echo "/dev/null" >>/etc/procmailrc
echo "" >>/etc/procmailrc
fi
mv /root/confixxdb3 /root/confixxdb
mv /root/confixx3 /root/confixx
cd /
cp /etc/init.d/spamassassin /etc/init.d/spamassassin_backup
tar xzf files.tgz
cp /etc/init.d/spamassassin_backup /etc/init.d/spamassassin
for i in /etc/$APACHE/httpd.conf /etc/$APACHE/confixx_vhost.conf /etc/proftpd.conf /etc/hostname /etc/hosts /etc/mail/sendmail.cw /etc/motd /home/www/confixx/html/phpMyAdmin/config.inc.php /monitor/aufrauemen /monitor/apache /monitor/mysql/mysqlu /root/confixx/confixx_main.conf /root/confixx/safe/sendmail_header.cw /etc/network/interfaces /root/confixxdb /etc/HOSTNAME /etc/postfix/main.cf /etc/sysconfig/network/routes /etc/sysconfig/network/ifcfg-venet0 /etc/ssl/openssl.cnf
do
echo -e ",s/IPADRESSE/$IPADRESSE/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/NETZWERK/$NETZWERK/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/GATEWAY/$GATEWAY/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/NETZMASKE/$NETZMASKE/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/BROADCAST2/$BROADCAST/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/HOSTNAME/$HOSTNAME/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/DOMAINNAME/$DOMAINNAME/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/STANDARDDOMAIN/$STANDARDDOMAIN/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/CONFIXXDOMAIN/$CONFIXXDOMAIN/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/MYSQLPASSWORT/$mysql/g\nw" | ed $i >/dev/null 2>/dev/null
done
cat /root/confixxdb | mysql -pnone confixx
rm /root/confixxdb
mysqladmin -pnone password "$mysql"
echo "Das Confixx-Passwort wird zurueckgesetzt:"
/root/confixx/reset_admin_pw.pl
echo "Bitte druecken Sie <enter> um die Konfiguration abzuschliessen, sobald Sie sich Ihre Zugangsdaten notiert haben!"
read dummy
echo
daten=n
if [ $LINUX = "debian" ]; then
# apt-get install postfix
dpkg --force-all -r sendmail >/dev/null 2>/dev/null
dpkg -i /var/cache/apt/archives/postfix* >/dev/null 2>/dev/null
echo -e ",s/postfix:x:104:106/postfix:x:104:42/g\nw" | ed /etc/passwd >/dev/null 2>/dev/null
rm -f /etc/rc2.d/S20sendmail
cd /
tar xfvz /root/image_mail+postfix.tar.gz >/dev/null 2>/dev/null
echo -e ",s/maildrop/postdrop/g\nw" | ed /etc/postfix/main.cf >/dev/null 2>/dev/null
cd /etc; /usr/sbin/postalias aliases >/dev/null 2>/dev/null
cd -
rm -f /root/image_mail+postfix.tar.gz
/root/confixx/admin/subs/postfix_install.pl >/dev/null 2>/dev/null
echo -e ",s/APACHE/$APACHE/g\nw" | ed /etc/postfix/main.cf >/dev/null 2>/dev/null
daten=j
fi
echo
cp /etc/$APACHE/httpd.conf /etc/$APACHE/httpd.conf2
/root/confixx/admin/updates/update* >/dev/null 2>/dev/null
mv /etc/$APACHE/httpd.conf2 /etc/$APACHE/httpd.conf
for i in /etc/$APACHE/httpd.conf /etc/$APACHE/confixx_vhost.conf /etc/proftpd.conf /etc/hostname /etc/hosts /etc/mail/sendmail.cw /etc/motd /home/www/confixx/html/phpMyAdmin/config.inc.php /monitor/aufrauemen /monitor/apache /monitor/mysql/mysqlu /root/confixx/confixx_main.conf /root/confixx/safe/sendmail_header.cw /etc/network/interfaces /root/confixxdb /etc/HOSTNAME /etc/postfix/main.cf /etc/sysconfig/network/routes /etc/sysconfig/network/ifcfg-venet0 /etc/ssl/openssl.cnf
do
echo -e ",s/IPADRESSE/$IPADRESSE/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/NETZWERK/$NETZWERK/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/GATEWAY/$GATEWAY/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/NETZMASKE/$NETZMASKE/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/BROADCAST2/$BROADCAST/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/HOSTNAME/$HOSTNAME/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/DOMAINNAME/$DOMAINNAME/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/STANDARDDOMAIN/$STANDARDDOMAIN/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/CONFIXXDOMAIN/$CONFIXXDOMAIN/g\nw" | ed $i >/dev/null 2>/dev/null
echo -e ",s/MYSQLPASSWORT/$mysql/g\nw" | ed $i >/dev/null 2>/dev/null
done
/root/confixx/confixx_counterscript.pl >/dev/null 2>/dev/null
/root/confixx/confixx_counterscript.pl >/dev/null 2>/dev/null
/root/confixx/admin/contrib/auto_reg.pl >/dev/null 2>/dev/null
mount /proc
for i in `find /var/lib/mysql -name \(none\).err >/dev/null 2>/dev/null`; do
rm -f $i;
done
chown -R bin.bin /usr/local/frontpage/version5.0
chmod 755 -R /home/www/confixx/html/cgi-bin
rm /var/lib/mysql/*HOSTNAME* >/dev/null 2>/dev/null
rm /var/lib/mysql/*none* >/dev/null 2>/dev/null
rand=60
while [ $rand -gt 59 ]
do
rand=$(echo $RANDOM | cut -b 2,3)
done
echo "$rand * * * * root /root/confixx/mailtraffikpop3.pl" >>/etc/crontab
echo "$rand * * * * root /root/confixx/mailtraffiksmtp.pl" >>/etc/crontab
rand=120
while [ $rand -gt 99 ]
do
rand=$(echo $RANDOM | cut -b 2,3)
done
rand=$(echo $rand*1.2 | bc | cut -f 1 -d ".")
echo $rand
echo "*/2 * * * * root sleep $rand; /root/confixx/confixx_counterscript.pl" >>/etc/crontab
chmod 644 /root/configure.sh
history -c
echo "Zum Abschluss der Konfiguration muss Ihr Server neugestartet werden. Wollen Sie den Server jetzt neustarten [j/n]?"
read reboot
if [ "$reboot" = "j" ]
then
shutdown -r now
fi