-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallMicroweber.sh
executable file
·105 lines (95 loc) · 2.64 KB
/
installMicroweber.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
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
while getopts e:a:p:d:H:D:U:P:t:T:R:f: flag
do
case "${flag}" in
e) adminEmail=${OPTARG};;
a) adminUsername=${OPTARG};;
p) adminPassword=${OPTARG};;
d) dbEngine=${OPTARG};;
H) dbHost=${OPTARG};;
D) dbUsername=${OPTARG};;
U) dbPassword=${OPTARG};;
P) dbName=${OPTARG};;
t) dbTablePrefix=${OPTARG};;
T) template=${OPTARG};;
f) fresh=${OPTARG};;
esac
done
#if fresh is not set perform existing installation
if [ -v $fresh ];then
export fresh="N"
fi
#if env file not exist perform a fresh installation
if [ ${fresh^h} == "N" ];then
if [ ! -f "/microweber/.env" ] ;then
export fresh="Y"
fi
fi
#extract
if [ ${fresh^h} == "Y" ];then
#clear instalaltion directory
rm -rfR /microweber/*
#overwrite
unzip -q -o -d /microweber -x /microweber.zip
else
#never overwrite
#unzip -q -n -d /microweber -x /microweber.zip
echo "Using existing installation"
fi
#ownership
chown -R nginx:nginx /microweber
chmod -R 0775 /microweber/storage/ /microweber/userfiles/
#permissions
chown -R nginx:nginx /microweber/userfiles/
chmod -R 0775 /microweber/userfiles/
chown -R nginx:nginx /microweber/config
#install if fresh
if [ ${fresh^h} == "Y" ];then
#change directory
cd /microweber;
cmd="php artisan microweber:install"
case $dbEngine in
"mysql")
#wait for mysql
export WAIT_HOSTS=$dbHost:3306
/wait
cmd="$cmd $adminEmail $adminUsername $adminPassword $dbHost $dbName $dbUsername $dbPassword mysql"
;;
"pgsql")
export WAIT_HOSTS=$dbHost:5432
/wait
cmd="$cmd $adminEmail $adminUsername $adminPassword $dbHost $dbName $dbUsername $dbPassword pgsql"
;;
"sqlite")
dbHost="/microweber/storage/database.sqlite"
cmd="$cmd $adminEmail $adminUsername $adminPassword $dbHost"
;;
esac
#table prefix
if [ -n "$dbTablePrefix" ];
then
cmd="$cmd -p $dbTablePrefix"
fi
#template
if [ -n "$template" ];
then
cmd="$cmd -t $template"
fi
#execute
$cmd;
echo $cmd
#ownerships if SQLite
if [ $dbEngine == "sqlite" ];then
chmod -R 0775 $dbHost
chown -R nginx:nginx $dbHost
fi
#ownership
chown -R nginx:nginx /microweber
chmod -R 0775 /microweber/storage/ /microweber/userfiles/
#permissions
chown -R nginx:nginx /microweber/userfiles/
chmod -R 0775 /microweber/userfiles/
chown -R nginx:nginx /microweber/config
fi
#init
/usr/bin/supervisord -c /etc/supervisord.conf -n