mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-07-28 13:07:02 +08:00
49 lines
No EOL
1.1 KiB
Bash
Executable file
49 lines
No EOL
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Logs response of email health check
|
|
#
|
|
# `captaincore email-health response <site> <token> <status>`
|
|
#
|
|
|
|
if [ ${#@} -ne 3 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a <site> <token> <status>."
|
|
fi
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(captaincore config fetch --captain-id=$CAPTAIN_ID)"
|
|
|
|
site=$1
|
|
token=$2
|
|
email_status=$3
|
|
|
|
run_command() {
|
|
|
|
# Extract environment
|
|
if [[ "$site" == *"-staging"* ]]; then
|
|
environment=staging
|
|
else
|
|
environment=production
|
|
fi
|
|
|
|
# Load site configs
|
|
IFS=$'\n'$'\r'; for line in $(captaincore site get $site --bash --captain-id=$CAPTAIN_ID); do declare "$line"; done; unset IFS
|
|
|
|
if [[ "$email_status" == "" ]] || [[ "$site_id" == "" ]] || [[ "$environment" == "" ]]; then
|
|
return
|
|
fi
|
|
|
|
cd ${CAPTAINCORE_PATH}/data
|
|
|
|
health_check_directory="$path_email_health/${token}/"
|
|
if [ -d "$health_check_directory" ]; then
|
|
echo "$email_status" > "${health_check_directory}response-${site_id}-${environment}.txt"
|
|
fi
|
|
|
|
}
|
|
|
|
run_command |