mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 18:49:42 +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 <<< "$(php ${CAPTAINCORE_PATH}/lib/local-scripts/configs.php fetch)"
|
|
|
|
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
|
|
|
|
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
|
|
cat $email_status > "${health_check_directory}response-${site_id}-${environment}.txt"
|
|
fi
|
|
|
|
}
|
|
|
|
run_command |