Create a gist now

Instantly share code, notes, and snippets.

@golderweb /uberspace-init Secret
Last active Apr 19, 2016

What would you like to do?
Init-Script to init new Uberspaces and to Update bash-config
#!/bin/bash
# Init-Script to init new Uberspaces and to Update bash-config
#
#
# Copyright 2014-2015 GOLDERWEB – Jonathan Golder <jonathan@golderweb.de>
#
# 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/>
#
# Make sure we are in $HOME
cd $HOME;
# Download my personal default bash configuration files from github
bash-config-update() {
# Download modified bash-config from github
( test -f .bash_profile && mv .bash_profile .bash_profile.save || test -d . ) && wget -q https://gist.githubusercontent.com/golderweb/d910ae1edbe853377da5/raw/.bash_profile
( test -f .bashrc && mv .bashrc .bashrc.save || test -d . ) && wget -q https://gist.githubusercontent.com/golderweb/e912ccfafda58470e51a/raw/.bashrc
( test -f .bash_functions && mv .bash_functions .bash_functions.save || test -d . ) && wget -q https://gist.github.com/golderweb/3dbb4f897339cf5c74e7/raw/.bash_functions
( test -f .bash_aliases && mv .bash_aliases .bash_aliases.save || test -d . ) && wget -q https://gist.github.com/golderweb/79a4a2cc2cb126d30d4a/raw/.bash_aliases
echo "Test if everything works right, then run \"uberspace-init cleanup\""
}
case "$1" in
init|"")
# Set up some predefinitions on new uberspace
# Create Symlink for www
test -e ~/www || ln -s /var/www/virtual/$USER www
# Prepare ubespace for using daemontools
test -d ~/service || uberspace-setup-svscan
# Create several dirs
test -d ~/bin || mkdir bin
test -d ~/git || mkdir git
# Enable E-Mail redirection
read -p "Enter E-Mail-Adress for redirection, leave empty for use Maildir of this uberspace:" mail
if [ -n "$mail" ]; then
echo -e "#Redirect incomming E-Mails on ${USER} to ${mail}\n$mail" > .qmail || echo "ERROR: .qmail-file couldn't be wrote! E-Mails will be delivered to Maildir"
else
echo "No E-Mail-adress was provided, E-Mails will be delivered to Maildir"
fi
#Get bash-config files from github
bash-config-update
;;
bash-config-update)
#Get bash-config files from github
bash-config-update
;;
cleanup)
#Remove backup files
rm .bash_profile.save .bashrc.save .bash_functions.save .bash_aliases.save
;;
*) echo "Invalid parameter"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment