Files
uberspace-setup/uber-standardsetup.sh

89 lines
2.7 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
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-Passwort: $MYSQLPASS"
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
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
# Webmail
mkdir $VIRTUAL/webmail.$DOMAIN
echo "RedirectPermanent / https://webmail.$HOSTNAME" > $VIRTUAL/webmail.$DOMAIN/.htaccess
2015-07-07 13:18:43 +03:00
# Create datasheet
2014-11-27 17:15:23 +01:00
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