forked from mangospot-net/MangoRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mangospot.sh
81 lines (68 loc) · 1.98 KB
/
mangospot.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
#!/bin/bash
echo ">>> Installing MangoSpot <<<"
[[ -z $1 ]] && { echo "Database does not match! (sudo ./mangospot mysql or pgsql)"; exit 1; }
if [ -z $2 ]
then
echo ''
read -sp "Confirm database password : " pswd
else
pswd=$2
fi
if [ -z $3 ]
then
echo ''
read -p "Select Database : " dbmango
else
dbmango=$3
fi
[[ -z $pswd ]] && { echo "Password is required!"; exit 1; }
[[ -z $dbmango ]] && { echo "Database is required!"; exit 1; }
# Download MangoSpot
if [ -d "/var/www/MangoSpot/" ]
then
echo "Directory MangoSpot exists."
else
cd /var/www
sudo git clone https://github.com/mangospot-net/MangoSpot.git
cd
fi
# Create virtualhost
sudo cat > /etc/apache2/conf-available/mangospot.conf << ENDOFFILE
Alias /mangospot /var/www/MangoSpot
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/MangoSpot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ENDOFFILE
# Edit connection to database
if [ $1 == 'mysql' ]
then
sed -i 's/"TYPE", ".*"/"TYPE", "mysql"/' /var/www/MangoSpot/include/config.php
sed -i 's/"DB_USER", ".*"/"DB_USER", "root"/' /var/www/MangoSpot/include/config.php
elif [ $1 == 'pgsql' ]
then
sed -i 's/"TYPE", ".*"/"TYPE", "pgsql"/' /var/www/MangoSpot/include/config.php
sed -i 's/"DB_USER", ".*"/"DB_USER", "postgres"/' /var/www/MangoSpot/include/config.php
else
echo "Database does not match!"
exit 1
fi
sed -i 's/"DB_PASSWORD", ".*"/"DB_PASSWORD", "'$pswd'"/' /var/www/MangoSpot/include/config.php
sed -i 's/"DB_DATABASE", ".*"/"DB_DATABASE", "'$dbmango'"/' /var/www/MangoSpot/include/config.php
chmod -R 777 /var/www/MangoSpot/dist/img
chmod -R 777 /var/www/MangoSpot/dist/img/bg
chmod -R 777 /var/www/MangoSpot/dist/img/users
# Enable htaccess
sudo a2enmod rewrite
# Enable mangospot.conf
sudo a2enconf mangospot.conf
# Restart apache
sudo /etc/init.d/apache2 restart
echo ">>> Finished Installing MangoSpot"
sleep 2