#!/bin/bash ######################################################################## # Copyright (C) 2014 Max Mehl ######################################################################## # # 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 . # ######################################################################## # # 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) # ######################################################################## 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://ip4.nandus.net) echo "User: $USER" # user in system echo "Hostname: $HOSTNAME" # e.g. cetus.uberspace.de echo "Homedir: $HOME" # Homedir echo "Server: $SERVER" # e.g. cetus echo "Domain: $DOMAIN" echo "IP: $IP" echo "Virtualdir: $VIRTUAL" echo "MySQL-Passwort: $MYSQLPASS" echo "" read -p "All correct? If not, cancel now." END # Setup domain uberspace-add-domain -d $DOMAIN -w uberspace-add-domain -d "*.$DOMAIN" -w uberspace-add-domain -d $DOMAIN -m # Setup basic directories mkdir ~/backup # Setup softlinks ln -s $VIRTUAL ~/virtual # Webmail mkdir $VIRTUAL/webmail.$DOMAIN echo "RedirectPermanent / https://webmail.$HOSTNAME" > $VIRTUAL/webmail.$DOMAIN/.htaccess # Create datasheet 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