summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinstall.sh78
-rw-r--r--setup/pbs-newdata.sql2
-rw-r--r--setup/pbs.sql4
3 files changed, 58 insertions, 26 deletions
diff --git a/install.sh b/install.sh
index b8cbdc2..f022c89 100755
--- a/install.sh
+++ b/install.sh
@@ -11,18 +11,23 @@
# Absolute path to this script. /home/user/bin/foo.sh
echo "Copying to /var/www/"
-sourceDir = dirname $0
-targetDir = "/var/www/pbs2/"
-cp -R $sourceDir $targetDir
-echo "Creating pbs2 host..."
-ln -s /usr/share/php/libzend-framework-php/Zend/ /var/www/pbs2/library/Zend
-cat > /etc/apache2/sites-available/pbs2 << EOF
+sourceDir=$(readlink -f $(dirname $(readlink -f $0)))
+echo -n "enter vhost name: "
+read vhost_name
+targetDir="/var/www/$vhost_name"
+mkdir -p $targetDir
+cp -R $sourceDir/* $targetDir
+
+echo "Creating pbs2 host..."#
+mkdir -p $targetDir/library/Zend
+ln -s /usr/share/php/libzend-framework-php/Zend/ $targetDir/library/Zend
+cat > /etc/apache2/sites-available/$vhost_name << EOF
<VirtualHost *:80>
- ServerName $domain
- ServerAdmin admin@$domain
- DocumentRoot /var/www/pbs2/public
- <Directory /var/www/pbs2/public >
+ ServerName $vhost_name
+ ServerAdmin admin@$vhost_name
+ DocumentRoot $targetDir/public
+ <Directory $targetDir/public >
Options FollowSymLinks
AllowOverride All
</Directory>
@@ -30,24 +35,51 @@ cat > /etc/apache2/sites-available/pbs2 << EOF
EOF
echo "Enabling pbs2 host..."
-a2ensite pbs2
+a2ensite $vhost_name
echo "Restarting apache..."
-etc/init.d/apache2 restart
+apachectl restart
echo "Creating config of pbs2..."
-cp /var/www/pbs2/application/configs/application.ini.dist /var/www/pbs2/application/configs/application.ini
-echo "Please enter the database user"
-read databaseuser
-sed -e 13s/$/$databaseuser/ -i /var/www/pbs2/application/configs/application.ini
+cp $targetDir/application/configs/application.ini.dist $targetDir/application/configs/application.ini
+
+echo -n "Please enter db admin user [root]: "
+read db_admin
+[ -n $db_admin ] || db_admin=root
+
+echo -n "Please enter the password for db admin user $db_admin: "
+read db_adminpass
+
+echo -n "Please enter username for pbs db: "
+read db_user
+sed -e 13s/$/$db_user/ -i $targetDir/application/configs/application.ini
+
+#echo -n "Please enter password for pbs db user $databaseuser: "
+#read databasepassword
+db_pass=$(md5sum /var/log/syslog| awk '{print $1}')
+sed -e "14s/\$/$db_pass/" -i $targetDir/application/configs/application.ini
+
+echo -n "Enter database name: "
+read db_name
+
+echo "Create database and tables"
+cat $targetDir/setup/pbs.sql | sed -e "s,##pbs##,$db_name," > /tmp/pbs.sql
+mysql -u $db_admin -p$db_adminpass < /tmp/pbs.sql
+rm /tmp/pbs.sql
-echo "Please enter the database password for user $databaseuser"
-read databasepassword
-sed -e 14s/$/$databasepassword/ -i /var/www/pbs2/application/configs/application.ini
+echo "Create db user"
+echo "GRANT ALL PRIVILEGES ON ${db_name}.* TO '${db_user}'@'localhost'" > /tmp/pbs-admin.sql
+echo " IDENTIFIED BY '${db_pass}' WITH GRANT OPTION;" >> /tmp/pbs-admin.sql
+echo "FLUSH PRIVILEGES;" >> /tmp/pbs-admin.sql
+mysql -u $db_admin -p$db_adminpass mysql < /tmp/pbs-admin.sql
+rm /tmp/pbs-admin.sql
-echo "Creating database and tables"
-mysql -u $databaseuser -p$databasepassword < /var/www/pbs2/setup/pbs.sql
-mysql -u $databaseuser -p$databasepassword < /var/www/pbs2/setup/pbs.sql
+echo "Import demo data"
+cat $targetDir/setup/pbs-newdata.sql | sed -e "s,##pbs##,$db_name," > /tmp/pbs-data.sql
+mysql -u $db_user -p$db_pass < /tmp/pbs-data.sql
+rm /tmp/pbs-data.sql
+#mysql -u $databaseuser -p$databasepassword < $targetDir/setup/pbs.sql
+#mysql -u $databaseuser -p$databasepassword < $targetDir/setup/pbs-newdata.sql
echo "woho - pbs2 is ready to use"
-echo "You can reach your installed pbs2 server under http://$domain/"
+echo "You can reach your installed pbs2 server under http://$vhost_name/"
echo "Login with username: 'test' and pasword 'test' and change the Passwort and eMail IMMEDIATELY!!!"
diff --git a/setup/pbs-newdata.sql b/setup/pbs-newdata.sql
index 00c9f96..43d2c41 100644
--- a/setup/pbs-newdata.sql
+++ b/setup/pbs-newdata.sql
@@ -1,4 +1,4 @@
-USE pbs;
+USE ##pbs##;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- Adding person test2//test
diff --git a/setup/pbs.sql b/setup/pbs.sql
index ad1a41f..d579ccf 100644
--- a/setup/pbs.sql
+++ b/setup/pbs.sql
@@ -1,5 +1,5 @@
-CREATE DATABASE `pbs` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-USE pbs;
+CREATE DATABASE `##pbs##` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+USE ##pbs##;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `pbs_group` (