-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.sh
More file actions
executable file
·76 lines (61 loc) · 2.45 KB
/
test_server.sh
File metadata and controls
executable file
·76 lines (61 loc) · 2.45 KB
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
#!/bin/bash
#
# Time-stamp: <Friday 2023-09-28 10:42:12 +1000 Jess Moore>
#
# A supplied first argument will override the HOST_NAME from
# linode.json.
#
# Adapted from similar script by Graham Williams.
cd $HOME/Documents/scripts
. ./common.sh
if [ -n "$1" ]; then
HOST_NAME=$1
fi
########################################################################
# CADDY Server Test
########################################################################
# testURL https://${HOST_NAME} 'Server Deployed|<html>'
########################################################################
if [ "${LIN_ACCT}" = "jmanutce" ]; then
########################################################################
DASH="_dash-loading"
WEB="<html>"
DEPLOYED="Server Deployed"
QUERY="https://${HOST_NAME}"
CMD=$(curl --silent ${QUERY})
# BZTE SERVER RETURNS A HTML PAGE OF THE DASH VISUALISATION
# CHECK EGREP ON RETURNED PAGE RETURNS THE MATCHED HTML TAG
RESPONSE=$(echo ${CMD} | egrep ${DASH})
NUM=$(echo ${RESPONSE} | wc -l)
EXP=1
if [ ${NUM} -eq ${EXP} ]; then
printf "${QUERY} returned dashboard.\n"
/usr/bin/osascript -e 'tell app "System Events" to display dialog "caddy returned dashboard"'
else
printf "FAIL: ${API}/${QUERY} did NOT return the expected number of lines.\n"
printf "===================================\n"
printf "EXPECTED TO BE ${EXP} LINES BUT GOT ${NUM}.\n"
printf ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
printf "OBTAINED\n"
printf "${RESPONSE}"
/usr/bin/osascript -e 'tell app "System Events" to display dialog "curl didnt return dashboard\ncaddy failed\n DO systemctl stop caddy\n THEN enable, start, reload, status"'
printf "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"
fi
RESPONSE=$(echo ${CMD} | egrep ${WEB})
NUM=$(echo ${RESPONSE} | wc -l)
EXP=1
if [ ${NUM} -eq ${EXP} ]; then
printf "${QUERY} returned website.\n"
/usr/bin/osascript -e 'tell app "System Events" to display dialog "caddy returned website"'
else
printf "FAIL: ${API}/${QUERY} did NOT return the expected number of lines.\n"
printf "===================================\n"
printf "EXPECTED TO BE ${EXP} LINES BUT GOT ${NUM}.\n"
printf ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
printf "OBTAINED\n"
printf "${RESPONSE}"
/usr/bin/osascript -e 'tell app "System Events" to display dialog "curl didnt return website\ncaddy failed\n DO systemctl stop caddy\n THEN enable, start, reload, status"'
printf "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"
fi
fi
exit