install.sh 3.64 KB
Newer Older
1
2
#!/bin/bash

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#check if db_partition is available
db_disk="/dev/vdb"
if [ -e $db_disk  ]
then
    echo "Disk for database found: $db_disk"
    mounted=`mount |grep "$db_disk" |wc -l`
    if [ "$mounted" = "0" ]
    then
        echo "Disk not mounted. Aborting"
        exit 1
    else
        echo "Partition mounted."
        mount |grep "$db_disk"
    fi
else 
    echo "Partition for database not found: $db_disk"
fi

Piotr Gawron's avatar
Piotr Gawron committed
21
#install toole required for minerva installation
22
apt-get update && apt-get install dirmngr apt-transport-https
Piotr Gawron's avatar
Piotr Gawron committed
23
24

#install minerva
25
26
echo "deb http://repo-r3lab.uni.lu/debian/ stable main" | tee /etc/apt/sources.list.d/repo-r3lab.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xcb185f4e31872412
27
28
29
30
31
32
33
34
35
36
37

echo debconf minerva/internal/skip-preseed boolean false | debconf-set-selections
echo debconf minerva/dbconfig-install boolean true | debconf-set-selections
echo debconf minerva/pgsql/app-pass select 123qweasdzxc | debconf-set-selections
echo debconf minerva/remote/host select localhost | debconf-set-selections
echo debconf minerva/db/dbname select map_viewer | debconf-set-selections
echo debconf minerva/db/app-user select map_viewer@localhost | debconf-set-selections
echo debconf minerva/database-type select pgsql | debconf-set-selections
echo debconf minerva/pgsql/manualconf boolean false | debconf-set-selections


38
apt-get update
39
apt-get install -y  mc apache2 php libapache2-mod-php7.2 minerva
40
41
42

#change tomcat memory limit to 4GB
sed -i 's/-Xmx128m/-Xmx4192m/g' /etc/default/tomcat7
43
sed -i 's/-Djava.awt.headless=true/-Djava.awt.headless=true -Xmx4192m/g' /etc/default/tomcat8
44
service tomcat7 restart
45

46
#setup proxy in apache to go to tomcat
Piotr Gawron's avatar
Piotr Gawron committed
47
sed -i '2i\    ProxyPass /minerva http://localhost:8080/minerva\n    ProxyPass /map_images http://localhost:8080/map_images\n    ProxyPass /minerva-big http://localhost:8080/minerva-big\n    ProxyPassReverse /minerva http://localhost:8080/minerva\n    ProxyPassReverse /minerva-big http://localhost:8080/minerva-big\n    ProxyPassReverse /map_images http://localhost:8080/map_images\n' /etc/apache2/sites-enabled/000-default.conf
48
49
50
51
52

a2enmod proxy
a2enmod proxy_http
service apache2 restart

Piotr Gawron's avatar
Piotr Gawron committed
53
54
55
56
#add redirection
printf "<?php\nheader('Location: minerva/');\n?>\n" > /var/www/html/index.php
rm /var/www/html/index.html

57
58
#create SSL certificat
sudo mkdir /etc/apache2/ssl
59
60
sudo openssl genrsa -des3 -passout pass:xxxxyyyy -out /etc/apache2/ssl/server.pass.key 2048
sudo openssl rsa -passin pass:xxxxyyyy -in /etc/apache2/ssl/server.pass.key -out /etc/apache2/ssl/server.key
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
sudo rm /etc/apache2/ssl/server.pass.key
sudo openssl req -new -key /etc/apache2/ssl/server.key -out /etc/apache2/ssl/server.csr   -subj "/C=LU/ST=Luxembourg/L=Esch-sur-Alzette/O=UL/OU=LCSB/CN=example.com"
sudo openssl x509 -req -days 365 -in /etc/apache2/ssl/server.csr -signkey /etc/apache2/ssl/server.key -out /etc/apache2/ssl/server.crt

#set the SSL certificate in apache2
sudo sed -i.bak -- 's/\/etc\/ssl\/certs\/ssl-cert-snakeoil\.pem/\/etc\/apache2\/ssl\/server.crt/g' /etc/apache2/sites-available/default-ssl.conf
sudo sed -i.bak -- 's/\/etc\/ssl\/private\/ssl-cert-snakeoil\.key/\/etc\/apache2\/ssl\/server.key/g' /etc/apache2/sites-available/default-ssl.conf
sudo a2ensite default-ssl
sudo a2enmod ssl

sudo sed -i.bak '/ProxyPass/d' /etc/apache2/sites-enabled/default-ssl.conf
sudo sed -i '3i\    ProxyPass / http://localhost/\n    ProxyPassReverse / http://localhost/\n' /etc/apache2/sites-enabled/default-ssl.conf

sudo service apache2 restart

#turn on backups
Piotr Gawron's avatar
Piotr Gawron committed
77
ln minerva-scripts/server/backup.sh /etc/cron.daily/minerva
78
79
80
81

#create .pgpass for later db management
echo "localhost:5432:map_viewer:map_viewer:123qweasdzxc" > .pgpass
chmod 0600 .pgpass