Files
uberspace-setup/uber-standardsetup.sh

119 lines
3.8 KiB
Bash
Raw Normal View History

2015-07-07 16:15:27 +03:00
#!/bin/bash
########################################################################
# Copyright (C) 2014 Max Mehl <mail@mehl.mx>
########################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
2015-07-07 16:15:27 +03:00
########################################################################
#
# This script enables users to quickly setup a new Uberspace.de host
# with domains, symlinks etc.
# Afterwards it creates a handy datasheet (which was the main reason for
# writing this script)
#
########################################################################
2014-11-27 17:15:23 +01:00
SERVER=$(echo $HOSTNAME | sed -e 's/.uberspace.de//g')
VIRTUAL=/var/www/virtual/$USER
MYSQLPASS=$(awk '/^\[client\]/,/^password=/' ~/.my.cnf | grep "password=" | sed -e 's/password=//g' | sed -e 's/[ \t].*//g')
# In older hosts, there's only 1 MySQL password and not 2
if [ "$MYSQLPASS" == "" ]; then
MYSQLPASS=$(grep "password=" ~/.my.cnf | sed -e 's/password=//g' | sed -e 's/[ \t].*//g')
fi
2014-11-27 17:15:23 +01:00
read -p "Domain: " DOMAIN
read -p "SSH Passwort: " SSHPASS
2015-07-08 00:17:41 +03:00
IP=$(wget -q -O - http://ip4.nandus.net)
2014-11-27 17:15:23 +01:00
2015-07-07 13:18:43 +03:00
echo "User: $USER" # user in system
echo "Hostname: $HOSTNAME" # e.g. cetus.uberspace.de
echo "Homedir: $HOME" # Homedir
echo "Server: $SERVER" # e.g. cetus
2014-11-27 17:15:23 +01:00
echo "Domain: $DOMAIN"
2015-07-07 13:18:43 +03:00
echo "IP: $IP"
2014-11-27 17:15:23 +01:00
echo "Virtualdir: $VIRTUAL"
echo "MySQL Password: $MYSQLPASS"
echo "SSH Password: $SSHPASS"
2014-11-27 17:15:23 +01:00
echo ""
2015-07-07 13:18:43 +03:00
read -p "All correct? If not, cancel now." END
2014-11-27 17:15:23 +01:00
2015-07-07 13:18:43 +03:00
# Setup domain
2014-11-27 17:15:23 +01:00
uberspace-add-domain -d $DOMAIN -w
uberspace-add-domain -d "*.$DOMAIN" -w
uberspace-add-domain -d $DOMAIN -m
2015-07-07 13:18:43 +03:00
# Setup basic directories
2015-01-09 17:13:39 +01:00
mkdir ~/backup
mkdir -p ~/bin ~/lib/python2.4 ~/lib/python2.6
2014-11-27 17:15:23 +01:00
2015-07-07 13:18:43 +03:00
# Setup softlinks
2015-01-09 17:13:39 +01:00
ln -s $VIRTUAL ~/virtual
2014-11-27 17:15:23 +01:00
# Mail
vsetup
## PHP
# Piwik and WP don't work smoothly with PHP 5.6, so switch to 5.5
cp $HOME/etc/phpversion $HOME/etc/phpversion.original
echo "PHPVERSION=5.5" > $HOME/etc/phpversion
2014-11-27 17:15:23 +01:00
# Webmail
mkdir $VIRTUAL/webmail.$DOMAIN
echo "RedirectPermanent / https://webmail.$HOSTNAME" > $VIRTUAL/webmail.$DOMAIN/.htaccess
# Web administration panel
read -p "Should the web administration panel be installed? [y/N] " YN
if [ "$YN" == "y" ]; then
SENDMAILPATH=$(which sendmail)
2015-12-11 20:18:39 +01:00
read -p "TO which email should reports be sent? " TOEMAIL
read -p "FROM which email should reports be sent? " FREMAIL
2016-03-17 11:28:28 +01:00
git clone https://src.mehl.mx/mxmehl/uberspace-webadmin.git $VIRTUAL/panel.$DOMAIN
# Create and edit config.cfg
cp $VIRTUAL/panel.$DOMAIN/config.cfg.sample $VIRTUAL/panel.$DOMAIN/config.cfg
sed -r -i \
-e "s|DOMAIN=.*|DOMAIN=$DOMAIN|" \
2015-12-11 20:18:39 +01:00
-e "s|TOEMAIL=.*|TOEMAIL=$TOEMAIL|" \
-e "s|FREMAIL=.*|FREMAIL=$FREMAIL|" \
$VIRTUAL/panel.$DOMAIN/config.cfg
# Set htaccess and htpasswd
cp $VIRTUAL/panel.$DOMAIN/.htaccess.sample $VIRTUAL/panel.$DOMAIN/.htaccess
sed -r -i \
-e "s|AuthUserFile.*|AuthUserFile $VIRTUAL/panel.$DOMAIN/.htpasswd|" \
$VIRTUAL/panel.$DOMAIN/.htaccess
htpasswd -b -c $VIRTUAL/panel.$DOMAIN/.htpasswd $USER $SSHPASS
# Install dependencies
2015-12-06 22:25:00 +01:00
pip install pexpect --user
fi
2014-11-27 17:15:23 +01:00
2015-07-07 13:18:43 +03:00
# Create datasheet
2014-11-27 17:15:23 +01:00
sed -e 's/SEDDOMAIN/'$DOMAIN'/g' \
-e 's/SEDIP/'$IP'/g' \
-e 's/SEDUSER/'$USER'/g' \
-e 's/SEDHOSTNAME/'$HOSTNAME'/g' \
-e 's/SEDMYSQLPASS/'$MYSQLPASS'/g' \
-e 's/SEDSSHPASS/'$SSHPASS'/g' \
uber-datenblatt-template.txt > $HOME/$USER-Notes.txt
2014-11-27 17:15:23 +01:00