captaincore/app/site/delete
2026-03-05 18:56:33 -05:00

52 lines
No EOL
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Removes a site from CaptainCore CLI.
#
# `captaincore site delete <site>`
#
if [ ${#@} -ne 1 ]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a site."
exit
fi
while read config; do
if [[ "$config" == "Error:"* ]]; then
continue
fi
declare "$config"
done <<< "$(captaincore config fetch --captain-id=$CAPTAIN_ID)"
site=$1
if [[ "$site" == "" ]]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify one a site."
return 1
fi
run_command() {
cd ${CAPTAINCORE_PATH}/data
verify=$( captaincore site get $site --captain-id=$CAPTAIN_ID )
if [[ "$verify" == "" ]]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Site '$site' not found in CaptainCore."
return 1
fi
# Final snapshot then remove site related files
captaincore snapshot generate $site --delete-after-snapshot --email=$captaincore_admin_email --captain-id=$CAPTAIN_ID
# Load site configs
IFS=$'\n'$'\r'; for line in $(captaincore site get $site --bash --captain-id=$CAPTAIN_ID); do declare "$line"; done; unset IFS
echo "Error: 'site delete' should now be handled natively in Go. If you see this, the native handler did not run."
# Update configs
captaincore configs update-websites --captain-id=$CAPTAIN_ID
}
run_command