-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·92 lines (74 loc) · 2.24 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
#!/usr/bin/env bash
eexit() {
echo -e "\e[91;1m!!! ${1}"
echo -e ""
echo -e "***********************"
echo -e "*** INSTALL FAILED ****"
echo -e "***********************\e[0m"
exit
}
eecho() {
echo -e "\e[34;1m${1}\e[0m"
}
eprintf() {
printf "\e[93;1m${1}\e[0m"
}
eecho "***********************"
eecho "*** GLUED INSTALLER ***"
eecho "***********************"
eecho ""
eprintf "*** Install glued? (y/n): "
if [ -t 1 ] ; then
read resp
eecho "--- Terminal installation"
else
read -u 3 resp
eecho "--- Streamed installation"
streamed="-u 3"
fi
if [ "$resp" != "y" ] ; then
eexit "exitting"
fi
if [ -d "glued" ] ; then
eecho "--- Skipping git pull, glued dir exists"
else
eecho "--- Pulling from github"
git clone https://github.com/vaizard/glued.git
fi
pushd glued > /dev/null
eecho "--- Ensuring private and public keys are present"
if [ ! -f ./private/oauth/private.key ]; then
openssl genrsa -out ./private/oauth/private.key 2048
fi
if [ ! -f ./private/oauth/public.key ]; then
openssl rsa -in ./private/oauth/private.key -pubout -out ./private/oauth/public.key
fi
eecho "--- Ensuring propper ownership and access rights of files and directories"
chmod 777 ./logs/
chmod 777 -R ./private/
chmod 600 ./private/oauth/private.key
eecho "--- Ensuring fresh dependencies"
rm -rf ./vendor/*
composer install
eecho "--- Testing if glued/settings.php is set up"
if [ ! -f ./glued/settings.php ]; then
eexit "! settings.php not present. Copy settings.php.example to settings.php and set it up."
else
pushd glued > /dev/null
eecho "\$config = require '_preflight.php';" | php -a
[[ $(echo "\$config = require '_preflight.php';" | php -a | grep 'ERROR') ]] && eexit "settings.php present, but misconfigured"
popd > /dev/null
fi
eecho "--- Testing if phinx.yml production environment is set up"
if [ ! -f ./phinx.yml ]; then
eexit "! phinx.yml not present. Copy phinx.yml.example to phinx.yml and set it up."
else
[[ $(php vendor/bin/phinx test -e production | grep 'success') ]] || eexit "phinx.yml present, but misconfigured"
fi
eecho "--- Setting up the database"
php vendor/bin/phinx migrate -e production
popd > /dev/null
eecho ""
eecho "***********************"
eecho "*** INSTALL DONE! *****"
eecho "***********************"