This is my first sizable bash script (if sizable it is). Looking for advice, critiques and...
It allows a user to copy an existing multisite installation and convert it to a new one with the content truncated out of it. I'm going to start using it for my stuff in the morning... any comments more than welcome!
Do not trust this draft on your production server
#! /bin/bash
SCRIPTUSER="root"
MyUSER="id"
MyPASS="pass"
GroomPrefix="tempprefix_"
MyHOST="localhost"
SitesHome="/var/www/drupal/sites"
Prefix=""
MultisitePrefix="mysite.com"
date=`date +%Y%m%d`
log_filename=/home/user/addsite.log
ThemePrefix="theme_"
if [ $(whoami) != $SCRIPTUSER ]; then
echo "Must be "$SCRIPTUSER "to run $0"
exit 1;
fi
#Choose a database to copy from
echo -n "Pick a site to copy from: "
read -e MasterDatabase
#Set the database Prefix
MasterDatabasePrefix="${MasterDatabase}_"
#Choose the website name you wish to create
echo -n "Pick a site to create mynewsite not mysite.com/mynewsite: "
read -e NewSite
#Check to see if database exists
DBS=`mysql -u$MyUSER -p$MyPASS -Bse 'show databases'| egrep -v 'information_schema|mysql'`
for db in $DBS; do
if [ "$db" = "$NewSite" ]
then
echo "This database already exists : exiting now"
exit
fi
done
#Dump the info from the MasterDatabase into an sql file