Compare commits

..

33 Commits

Author SHA1 Message Date
391b0a0b09 Add even shorter aliases for sending and pushing clones, and also allow them to handle Git repos! 2026-04-11 09:31:45 -07:00
a76cb8b5ec Change order in which the scripts are added; do the project's first, then the downloads. 2026-04-10 18:09:40 -07:00
a87c205a80 Finish changes to reload-shared which adds scripts to the local bin. 2026-04-10 18:08:45 -07:00
186519fb0e Minify log functions. 2026-04-10 13:12:30 -07:00
7fa1430b34 Move log functions to shared, 2026-04-10 13:11:13 -07:00
074f0a29bf Explicitly note in sync-all that SYNC folders are not being handled. 2026-04-01 08:45:19 -07:00
bdb06cd0b4 Split SYNC folders out to have their own commands -- for safety! :) 2026-04-01 08:35:53 -07:00
ec9b74d3d8 Add aliases for push and pull called sync, both for individual folders as well as groups. 2026-04-01 08:22:01 -07:00
0bfdc8d411 Add shortcut to process the entire Clones collection. 2026-03-31 19:58:23 -07:00
89c0d0589c Fix OR's to be AND's for checking SYNC folders. 2026-03-31 19:51:26 -07:00
3edd062852 Change single quotes to double so regex works. 2026-03-31 19:44:34 -07:00
bc81d1bedd Add aliases for accidentally typed rewords of commands. 2026-03-31 19:43:47 -07:00
c859b4dcd8 Process folders named as SYNC as both a MASTER and CLONE. 2026-03-31 17:54:22 -07:00
be0469fb94 Enhance logging for subdir datasets. 2026-03-30 13:33:01 -07:00
5351df572b Change where the newline is so each clone is in its own log section. 2026-03-30 11:25:11 -07:00
ef097e973e Change where the newline is so each MASTER is in its own log section. 2026-03-30 11:16:59 -07:00
588007fe37 Change pull script to only do subdirectories in music. 2026-03-30 10:43:03 -07:00
3399b07031 The dashes need escaped even though they are quoted. 2026-03-29 17:57:34 -07:00
f8c8036e5f Fix the remote directory name for pulling. 2026-03-29 17:54:39 -07:00
076641fc9d Fix pull-clones to use pull-clone. ;) 2026-03-29 17:30:46 -07:00
40b53ce8a7 Fix filename to properly have an underscore. 2026-03-29 17:30:13 -07:00
6f8074d56b Add dash to MASTER, so things like SPACEMASTER would not get considered. 2026-03-29 16:59:32 -07:00
e6bc85e761 Add functions for pulling clones. Also add a dash to MASTER check. 2026-03-29 16:58:36 -07:00
7dcf55629d Add script to pull clones easily. 2026-03-29 16:57:03 -07:00
1cc57721f7 Add full set of vimrc commands from Ansible. 2026-03-28 16:25:19 -07:00
c27aed102b Rename file to just be a generic vimrc. 2026-03-28 15:13:00 -07:00
24047f4fbb Add code for qq in Vim. 2026-03-28 15:11:20 -07:00
d0b8afa2fb Add vimrc file. 2026-03-28 15:09:20 -07:00
cbacd3db50 Only export functions without underscores. 2026-03-28 14:41:27 -07:00
50e06f9196 Move now and today to shared env. Export all functions. 2026-03-28 14:24:34 -07:00
c58496e6a6 Move scan to be in shared env. 2026-03-28 14:18:57 -07:00
fb36a5f11b Bring some of the video processing functions to from Termux to Shared for desktop usage! 2026-03-28 14:17:06 -07:00
ae556e03e8 Enhance output of sending all masters. 2026-03-28 14:10:03 -07:00
4 changed files with 448 additions and 14 deletions

