From 04f8aabb07701d534d6cf28237e4bd8704c3ee7f Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 21 Apr 2011 17:25:17 +0200 Subject: update installer .. --- install.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'install.sh') 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 - ServerName $domain - ServerAdmin admin@$domain - DocumentRoot /var/www/pbs2/public - + ServerName $vhost_name + ServerAdmin admin@$vhost_name + DocumentRoot $targetDir/public + Options FollowSymLinks AllowOverride All @@ -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!!!" -- cgit v1.2.3-55-g7522