summaryrefslogtreecommitdiffstats
path: root/install.sh
blob: dd5e48269c755d2241ab359379955c67d3bc5e51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/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
<VirtualHost *:80>
    ServerName  $vhost_name
    ServerAdmin admin@$vhost_name
    DocumentRoot $targetDir/public
    <Directory $targetDir/public >
        Options FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>
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/"