mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-18 13:16:01 +08:00
66 lines
1.3 KiB
Bash
Executable file
66 lines
1.3 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.
|
|
#
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(php ${CAPTAINCORE_PATH}/lib/local-scripts/configs.php fetch)"
|
|
|
|
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
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $site --bash --captain-id=$CAPTAIN_ID)"
|
|
|
|
if [[ $domain == "" ]]; then
|
|
echo "Domain not found"
|
|
continue
|
|
fi
|
|
|
|
read -r -d '' php_code << heredoc
|
|
\$run_code = <<<PHPHEREDOC
|
|
wp_content=$wp_content
|
|
provider=$provider
|
|
name=$FLAG_NAME
|
|
link=$FLAG_LINK
|
|
PHPHEREDOC;
|
|
|
|
echo base64_encode( \$run_code );
|
|
heredoc
|
|
|
|
arguments=$( php -r "$php_code" )
|
|
|
|
captaincore ssh $site-$environment --script=deactivate -- --arguments="$arguments"
|
|
|
|
}
|
|
|
|
run_command
|