Files
uberspace-setup/uber-standardsetup.sh

79 lines
2.2 KiB
Bash
Executable File

# uber-standardsetup.sh
#
# Copyright (C) 2015 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/>.
#
#!/bin/bash
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
read -p "Domain: " DOMAIN
IP=$(wget -q -O - http://myexternalip.com/raw)
echo "User: $USER" # user auf dem System
echo "Hostname: $HOSTNAME" # z.B. cetus.uberspace.de
echo "Homedir: $HOME" # Homedir
echo "Server: $SERVER" # z.B. cetus
echo "Domain: $DOMAIN"
echo "Virtualdir: $VIRTUAL"
echo "MySQL-Passwort: $MYSQLPASS"
echo ""
read -p "Alles okay? Sonst jetzt abbrechen." END
# Richte Domain ein
uberspace-add-domain -d $DOMAIN -w
uberspace-add-domain -d "*.$DOMAIN" -w
uberspace-add-domain -d $DOMAIN -m
# Richte grundlegende Verzeichnisse ein
mkdir ~/backup
# Richte softlinks ein
ln -s $VIRTUAL ~/virtual
# Webmail
mkdir $VIRTUAL/webmail.$DOMAIN
echo "RedirectPermanent / https://webmail.$HOSTNAME" > $VIRTUAL/webmail.$DOMAIN/.htaccess
# Erstelle Datenblatt
DOMAIN=$DOMAIN
USER=$USER
HOSTNAME=$HOSTNAME
MYSQLPASS=$MYSQLPASS
SSHPASS=
read -p "SSH Passwort: " SSHPASS
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 > $USER-Notes.txt