66
bin-shared/pull_clone.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# TBD:
# - merge into send-master script and use a variable to control push vs pull.
## Variables ##
PROG="$(basename -- "${BASH_SOURCE[0]}")"
loop=false
DIR="`pwd`"
dir="`basename $DIR`"
## Validations ##
if [[ "$DIR" != *"-clone" && "$DIR" != *"-SYNC" ]]; then
echo "'$DIR' is not labeled as a CLONE or SYNC. Skipping download."
exit 0
fi
# Only pull the existing subdirectories rather than ALL content.
subdirs_only="false"
if [[ "$dir" == "music-clone" ]]; then
subdirs_only="true"
fi
## Main ##
echo "`date` - Pulling" \
"'$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_PORT$PROD_DATA_DIR/$dir'" \
"to '$dir'."
sleep=0
while true; do
if (( $sleep > 0 )); then
echo "Sleeping for '$sleep' seconds..."
sleep $sleep
fi
if [[ "$subdirs_only" == "true" ]]; then
ls $DIR | while read subdir; do
echo -e "\n`date` - Working subdirectory '$subdir'..."
clone -e "ssh -p $PROD_DATA_PORT" \
$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_DIR/$dir/$subdir/ \
./$subdir &&
echo "`date` - Success!" ||
echo "`date` - Failed!"
done
else
clone -e "ssh -p $PROD_DATA_PORT" \
$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_DIR/$dir/ \
. &&
echo "`date` - Success!" ||
echo "`date` - Failed!"
fi
sleep=30
if [[ "$loop" == false ]]; then
break;
fi
done
## Complete ##
echo -e "\n`date` - $PROG complete."
exit 0

View File

@@ -14,8 +14,8 @@ dir="`basename $DIR`"
## Validations ##
if [[ "$DIR" != *"MASTER" ]]; then
echo "'$DIR' is not labeled as a MASTER. Skipping upload."
if [[ "$DIR" != *"-MASTER" && "$DIR" != *"-SYNC" ]]; then
echo "'$DIR' is not labeled as a MASTER or SYNC. Skipping upload."
exit 0
fi

View File

