#!/bin/bash # # Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg # This program is free software distributed under the GPL version 2. # See http://gpl.openslx.org/ # # If you have any feedback please consult http://feedback.openslx.org/ and # send your suggestions, praise, or complaints to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org/ # Absolute path to this script. /home/user/bin/foo.sh echo "Copying to /var/www/" sourceDir=$(readlink -f $(dirname $(readlink -f $0))) echo -n "enter vhost name: " read vhost_name sed -e "39s/\$/$vhost_name/" -i $targetDir/application/configs/application.ini targetDir="/var/www/$vhost_name" mkdir -p $targetDir cp -R $sourceDir/* $targetDir echo "Creating poolctrl host..."# mkdir -p $targetDir/library ln -sf /usr/share/php/libzend-framework-php/Zend $targetDir/library/ cat > /etc/apache2/sites-available/$vhost_name << EOF ServerName $vhost_name ServerAdmin admin@$vhost_name DocumentRoot $targetDir/public Options FollowSymLinks AllowOverride All EOF echo "Enabling poolctrl host..." a2ensite $vhost_name echo "Restarting apache..." apachectl restart echo "Creating config of poolctrl..." cp $targetDir/application/configs/application.ini.dist $targetDir/application/configs/application.ini echo -n "Please enter db admin user [root]: " read db_admin [ "x" = "x$db_admin" ] && db_admin="root" echo -n "Please enter the password for db admin user $db_admin: " stty -echo read db_adminpass stty echo echo -n "Please enter username for poolctrl db: " read db_user sed -e "12s/\$/$db_user/" -i $targetDir/application/configs/application.ini #echo -n "Please enter password for poolctrl db user $databaseuser: " #read databasepassword db_pass=$(md5sum /var/log/syslog| awk '{print $1}') sed -e "13s/\$/$db_pass/" -i $targetDir/application/configs/application.ini echo -n "Enter database name: " read db_name sed -e "14s/\$/$db_name/" -i $targetDir/application/configs/application.ini echo -n "Please enter host of pbs2: " read pbs2_host sed -e "21s/\$/$pbs2_host/" -i $targetDir/application/configs/application.ini echo -n "Please enter host of gearman server [localhost]: " read gearman_server_host [ "x" = "x$gearman_server_host" ] && gearman_server_host="localhost" sed -e "42s/\$/$gearman_server_host/" -i $targetDir/application/configs/application.ini echo -n "Please enter port of gearman server [4730]: " read gearman_server_port [ "x" = "x$gearman_server_port" ] && gearman_server_port="4730" sed -e "43s/\$/$gearman_server_port/" -i $targetDir/application/configs/application.ini echo "Create database and tables" cat $targetDir/setup/poolctrl.sql | sed -e "s,##poolctrl##,$db_name," > /tmp/poolctrl.sql mysql -u $db_admin -p$db_adminpass < /tmp/poolctrl.sql rm /tmp/poolctrl.sql echo "Create db user" echo "GRANT ALL PRIVILEGES ON ${db_name}.* TO '${db_user}'@'localhost'" > /tmp/poolctrl-admin.sql echo " IDENTIFIED BY '${db_pass}' WITH GRANT OPTION;" >> /tmp/poolctrl-admin.sql echo "FLUSH PRIVILEGES;" >> /tmp/poolctrl-admin.sql mysql -u $db_admin -p$db_adminpass mysql < /tmp/poolctrl-admin.sql rm /tmp/poolctrl-admin.sql echo "Import demo data" cat $targetDir/setup/poolctrl_data.sql | sed -e "s,##poolctrl##,$db_name," > /tmp/poolctrl-data.sql mysql -u $db_user -p$db_pass < /tmp/poolctrl-data.sql rm /tmp/poolctrl-data.sql #mysql -u $databaseuser -p$databasepassword < $targetDir/setup/poolctrl.sql #mysql -u $databaseuser -p$databasepassword < $targetDir/setup/poolctrl_data.sql echo "woho - poolctrl is ready to use" echo "You can reach your installed poolctrl server under http://$vhost_name/"