|
| 1 | +#!/bin/bash |
| 2 | +# Script to configuring an ispconfig3 server in a Debian VPS |
| 3 | +# by calocen [at] gmail [dot] com |
| 4 | + |
| 5 | +# getting some enviromment values |
| 6 | +myhostname=`hostname -f` |
| 7 | +mydomain=`hostname -d` |
| 8 | +myip=`hostname -i` |
| 9 | +[ ! -x /usr/bin/geoiplookup ] && apt-get --assume-yes install geoip-bin |
| 10 | +mycountry=`geoiplookup $myip | cut -f4 -d" " | cut -f1 -d","` |
| 11 | +myprovince=`geoiplookup $myip | cut -f5 -d" "` |
| 12 | + |
| 13 | +# reconfiguring webalizer, postfix |
| 14 | +# could be cool to modify here webalizer values |
| 15 | +dpkg-reconfigure -u webalizer |
| 16 | +postconf -e "myhostname = $myhostname" |
| 17 | +postconf -e "mydestination = $myhostname, localhost" |
| 18 | +echo $myhostname > /etc/mailname |
| 19 | +dpkg-reconfigure -u postfix |
| 20 | + |
| 21 | +# request new password |
| 22 | +oldpwd=`grep password /root/.my.cnf | tr "\t" " " | tr -s " " | cut -f3 -d" "` |
| 23 | +read -p "mysql password: [$oldpwd] " mysqlpwd |
| 24 | +[ -z $mysqlpwd ] && mysqlpwd=$oldpwd |
| 25 | +echo $mysqlpwd |
| 26 | +#read -p "Are you sure? (y/n) " sure |
| 27 | +## who said fear ## |
| 28 | +set -x |
| 29 | +mysqladmin -u root -p$oldpwd password $mysqlpwd |
| 30 | +mysqladmin -u root -p$mysqlpwd -h localhost password $mysqlpwd |
| 31 | +cat << EOF > /root/.my.cnf |
| 32 | +[client] |
| 33 | +password = $mysqlpwd |
| 34 | +EOF |
| 35 | +chmod 600 /root/.my.cnf |
| 36 | + |
| 37 | +# changing mydns password |
| 38 | +mysql -e "SET PASSWORD FOR 'mydns'@'%' = PASSWORD( '$mysqlpwd' )" |
| 39 | +mysql -e "SET PASSWORD FOR 'mydns'@'localhost' = PASSWORD( '$mysqlpwd' )" |
| 40 | +cp -ax /etc/mydns.conf /etc/mydns.conf~ |
| 41 | +sed s/$oldpwd/$mysqlpwd/g < /etc/mydns.conf~ > /etc/mydns.conf |
| 42 | + |
| 43 | +# enabling mydns |
| 44 | +mydns --create-tables > /tmp/mydns.sql |
| 45 | +mysql -e "CREATE DATABASE IF NOT EXISTS mydns ; USE mydns ; SOURCE /tmp/mydns.sql;" |
| 46 | +rm /tmp/mydns.* |
| 47 | +invoke-rc.d mydns restart |
| 48 | + |
| 49 | +# preparing server installation |
| 50 | +mv /etc/ssl/openssl.cnf /etc/ssl/openssl.cnf~ |
| 51 | +sed s/"YOURHOSTNAME"/"$myhostname"/g < /usr/local/bin/openssl.cnf | |
| 52 | +sed s/"YOURDOMAIN"/"$mydomain"/g | \ |
| 53 | +sed s/"YOURCOUNTRY"/"$mycountry"/g | \ |
| 54 | +sed s/"YOURPROVINCE"/"$myprovince"/g > /etc/ssl/openssl.cnf |
| 55 | + |
| 56 | +tar xfz /root/downloads/ISPConfig-3.0.0.7-beta.tar.gz -C /usr/local/src |
| 57 | +# here would be some stuff to update from SVN |
| 58 | +cd /usr/local/src/ispconfig3_install/install/ |
| 59 | +php -q install.php |
| 60 | + |
| 61 | + |
0 commit comments