summaryrefslogblamecommitdiffstats
path: root/install.sh
blob: f022c894e6036314fd86a01518a09f5fb179bf19 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                          
 










                                                                        
                  



                                  






                              
                    
                           
                 

                                 
























                                                                                                     
 





                                                                                            
 





                                                                                        

                                  
                                                                         
                                                                                                      
#!/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
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  $vhost_name
    ServerAdmin admin@$vhost_name
    DocumentRoot $targetDir/public
    <Directory $targetDir/public >
        Options FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>
EOF

echo "Enabling pbs2 host..."
a2ensite $vhost_name
echo "Restarting apache..."
apachectl restart

echo "Creating config of pbs2..."
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 "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 "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://$vhost_name/"
echo "Login with username: 'test' and pasword 'test' and change the Passwort and eMail IMMEDIATELY!!!"