-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·92 lines (76 loc) · 2.65 KB
/
install.sh
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
#!/bin/bash
#
# Grab the files using this git-clone command:
# git clone https://github.com/mousems/NTUVoteV2_install
if [[ $(id -u) != 0 ]]; then
echo 'ERROR: This script should run as root.' >&2
return 1 2>/dev/null || exit 1
fi
# help user: cd to the containing directory of this shell script
cd "$(dirname "${BASH_SOURCE[0]}")"
# help user: make sure all these files exist in the current directory
if ! [[ -f 000-default.conf &&
-f apache2.conf &&
-f config.php &&
-f default-ssl.conf &&
-f ntuvote.sql &&
-f Result.sh ]]; then
echo 'ERROR: Some required file does not exist.' >&2
return 1 2>/dev/null || exit 1
fi
# important message goes first
echo
echo
echo ' Please make sure network and OpenSSH server both work already.'
echo ' If you are not ready, press Control-C to stop right now!'
echo
echo
echo 'The installation process will start in 3 seconds...'
echo
sleep 3
# install tasksel and git
apt-get update
apt-get install -y tasksel git
# install LAMP if not done before (need to provide mysql root password twice)
tasksel install lamp-server
# config apache (need to provide csr data for openssl manually)
a2enmod rewrite
a2enmod ssl
mkdir /etc/apache2/ssl
openssl req -x509 -nodes -days 365000 -newkey rsa:2048 \
-keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
cp ./apache2.conf /etc/apache2/
cp ./default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf
cp ./000-default.conf /etc/apache2/sites-enabled/000-default.conf
chown root:root /etc/apache2/sites-enabled/default-ssl.conf
chmod 644 /etc/apache2/sites-enabled/default-ssl.conf
sudo apt-get install -y php5-json
service apache2 restart
# ticket storage
mkdir /var/log/NTUticket
git init /var/log/NTUticket
chmod -R 777 /var/log/NTUticket
# put application files
rm -rf /var/www/
mkdir /var/www/
git clone https://github.com/mousems/ntuvotev2.git
# checkout tag 2.1
cd ntuvotev2
git checkout 2.1
cd ..
cp -r ./ntuvotev2/* ntuvotev2/.htaccess /var/www/
cp ./config.php /var/www/application/config/
cp ./Result.sh /var/log/NTUticket/
# finally, just a message about next actions
cat <<'END'
install complete
1.Please connect to MySQL create database and import SQL file. 'ntuvote.sql'
#> mysql -u root -p
mysql> create database ntuvote
#> mysql ntuvote -u root -p < ntuvote.sql
2.Edit /var/www/application/config/database_sample.php for MySQL settings.
3.rename database_sample.php to database.php
4.Edit /var/www/application/config/config.php for 'URL'.
5.visit website, administrator account: mousems/ntuvote
END