captaincore/app/quicksave/get
2026-03-05 18:56:33 -05:00

46 lines
No EOL
1,012 B
Bash
Executable file

#!/usr/bin/env bash
#
# Fetches quicksave for a site
#
# `captaincore quicksave get <site> <hash>`
#
while read config; do
if [[ "$config" == "Error:"* ]]; then
continue
fi
declare "$config"
done <<< "$(captaincore config fetch --captain-id=$CAPTAIN_ID)"
if [ ${#@} -ne 2 ]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify <site> and <hash>."
exit
fi
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
IFS=$'\n'$'\r'; for line in $(captaincore site get $site --bash --captain-id=$CAPTAIN_ID); do declare "$line"; done; unset IFS
quicksave="$path/${site}_${site_id}/${environment}/quicksaves/commit-$hash.json"
if [ ! -f "$quicksave" ]; then
generate=$( captaincore quicksave get-generate $site-$environment $hash --captain-id=$CAPTAIN_ID )
fi
cat $quicksave