mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2025-10-04 04:47:02 +08:00
46 lines
No EOL
1.9 KiB
Bash
46 lines
No EOL
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Adds a site to CaptainCore CLI.
|
|
#
|
|
# `captaincore site add <site>`
|
|
#
|
|
# --id=<id> --domain=<domain> --username=<username> --password=<password> --address=<address> --protocol=<protocol> --port=<port> --staging_username=<staging_username> --staging_password=<staging_password> --staging_address=<staging_address> --staging_protocol=<staging_protocol> --staging_port=<staging_port> [--preloadusers=<preloadusers>] [--home_directory=<home_directory>] [--offload_provider=<offload_provider>] [--offload_access_key=<offload_access_key>] [--offload_secret_key=<offload_secret_key>] [--offload_bucket=<offload_bucket>] [--offload_path=<offload_path>] [--captain_id=<id>]
|
|
# Example: captaincore site add <site> --id=1234 --domain=sitename.com --username=sitename --password=random --address=sitename.wpengine.com --protocol=sftp --port=2222 --staging_username=sitename-staging --staging_password=randompassword --staging_address=sitename.wpengine.com --staging_protocol=sftp --staging_port=2222 --preloadusers=1737
|
|
#
|
|
|
|
# Load configuration
|
|
root_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; root_path=${root_path%app*}
|
|
source ${root_path}lib/arguments
|
|
|
|
run_command() {
|
|
|
|
# Remove leading "--" from flags
|
|
for i in "${!flags[@]}"; do
|
|
flags[$i]=`echo ${flags[$i]} | cut -c 3-`
|
|
done
|
|
|
|
cd ${root_path}data
|
|
wp eval-file ../lib/local-scripts/site-add.php site=$1 ${flags[@]}
|
|
|
|
# Load site configs
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $1 --bash --captain_id=$captain_id)"
|
|
|
|
# Generate rclone keys
|
|
captaincore site rclone-configs $site --captain_id=$captain_id
|
|
|
|
# Update configs
|
|
captaincore configs update-websites --captain_id=$captain_id
|
|
|
|
}
|
|
|
|
# See if any sites are specifed
|
|
if [ ${#arguments[*]} -eq 1 ]; then
|
|
# Runs on specifed sites
|
|
run_command ${arguments[*]}
|
|
fi
|
|
|
|
# Error if no sites specifed
|
|
if [ ${#arguments[*]} -eq 0 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a site."
|
|
fi |