mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 20:45:45 +08:00
44 lines
No EOL
1.2 KiB
Bash
44 lines
No EOL
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Generate quicksave response for a site
|
|
#
|
|
# `captaincore quickave get-generate <site> <hash>`
|
|
#
|
|
|
|
if [ ${#@} -eq 0 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify <quicksave> and <hash>."
|
|
exit 1
|
|
fi
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(php ${CAPTAINCORE_PATH}/lib/local-scripts/configs.php fetch)"
|
|
|
|
site=$1
|
|
hash=$2
|
|
|
|
# Extract environment
|
|
if [[ "$site" == *"-staging"* ]]; then
|
|
environment=staging
|
|
fi
|
|
|
|
if [[ "$site" == *"-production"* ]]; then
|
|
environment=production
|
|
fi
|
|
|
|
if [[ "$site" != *"-"* ]]; then
|
|
environment=production
|
|
fi
|
|
|
|
# Load site configs
|
|
while read site_configs; do if [[ $site_configs == "" ]]; then continue; fi; declare "$site_configs"; done <<< "$(captaincore site get $site --bash --captain-id=$CAPTAIN_ID)"
|
|
|
|
cd ${CAPTAINCORE_PATH}/data
|
|
|
|
hash_file="$path/${site}_${site_id}/${environment}/quicksaves/commit-${hash}.json"
|
|
echo "Generating ${site}_${site_id}/${environment}/quicksaves/commit-${hash}.json"
|
|
wp eval-file ${CAPTAINCORE_PATH}/lib/local-scripts/quicksave-get.php hash=$hash site=$site site_id=$site_id environment=$environment > "$hash_file" |