blob: ee4417a96800fbd2b053bc3db7bb631038e9a32d [file] [log] [blame]
Mustafa Ozcelikors419a2ea2017-06-27 18:46:47 +02001#!/bin/bash
2
3#Script Description:
4# A4MCAR Project - Script that sets up web_interface module
5# Installs Apache2, PHP5, allows user privilages and installs required libraries
6#
7#Author:
8# M. Ozcelikors <mozcelikors@gmail.com>, Fachhochschule Dortmund
9#
10#Disclaimer:
11# Copyright (c) 2017 Eclipse Foundation and FH Dortmund.
12# All rights reserved. This program and the accompanying materials are made available under the
13# terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
14# http://www.eclipse.org/legal/epl-v10.html
15#
16
17echo "### Setting up web_interface..."
18CURRENT_USER=$(whoami)
19
20#Getting the script directory
21SOURCE="${BASH_SOURCE[0]}"
22while [ -h "$SOURCE" ]; do
23 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
24 SOURCE="$(readlink "$SOURCE")"
25 [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
26done
27DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
28
29echo "### Updating repository list..."
30sudo apt-get update
31
32echo "### Installing apache2 and php5..."
33sudo apt-get install apache2 -y
34sudo apt-get install php5 libapache2-mod-php5 -y
35
36echo "### Adjusting web server permissions..."
37sudo chgrp -R www-data /var/www/html
38sudo find /var/www/html -type -d -exec chmod g+rx {} +
39sudo find /var/www/html -type f -exec chmod g+r {} +
40sudo chown $CURRENT_USER /var/www/html/
41sudo find /var/www/html/ -type d -exec chmod u+rwx {} +
42sudo find /var/www/html/ -type f -exec chmod u+rw {} +
43
44echo "### Copying the folder contents into /var/www/html/..."
45sudo cp -r $DIR/* /var/www/html
46
47echo "### Allowing script permissions to www-data..."
48sudo -i
49sudo echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
50exit
51# Or sudo echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers, But script has to be run as root..
52
53echo "### Cloning external frameworks and libraries..."
54cd ~/Downloads
55sudo git clone https://gitlab.pimes.fh-dortmund.de/RPublic/a4mcar_required_modules.git
56
57echo "### Copying downloaded libraries into /var/www/html..."
58sudo mkdir /var/www/html/jqplot_dist
59sudo cp -r ~/Downloads/a4mcar_required_modules/web_interface/jqplot_dist/* /var/www/html/jqplot_dist
60sudo mkdir /var/www/html/jquery_ui
61sudo cp -r ~/Downloads/a4mcar_required_modules/web_interface/jquery_ui/* /var/www/html/jquery_ui
62sudo cp ~/Downloads/a4mcar_required_modules/web_interface/jq.js /var/www/html/
63
64echo "### Clearing downloaded files..."
65sudo rm -rf ~/Downloads/a4mcar_required_modules/
66
67echo "### Finished."