mirror of
https://ghproxy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-08-04 14:10:32 +08:00
56 lines
1.4 KiB
Bash
Executable file
56 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Generates content fingerprint for quicksave change detection.
|
|
# Outputs a single md5sum hash of all file contents in plugins/, themes/, mu-plugins/.
|
|
#
|
|
# Usage: captaincore ssh <site> --script=quicksave-fingerprint -- --wp_content=wp-content
|
|
#
|
|
|
|
# Loop through arguments and separate regular arguments from flags
|
|
for arg in "$@"; do
|
|
|
|
# Add to arguments array. (Does not starts with "--")
|
|
if [[ $arg != --* ]]; then
|
|
count=1+${#arguments[*]}
|
|
arguments[$count]=$arg
|
|
continue
|
|
fi
|
|
|
|
# Remove leading "--"
|
|
flag_name=$( echo $arg | cut -c 3- )
|
|
|
|
# Add to flags array
|
|
count=1+${#flags[*]}
|
|
flags[$count]=$arg
|
|
|
|
# Process flags without data (Assign to variable)
|
|
if [[ $arg != *"="* ]]; then
|
|
flag_name=${flag_name//-/_}
|
|
declare "$flag_name"=true
|
|
fi
|
|
|
|
# Process flags with data (Assign to variable)
|
|
if [[ $arg == *"="* ]]; then
|
|
flag_value=$( echo $flag_name | perl -n -e '/.+?=(.+)/&& print $1' )
|
|
flag_name=$( echo $flag_name | perl -n -e '/(.+?)=.+/&& print $1' )
|
|
flag_name=${flag_name//-/_}
|
|
declare "$flag_name"="$flag_value"
|
|
fi
|
|
|
|
done
|
|
|
|
# Default wp_content path
|
|
if [[ -z "$wp_content" ]]; then
|
|
wp_content="wp-content"
|
|
fi
|
|
|
|
cd "$wp_content" 2>/dev/null || exit 1
|
|
|
|
find plugins/ themes/ mu-plugins/ -type f \
|
|
! -path '*/node_modules/*' \
|
|
! -path '*/.git/*' \
|
|
! -name .DS_Store \
|
|
! -name error_log \
|
|
-exec md5sum {} + 2>/dev/null \
|
|
| sort -k2 | md5sum | awk '{print $1}'
|