mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-07-28 13:07:02 +08:00
64 lines
1.8 KiB
Bash
Executable file
64 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Preps new site configurations into logins via command line
|
|
#
|
|
# `captaincore site prepare <site>`
|
|
#
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(captaincore config fetch --captain-id=$CAPTAIN_ID)"
|
|
|
|
if [ ${#@} -ne 1 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a site."
|
|
exit
|
|
fi
|
|
|
|
site=$1
|
|
|
|
# Load site details
|
|
IFS=$'\n'$'\r'; for line in $(captaincore site get $site --bash --captain-id=$CAPTAIN_ID); do declare "$line"; done; unset IFS
|
|
|
|
IFS=$' \t\n'; environments=( $( captaincore environment list $site --captain-id=$CAPTAIN_ID ) )
|
|
|
|
for environment in ${environments[@]}; do
|
|
|
|
# Deploy SSH keys
|
|
captaincore site deploy-keys ${site}-${environment} --captain-id=$CAPTAIN_ID
|
|
|
|
# Generate token
|
|
token_key=$( captaincore ssh $site-$environment --script=fetch-token --captain-id=$CAPTAIN_ID )
|
|
|
|
if [[ "$captaincore_dev" == true ]]; then
|
|
curl_argument="-k"
|
|
fi
|
|
|
|
# Assign token
|
|
curl ${curl_argument} --request POST "$captaincore_api" --header "Content-Type: application/json" --data @- << EOF
|
|
{
|
|
"command":"token",
|
|
"site_id":"$site_id",
|
|
"token_key":"$token_key",
|
|
"token":"$token"
|
|
}
|
|
EOF
|
|
|
|
# Set permalink to 'Post name' format if not set
|
|
captaincore ssh ${site}-${environment} --script=rewrite-prep --captain-id=$CAPTAIN_ID
|
|
|
|
# Deploy helper plugin
|
|
captaincore ssh ${site}-${environment} --script=deploy-helper --captain-id=$CAPTAIN_ID -- --wp_content=$wp_content
|
|
|
|
captaincore sync-data ${site}-${environment} --captain-id=$CAPTAIN_ID
|
|
|
|
# Generate new Fathom code if needed
|
|
if [[ "$( captaincore site get ${site}-${environment} --field=fathom --captain-id=$CAPTAIN_ID )" == "" ]]; then
|
|
# Generate new Fathom tracking code, if needed
|
|
captaincore site stats-generate ${site}-${environment} --captain-id=$CAPTAIN_ID
|
|
fi
|
|
|
|
done
|