mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2025-10-04 01:48:24 +08:00
64 lines
1.5 KiB
Bash
Executable file
64 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Deploy default plugins/themes/settings for website
|
|
#
|
|
# `captaincore deploy-defaults`
|
|
#
|
|
# [<site>...]
|
|
# One or more sites.
|
|
#
|
|
# [--global-only]
|
|
#
|
|
# [@<target>]
|
|
# Target groups of sites like @all @production or @staging.
|
|
#
|
|
|
|
# Load configuration
|
|
root_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; root_path=${root_path%app*}
|
|
source ${root_path}lib/arguments
|
|
|
|
run_command() {
|
|
|
|
echo "Deploying defaults to $# sites"
|
|
|
|
# Remove leading "--" from flags
|
|
for i in "${!flags[@]}"; do
|
|
flags[$i]=`echo ${flags[$i]} | cut -c 3-`
|
|
done
|
|
|
|
cd ${root_path}data;
|
|
|
|
for website in "$@"; do
|
|
|
|
# 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 $website --bash --captain_id=$captain_id)"
|
|
|
|
wp eval-file ../lib/local-scripts/site-deploy-defaults.php site=$site environment=$environment ${flags[@]}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
# See if any sites are specifed
|
|
if [ ${#arguments[*]} -gt 0 ]; then
|
|
# Runs on specifed sites
|
|
run_command ${arguments[*]}
|
|
fi
|
|
|
|
# Runs on targeted sites
|
|
if [ ${#targets[*]} -gt 0 ]; then
|
|
run_command $(captaincore site list ${targets[*]/targets=/@} --captain_id=$captain_id)
|
|
fi
|
|
|
|
# Error if no sites specifed
|
|
if [ ${#targets[*]} -eq 0 ] && [ ${#arguments[*]} -eq 0 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify one or more sites, or use a target @all, @production or @staging."
|
|
fi
|