mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-23 01:50:05 +08:00
57 lines
No EOL
1.4 KiB
Bash
57 lines
No EOL
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Generate thumbnails for one or more sites based on most recent capture.
|
|
#
|
|
# `captaincore regenerate-thumbnails`
|
|
#
|
|
# [<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() {
|
|
|
|
echo "Generating thumbnails for $# sites"
|
|
INDEX=1
|
|
for website in "$@"; do
|
|
|
|
while read site_configs; do declare "$site_configs"; done <<< "$(captaincore site get $website --bash --captain_id=$captain_id)"
|
|
|
|
# Return error if domain not found
|
|
if [[ "$domain" == "" ]] || [[ "$site" == "" ]]; then
|
|
echo "Can't locate website for site $site"
|
|
return 1
|
|
fi
|
|
|
|
cd ${root_path}data
|
|
wp eval-file ../lib/local-scripts/regenerate-thumbnails.php site_id=$site_id captain_id=$captain_id
|
|
|
|
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 |