-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_test.sh
executable file
·132 lines (104 loc) · 3.22 KB
/
run_test.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
set -u
set -e
shopt -s dotglob
[[ "${DEBUG:-}" == 'true' ]] && set -x
detect_os ()
{
os=""
dist=""
if [[ -e /etc/lsb-release ]]; then
. /etc/lsb-release
if [[ "${ID:-}" = "raspbian" ]]; then
os=${ID}
dist=$(cut --delimiter='.' -f1 /etc/debian_version)
else
os=${DISTRIB_ID}
dist=${DISTRIB_CODENAME}
if [ -z "$dist" ]; then
dist=${DISTRIB_RELEASE}
fi
fi
elif [[ -e /etc/os-release ]]; then
. /etc/os-release
os="${ID:-}"
if [[ -n "${VERSION_CODENAME:-}" ]]; then
dist=${VERSION_CODENAME:-}
elif [[ -n "${VERSION_ID:-}" ]]; then
dist=${VERSION_ID:-}
fi
elif [[ -n "$(command -v lsb_release > /dev/null 2>&1)" ]]; then
dist=$(lsb_release -c | cut -f2)
os=$(lsb_release -i | cut -f2 | awk '{ print tolower($1) }')
fi
if [[ -z "$dist" ]] && [[ -e /etc/debian_version ]]; then
os=$(cat /etc/issue | head -1 | awk '{ print tolower($1) }')
if grep -q '/' /etc/debian_version; then
dist=$(cut --delimiter='/' -f1 /etc/debian_version)
else
dist=$(cut --delimiter='.' -f1 /etc/debian_version)
fi
fi
if [[ -z "$dist" ]]; then
unknown_os
fi
if [[ "${os}" = "debian" ]]; then
case $dist in
6* ) dist="squeeze" ;;
7* ) dist="wheezy" ;;
8* ) dist="jessie" ;;
9* ) dist="stretch" ;;
10* ) dist="buster" ;;
11* ) dist="bullseye" ;;
12* ) dist="bookworm" ;;
esac
fi
# remove whitespace from OS and dist name
os="${os// /}"
dist="${dist// /}"
# lowercase
os=${os,,}
dist=${dist,,}
echo "Detected operating system as $os/$dist."
}
unknown_os ()
{
echo "Unfortunately, your operating system distribution and version are not supported by this script."
exit 1
}
echo
echo "Start building"
echo "Web-server: ${WEB_SERVER}"
echo "Database: ${DATABASE}"
echo
detect_os
echo "127.0.0.1 test.gameap" > /etc/hosts
if [[ ${os} == "debian" ]] || [[ ${os} == "ubuntu" ]]; then
./install.sh --path=/var/www/gameap --host=test.gameap --web-server=${WEB_SERVER} --database=${DATABASE}
elif [[ ${os} == "centos" ]]; then
./install.sh --path=/var/www/gameap --host=test.gameap --web-server=${WEB_SERVER} --database=${DATABASE}
else
echo "Unknown OS" >> /dev/stderr
exit 1
fi
echo
echo "Checking available gameap host"
echo
curl -sL -w "HTTP CODE: %{http_code}\\n" "http://test.gameap/login" -o /dev/null
echo
echo "Checking GameAP Daemon installation"
daemon_install_command="./install-gdaemon.sh"
echo "Illuminate\Support\Facades\Cache::put('gdaemonAutoCreateToken', 'test_auto_setup_token', 99999);" | /var/www/gameap/artisan tinker || true
export CREATE_TOKEN=test_auto_setup_token
export PANEL_HOST=http://test.gameap;
if ! ${daemon_install_command}; then
echo "Unable to install gameap-daemon"
if [[ -f /tmp/gameap-response-create-ds.log ]]; then
echo
echo "Showing gameap create ds respoonse log:"
echo
cat /tmp/gameap-response-create-ds.log
echo
fi
exit 1
fi