mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-07-28 13:07:02 +08:00
99 lines
No EOL
2.1 KiB
Bash
Executable file
99 lines
No EOL
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Deploys custom deactivate mu-plugin on one or more sites.
|
|
#
|
|
# `captaincore deactivate`
|
|
#
|
|
# [<site>...]
|
|
# One or more sites to deactivate.
|
|
#
|
|
# [--name=<business-name>]
|
|
# Custom name to display on deactivate page.
|
|
#
|
|
# [--link=<business-link>]
|
|
# Custom link to display on deactivate page.
|
|
#
|
|
# [--subject=<subject>]
|
|
# Heading/Subject to show on deactivate page.
|
|
#
|
|
# [--status=<status>]
|
|
# Status message to show on deactivate page.
|
|
#
|
|
# [--action=<action>]
|
|
# Action text to show on deactivate page.
|
|
#
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(captaincore config fetch --captain-id=$CAPTAIN_ID)"
|
|
|
|
if [ ${#@} -ne 1 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a <site>."
|
|
exit
|
|
fi
|
|
|
|
site=$1
|
|
|
|
run_command() {
|
|
|
|
# Extract environment
|
|
if [[ "$website" == *"-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 [[ $domain == "" ]]; then
|
|
echo "Domain not found"
|
|
continue
|
|
fi
|
|
|
|
# Remove surrounding quotes and unescape
|
|
FLAG_NAME=${FLAG_NAME%\"}
|
|
FLAG_NAME=${FLAG_NAME#\"}
|
|
FLAG_NAME=${FLAG_NAME//\\\'/\'}
|
|
|
|
FLAG_LINK=${FLAG_LINK%\"}
|
|
FLAG_LINK=${FLAG_LINK#\"}
|
|
FLAG_LINK=${FLAG_LINK//\\\'/\'}
|
|
|
|
FLAG_SUBJECT=${FLAG_SUBJECT%\"}
|
|
FLAG_SUBJECT=${FLAG_SUBJECT#\"}
|
|
FLAG_SUBJECT=${FLAG_SUBJECT//\\\'/\'}
|
|
|
|
FLAG_STATUS=${FLAG_STATUS%\"}
|
|
FLAG_STATUS=${FLAG_STATUS#\"}
|
|
FLAG_STATUS=${FLAG_STATUS//\\\'/\'}
|
|
|
|
FLAG_ACTION=${FLAG_ACTION%\"}
|
|
FLAG_ACTION=${FLAG_ACTION#\"}
|
|
FLAG_ACTION=${FLAG_ACTION//\\\'/\'}
|
|
|
|
read -r -d '' php_code << heredoc
|
|
\$run_code = <<<PHPHEREDOC
|
|
wp_content=$wp_content
|
|
provider=$provider
|
|
name=$FLAG_NAME
|
|
link=$FLAG_LINK
|
|
subject=$FLAG_SUBJECT
|
|
status=$FLAG_STATUS
|
|
action=$FLAG_ACTION
|
|
PHPHEREDOC;
|
|
|
|
echo base64_encode( \$run_code );
|
|
heredoc
|
|
|
|
arguments=$( php -r "$php_code" )
|
|
|
|
captaincore ssh $site-$environment --script=deactivate -- --arguments="$arguments"
|
|
|
|
}
|
|
|
|
run_command |