@@ -3,10 +3,12 @@
## Variables ##
# Environment Usability
# Environment Usability #
export PATH="$PATH:~/bin-shared:~/.bin-shared"
# PS1 Colors
# PS1 Colors #
export PURPLE="`tput setaf 55`"
export ORANGE="`tput setaf 208`"
export GREEN="`tput setaf 34`"
@@ -23,7 +25,8 @@ export BOLD="`tput bold`"
## Aliases ##
# Quickies
# Quickies #
alias reload-bash="source ~/.bashrc"
alias bash-reload="reload-bash"
alias shell-reload="reload-bash"
@@ -34,10 +37,14 @@ alias l='ls '
alias ll='ls -alh '
alias lh='ls -ash '
# Networking #
alias scan="nmap -A -p- --script=vuln "
## Functions ##
# Related specifically to this project.
# Related specifically to this project. #
function update-shared {
log "`date` - Reloading the '~/.rc_shared' file from env-shared.\n"
@@ -53,6 +60,21 @@ function update-shared {
mv -v $dir/rc_shared.sh ~/.rc_shared
local_bin="$HOME/bin"
remote_bin="shared-rc-deleteme/bin-shared"
if [[ -d "$local_bin" ]]; then
log "\n`date` - Found '$local_bin', adding scripts.\n"
mv -v $remote_bin/*.sh "$local_bin"/
refactor_script="refactor_music_library.sh"
wget -O "$refactor_script" \
https://git.hyperling.com/me/shell-music-refactor-library/src/branch/main/refactor_music_library.sh
mv -v $refactor_script "$local_bin"/
else
echo "Did not find '$local_bin', did not copy scripts."
fi
log "\n`date` - Done! Removing git clone.\n"
mv -v $dir ~/TRASH/"$dir-`date "+%Y%m%d-%H%M%S"`"
log "\n`date` - Complete! Please note this does NOT update bin files."
@@ -61,31 +83,366 @@ alias shared-update="update-shared"
alias reload-shared="update-shared"
alias shared-reload="update-shared"
# Shortcuts
# Shortcuts #
function send-master { send_master.sh; }
alias push-master="send-master"
alias sync-master="send-master"
function pull-clone { pull_clone.sh; }
alias get-clone="pull-clone"
alias sync-clone="pull-clone"
alias send-sync="send-master"
alias push-sync="send-master"
alias pull-sync="pull-clone"
alias get-sync="pull-clone"
function sync-sync {
cat <<- EOF
Command not implemented, too dangerous guessing the state of the folder.
Please use push-sync and pull-sync in the correct order for its current state.
EOF
}
function goodbye { update -y; bye; }
function clone {
rsync -auPhz --delete --exclude '.gradle' --exclude 'app/build' "$@"
}
export -f clone
# Enhance Bin Scripts
function now { date "+%Y%m%d-%H%M%S"; }
function today { date "+%Y%m%d"; }
function log { echo -e "$1"; }
function blog { echo -e "\n\n$1\n\n"; }
function pull {
if [[ -d .git ]]; then
git pull --recurse-submodules
else
pull-clone
fi
}
function push {
if [[ -d .git ]]; then
git push && load-stage && load-prod
else
send-master
fi
}
# Enhance Bin Scripts #
# MASTER and CLONE folders.
function send-masters {
ls | grep MASTER | while read dir; do
echo "Preparing to sync '$dir' to '$SERVER_NAME'."
echo -e "`date` - Looping through MASTER directories."
ls | grep "\-MASTER" | while read dir; do
echo -e "\n`date` - Found '$dir'..."
cd $dir
send-master
cd ..
done
echo -e "\n`date` - Done checking for MASTER directories."
}
export -f send-masters
alias push-masters="send-masters"
alias sync-masters="send-masters"
# Audio
function pull-clones {
echo -e "`date` - Looping through clone directories."
ls | grep "\-clone" | while read dir; do
echo -e "\n`date` - Found '$dir'..."
cd $dir
pull-clone
cd ..
done
echo -e "\n`date` - Done checking for clone directories."
}
alias get-clones="pull-clones"
alias sync-clones="pull-clones"
# Video
function sync-all {
push-masters
echo -e "\n"
pull-clones
echo -e "\n`date` - Skipping SYNC folders! Please do their loads separately."
ls | grep "\-SYNC" | while read dir; do
echo "- $dir"
done
echo -e "`date` - \nDone."
}
function sync-all-loop {
while true; do
sync-all
echo -e "\n\n*** Sleeping... ***\n\n"
sleep 30
done
}
# SYNC folders.
function send-syncs {
echo -e "`date` - Looping through SYNC directories."
ls | grep "\-SYNC" | while read dir; do
echo -e "\n`date` - Found '$dir'..."
cd $dir
send-master
cd ..
done
echo -e "\n`date` - Done checking for SYNC directories."
}
alias push-syncs="send-syncs"
function pull-syncs {
echo -e "`date` - Looping through SYNC directories."
ls | grep "\-SYNC" | while read dir; do
echo -e "\n`date` - Found '$dir'..."
cd $dir
pull-clone
cd ..
done
echo -e "\n`date` - Done checking for SYNC directories."
}
alias get-syncs="pull-syncs"
function sync-syncs {
cat <<- EOF
Command not implemented, too dangerous guessing the state of the folder.
Please use push-syncs and pull-syncs in the correct order for its current state.
EOF
}
# Audio #
# Video #
# Optimize the bitrate and audio levels for an edited video.
function process-video-usage {
echo "USAGE: process-video oldFile newFile [videoBitrate] [audioBitrate] [sizeRating] [numPasses] [forceBitrate]"
echo -n "Purpose: Call ffmpeg with preferred video posting settings. "
echo -n "Bitrates default to 2000k and 192k, size is 720, passes is 1, and force is N."
echo "These work well on Odysee and are fairly small as backups."
echo "Examples:"
echo "- Create a small file for quick streaming."
echo " process-video youcut.mp4 20240210.mp4 1200k 128k 480"
echo "- Create a larger file for something like YouTube."
echo " process-video youcut.mp4 20240210_1080p.mp4 5000k 256k 1080"
}
function process-video {
# Parameters
file="$1"
newfile="$2"
video="$3"
audio="$4"
size="$5"
passes="$6"
force="$7"
# Validations
if [[ -z $file || ! -e $file ]]; then
echo "ERROR: Original file '$file' does not exist." >&2
process-video-usage
return 1
fi
if [[ -z $newfile ]]; then
echo "ERROR: New file's name must be provided." >&2
process-video-usage
return 1
elif [[ -e $newfile ]]; then
echo "ERROR: New file '$newfile' already exists." >&2
du -h "$newfile"
process-video-usage
return 1
fi
echo "`date` - Converting '$file' to '$newfile'."
if [[ -z $video ]]; then
video="2000k"
fi
if [[ $force == "Y" ]]; then
video="-b:v $video"
else
video="-b:v $video -minrate 0 -maxrate $video -bufsize $video"
fi
if [[ -z $audio ]]; then
audio="192k"
fi
audio="-b:a $audio"
if [[ -z $size ]]; then
size="720"
fi
size="-filter:v scale=-1:$size"
if [[ -z $passes ]]; then
passes=1
fi
pass=""
if [[ $passes != 1 ]]; then
passes=2
pass="-pass 2"
fi
## Main ##
# More information on two-pass processing with ffmpeg
# https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html
if [[ $passes == 2 ]]; then
set -x
ffmpeg -nostdin -hide_banner -loglevel quiet \
-i "$file" $size $video $audio \
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
-vcodec libx264 -movflags +faststart \
-pass 1 -f mp4 /dev/null -y
status=$?
set +x
echo "`date` - Done with the first pass."
if [[ $status != 0 ]]; then
echo "Received unsuccessful status, exiting."
return 1
fi
fi
set -x &&
ffmpeg -nostdin -hide_banner -loglevel quiet \
-i "$file" $size $video $audio \
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
-vcodec libx264 -movflags +faststart \
$pass "$newfile"
status="$?"
set +x
echo "`date` - Done with the final pass."
if [[ $passes == 2 && $status == 0 ]]; then
mv -v ffmpeg2pass*.log* ~/TRASH/
fi
sync
sleep 10
sync
if [[ -s $newfile ]]; then
echo "`date` - Getting file sizes."
du -h "$file"
du -h "$newfile"
else
echo "ERROR: New file not created or has a 0 size." >&2
fi
echo -e "\n`date` - Finished with status '$status'."
return $status
}
alias pv="process-video"
alias qpv="pv ./raw/YouCut*.mp4 `basename $(pwd)`.mp4"
# Allow converting video to audio and other smaller
# tasks than what process-video is intended to do.
function basic-process-usage {
echo "basic-process INPUT OUTPUT NORMALIZE [EXTRA]"
echo -n "Pass a file through ffmpeg with the option"
echo "to easily normalize the audio with a Y."
echo "Examples:"
echo "- Normalize audio on a video."
echo " basic-process video.mp4 normalized.mp4 Y"
echo "- Convert a video to audio at 192k."
echo " basic-process video.mp4 audio.mp3 N '-b:a 192k'"
}
function basic-process {
# Parameters
input="$1"
output="$2"
typeset -u normalize
normalize="$3"
extra="$4"
echo "`date` - Starting basic-process"
# Validations
if [[ -z $input || ! -e $input ]]; then
echo "ERROR: Input file '$input' does not exist." >&2
basic-process-usage
return 1
fi
if [[ -z $output ]]; then
echo "ERROR: Output file's name must be provided." >&2
basic-process-usage
return 1
elif [[ -e $output ]]; then
echo "ERROR: Output file '$output' already exists." >&2
du -h "$output"
basic-process-usage
return 1
fi
if [[ $normalize == "Y" ]]; then
echo "Normalize set to TRUE."
normal="-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3"
else
echo "No audio normalization is being done."
fi
# Main
echo "`date` - Converting '$input' to '$output'."
set -x
ffmpeg -nostdin -hide_banner -loglevel quiet \
-i "$input" $extra $normal "$output"
status=$?
set +x
if [[ $status != 0 ]]; then
echo "`date` - WARNING: ffmpeg exited with status '$status'." >&2
fi
# Finish
if [[ ! -s $output ]]; then
echo "`date` - ERROR: Output '$output' not created or has 0 size." >&2
return 1
fi
sync
echo "`date` - '$output' has been created successfully."
sleep 3
du -h "$input"
du -h "$output"
echo "`date` - Finished basic-process"
return 0
}
alias bp="basic-process"
alias bv="bp"
# Function to automatically append the Y.
function fix-audio { basic-process "$1" "$2" Y; }
function eq { fix-audio "$1" "$2"; }
# Function to easily turn a video to audio without typing the audio name.
function convert-to-audio {
video="$1"
audio="$2"
if [[ -z "$2" || "$2" == "Y" ]]; then
audio="${1//mp4/mp3}"
fi
volume=""
if [[ ( "$2" == "Y" && -z "$3" ) || "$3" == "Y" ]]; then
$volume="Y"
fi
basic-process "$video" "$audio" $volume
}
alias v2a="convert-to-audio"
alias vta="v2a"
alias pull-audio="v2a"
alias pa="v2a"
# Export all functions! #
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
## Complete! ##

11
vimrc.vim Normal file
View File

@@ -0,0 +1,11 @@
" Turn off syntax, flashy lights, etc. Make VIM into a basic editor.
syntax off
set nohlsearch
set noautoindent noautowrite noshowmatch wrapmargin=0 report=1 ts=3
set ignorecase
" Turn off auto-commenting.
autocmd Filetype * set fo-=c fo-=r fo-=o
" qq shortcut for immediately exiting all files without saving.
nnoremap qq :qa!<cr>