-
Notifications
You must be signed in to change notification settings - Fork 47
/
test.sh
executable file
·86 lines (63 loc) · 2.12 KB
/
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
#!/bin/bash
cd "$(dirname "$0")"
chmod a+x ./install.sh
#assume yes to all apt-get commands
echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf.d/90assumeyes
export DEBIAN_FRONTEND=noninteractive
./install.sh
if [[ $IN_DOCKER ]];then
#systemd doesn't work in docker, so start manually
export CATALINA_HOME=/usr/share/tomcat9
export CATALINA_BASE=/var/lib/tomcat9
export CATALINA_TMPDIR=/tmp
export JAVA_OPTS=-Djava.awt.headless=true
apt install sudo
sudo --user=tomcat --preserve-env --set-home /usr/libexec/tomcat9/tomcat-start.sh &
fi
sleep 15
http_code=$(curl --verbose -o /tmp/result.txt -w '%{http_code}' 'http://127.0.0.1:8080/lucee/admin/web.cfm';)
echo "Finished with Status: $http_code "
echo -e "\n-----\n"
#output the result
if [ -f "/tmp/result.txt" ]; then
cat /tmp/result.txt
else
echo "Result file did not exist"
http_code=0
fi
echo -e "\n-----\n"
#test nginx setup
cp /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf
service nginx restart
echo "<cfheader statuscode='418' statustext='teapot'><cfoutput>Lucee #server.lucee.version#</cfoutput>" > /web/example.com/wwwroot/test.cfm
#warmup hit
curl --verbose --resolve 'example.com:80:127.0.0.1' http://example.com/test.cfm
nginx_http_code=$(curl --verbose --resolve 'example.com:80:127.0.0.1' -o /tmp/result.txt -w '%{nginx_http_code}' 'http://example.com/test.cfm';)
echo "Finished Nginx with Status: $nginx_http_code "
echo -e "\n-----\n"
#output the result
if [ -f "/tmp/result.txt" ]; then
cat /tmp/result.txt
else
echo "Nginx Result file did not exist"
http_code=0
fi
echo -e "\n-----\n"
find /opt/lucee/
#output logs for debugging
cat /var/log/nginx/*.log
cat /var/log/tomcat9/*.log
if [[ $DEBUG_SLEEP ]];then
apt install vim
echo "DEBUG SLEEPING: docker exec -it ID /bin/bash to debug container"
echo "curl --verbose --resolve 'example.com:80:127.0.0.1' http://example.com/test.cfm"
sleep 50000
fi
if [ "$http_code" -ne 200 ]; then
#fail if status code is not 200
exit 1
fi
if [ "$nginx_http_code" -ne 418 ]; then
#fail if status code is not 418
exit 1
fi