forked from swizzin/swizzin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b5d2b1
commit 374ee9a
Showing
1 changed file
with
7 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# LazyLibrarian test script for swizzin | ||
# Author: Aethaeran | ||
|
||
########################################################################## | ||
# References | ||
########################################################################## | ||
|
||
# https://github.com/swizzin/swizzin/blob/master/scripts/tests/_basetest.sh | ||
|
||
########################################################################## | ||
# Import Sources | ||
########################################################################## | ||
# Author: Aethaeran 2021 | ||
# GPLv3 | ||
|
||
#shellcheck source=sources/functions/tests | ||
. /etc/swizzin/sources/functions/tests | ||
|
||
########################################################################## | ||
# Variables | ||
########################################################################## | ||
|
||
app_name="lazylibrarian" | ||
|
||
########################################################################## | ||
# Functions | ||
########################################################################## | ||
|
||
# TODO: Is this change necessary? Maybe I just did the nginx configuration incorrectly. | ||
|
||
check_port_curl() { | ||
check_port_curl_lazylib() { | ||
echo_progress_start "Checking if port $1 is reachable via curl" | ||
if [ "$1" -eq "$1" ] 2> /dev/null; then | ||
port=$1 | ||
else | ||
port=$(get_port "$1") || { | ||
echo_warn "Couldn't guess port" | ||
return 1 | ||
} | ||
fi | ||
extra_params="$2" | ||
# shellcheck disable=SC2086 # We want splitting on the extra params variable. So the warning is void here. | ||
curl -sSfLk $extra_params http://127.0.0.1:"$port/$app_name" -o /dev/null || { | ||
# override necessary for baseurl inclusion | ||
curl -sSfLk http://127.0.0.1:"$port/$app_name" -o /dev/null || { | ||
echo_warn "Querying http://127.0.0.1:$port/$app_name failed" | ||
echo | ||
return 1 | ||
} | ||
echo_progress_done | ||
} | ||
|
||
########################################################################## | ||
# Main | ||
########################################################################## | ||
|
||
# run all functions, if one fails, mark as bad | ||
check_service "$app_name" || BAD="true" | ||
check_port "$app_name" || BAD="true" | ||
check_port_curl "$app_name" || BAD="true" | ||
# shellcheck disable=SC2034 # $BAD is used in evaluate_bad. So the warning is void here. | ||
check_port 5299 || BAD="true" | ||
check_port_curl_lazylib 5299 || BAD="true" | ||
check_nginx "$app_name" || BAD="true" | ||
|
||
evaluate_bad |