#!/bin/bash function check_install { if [ -z "`which "$1" 2>/dev/null`" ] then # if [ "$1" = "postfix" ]; then # DEBIAN_FRONTEND=noninteractive apt-get -t squeeze-backports --no-install-recommends -q -y install "$2" # else DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install $2 # fi print_info "$2 installed for $1" else print_warn "$2 already installed" fi } function check_remove { if [ -n "`which "$1" 2>/dev/null`" ] then DEBIAN_FRONTEND=noninteractive apt-get -q -y remove --purge "$2" print_info "$2 removed" else print_warn "$2 is not installed" fi } function check_sanity { # Do some sanity checking. if [ $(/usr/bin/id -u) != "0" ] then die 'Must be run by root user' fi if [ -f /etc/lsb-release ] then die "Distribution is not supported" fi if [ ! -f /etc/debian_version ] then die "Ubuntu is not supported" fi } function die { echo "ERROR: $1" > /dev/null 1>&2 exit 1 } function get_domain_name() { # Getting rid of the lowest part. domain=${1%.*} lowest=`expr "$domain" : '.*\.\([a-z][a-z]*\)'` case "$lowest" in com|net|org|gov|edu|co) domain=${domain%.*} ;; esac lowest=`expr "$domain" : '.*\.\([a-z][a-z]*\)'` [ -z "$lowest" ] && echo "$domain" || echo "$lowest" } function get_password() { # Check whether our local salt is present. SALT=/var/lib/radom_salt if [ ! -f "$SALT" ] then head -c 512 /dev/urandom > "$SALT" chmod 400 "$SALT" fi password=`(cat "$SALT"; echo $1) | md5sum | base64` echo ${password:0:13} } function dotdeb { if [ ! -f /etc/apt/sources.list.d/dotdeb.list ];then cat > /etc/apt/sources.list.d/dotdeb.list < /etc/xinetd.d/dropbear < /etc/aliases < /etc/mysql/conf.d/lowendbox.cnf < ~/.my.cnf < /etc/nginx/conf.d/lowendbox.conf < /etc/nginx/sites-available/default <> /etc/nginx/sites-available/default <> /etc/nginx/sites-available/default <> /etc/nginx/sites-available/default <> /etc/nginx/sites-available/default < /etc/nginx/standard.conf <