mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-23 02:54:40 +08:00
91 lines
2 KiB
Bash
Executable file
91 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Sends theme and plugin update logs to CaptainCore API.
|
|
#
|
|
# `captaincore update-log-import`
|
|
#
|
|
# [<site>...]
|
|
# One or more sites.
|
|
#
|
|
# [@<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() {
|
|
|
|
INDEX=1
|
|
for website in "$@"; do
|
|
|
|
|
|
# Load site configs
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $website --bash --captain_id=$captain_id)"
|
|
|
|
# Site found, start the backup
|
|
if [[ $site_id != "" ]] && [[ $site != "" ]]; then
|
|
|
|
echo "${INDEX}/$# - $domain"
|
|
|
|
response=$(captaincore update-fetch $site)
|
|
|
|
if [[ "$debug" == "true" ]]; then
|
|
echo "$captaincore_api?core=$core_version&plugins=$plugin_data&themes=$theme_data&users=$user_data&token=$token"
|
|
continue
|
|
fi
|
|
|
|
|
|
if [[ "$captaincore_dev" == true ]]; then
|
|
curl_argument="-k "
|
|
fi
|
|
|
|
# Adds sync data to CaptainCore GUI
|
|
curl ${curl_argument}--request POST "$captaincore_api" --header "Content-Type: application/json" --data @- << EOF
|
|
{
|
|
"command": "import-update-log",
|
|
"site_id":"$site_id",
|
|
"token":"$token",
|
|
"data":$response
|
|
}
|
|
EOF
|
|
|
|
fi
|
|
|
|
# Clear out variables
|
|
site=''
|
|
site_id=''
|
|
domain=''
|
|
username=''
|
|
password=''
|
|
address=''
|
|
protocol=''
|
|
port=''
|
|
home_directory=''
|
|
remoteserver=''
|
|
s3bucket=''
|
|
s3path=''
|
|
subsite=''
|
|
|
|
let INDEX=${INDEX}+1
|
|
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
|