Compare commits

..

46 Commits

Author SHA1 Message Date
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
4ef51915fb Update TBD's. 2026-03-28 14:03:52 -07:00
0a3b339921 Finalize changes needed to get send-master to work!! Yay! 2026-03-28 14:03:08 -07:00
9243bd5480 Add exporting of functions needed for scripts. 2026-03-28 13:44:40 -07:00
c09e5560e6 Change clone to use all-params ($@). 2026-03-28 13:37:50 -07:00
90a94ec648 Move clone and ls aliases to shared. 2026-03-28 13:34:38 -07:00
945563aa28 Change double quotes to singles in clone command. 2026-03-28 13:30:44 -07:00
bb542d1d2f Further fix the while loop. 2026-03-28 13:29:34 -07:00
7ff5431e83 Change do-while to while. 2026-03-28 13:27:01 -07:00
0e193d430b Fix misquotes. 2026-03-28 12:54:19 -07:00
bef7091063 Fix output for updater. 2026-03-28 12:25:04 -07:00
890c991f18 Use log rather than echo. Add quotes on color assignments. 2026-03-28 12:22:41 -07:00
f34e02c641 Ensure colors are exported! 2026-03-28 12:20:14 -07:00
df8f7f3101 Add output to rc shared updater. 2026-03-28 12:19:25 -07:00
74fb1def7f Fix the function to reload shared RC file. 2026-03-28 12:18:24 -07:00
6d0840d4eb Fix the DIR variable to be current directory, not program directory. 2026-03-28 12:15:17 -07:00
eb9eb03c1e Remove start message. 2026-03-28 12:10:57 -07:00
9d1141bf82 Fix output to be more helpful. 2026-03-28 12:08:29 -07:00
513c0d6fac Add colors for PS1 prompts. 2026-03-28 12:08:16 -07:00
6ed7475c02 Change command to use the proper variables which should now exist in each main env project. Add a sleep for the loop with conditional output. 2026-03-27 18:40:11 -07:00
6afd10b296 Only show the output if not running as root. 2026-03-27 18:35:26 -07:00
e815803630 Add dates to output. 2026-03-27 18:34:20 -07:00
b94a3e4a0b Add an explicit bye since goodbye does not seem to be working still? 2026-03-27 17:09:42 -07:00
9c9de6f96f Add function which syncs all the MASTER catalogs in the current directory. 2026-03-27 17:07:24 -07:00
c5d1386211 Add another TODO to master sync script. 2026-03-27 17:06:48 -07:00
9f6c7834d8 Add comments and TBD's. 2026-03-23 12:31:42 -07:00
bbf7bd5606 Add comments to script. 2026-03-23 12:25:55 -07:00
3f4d3363af Finish the script for the shared config to update itself. Add aliases. 2026-03-23 12:24:11 -07:00
8e3c581d16 Rename file for better code highlighting. 2026-03-23 12:21:39 -07:00
3de906a03f Create alias with dash for script. 2026-03-23 12:13:57 -07:00
1c919cb4d9 Use underscore in script filename as well. 2026-03-23 12:13:46 -07:00
8bf6b5905c Use underscore in name. 2026-03-23 12:13:00 -07:00
3c6a0994c6 Edit note to be more stern yet kind. ;) 2026-03-23 12:08:40 -07:00
9bb80b51c4 Add RC file which sources the shared bin. 2026-03-23 12:07:55 -07:00
17a65f6ce0 Rename the bin dir to include shared. 2026-03-23 12:07:49 -07:00
353b38fad4 Rename script to something easier to remember as well as type. 2026-03-23 12:01:51 -07:00
c5a1015083 Add a script for uploading MASTER catalogs automagically, so the location of the trailing slash can't accidentally be swapped. ;) 2026-03-23 12:00:07 -07:00
4 changed files with 432 additions and 0 deletions

47
bin-shared/pull-clone.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/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" ]]; then
echo "'$DIR' is not labeled as a clone. Skipping download."
exit 0
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
clone -e "ssh -p $PROD_DATA_PORT" \
$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_DIR/$new_dir \
. &&
echo "`date` - Success!" ||
echo "`date` - Failed!"
sleep=30
if [[ "$loop" == false ]]; then
break;
fi
done
## Complete ##
echo "`date` - $PROG complete."
exit 0

48
bin-shared/send_master.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# TBD:
# - add parameter to set loop=true, and accept a value for sleep seconds
# - allow passing the script a variable for the dir, rather than assuming curr
## Variables ##
PROG="$(basename -- "${BASH_SOURCE[0]}")"
loop=false
DIR="`pwd`"
dir="`basename $DIR`"
## Validations ##
if [[ "$DIR" != *"MASTER" ]]; then
echo "'$DIR' is not labeled as a MASTER. Skipping upload."
exit 0
fi
## Main ##
new_dir="${dir//MASTER/clone}"
echo "`date` - Sending '$dir' to" \
"'$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_PORT$PROD_DATA_DIR/$new_dir'"
sleep=0
while true; do
if (( $sleep > 0 )); then
echo "Sleeping for '$sleep' seconds..."
sleep $sleep
fi
clone -e "ssh -p $PROD_DATA_PORT" ./ \
$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_DIR/$new_dir &&
echo "`date` - Success!" ||
echo "`date` - Failed!"
sleep=30
if [[ "$loop" == false ]]; then
break;
fi
done
## Complete ##
echo "`date` - $PROG complete."
exit 0

326
rc_shared.sh Normal file
View File

@@ -0,0 +1,326 @@
# Notes:
# - Please keep this file working for both BASH and ZSH. :)
## Variables ##
# Environment Usability #
export PATH="$PATH:~/bin-shared:~/.bin-shared"
# PS1 Colors #
export PURPLE="`tput setaf 55`"
export ORANGE="`tput setaf 208`"
export GREEN="`tput setaf 34`"
export RED="`tput setaf 196`"
export SCARLET="`tput setaf 160`"
export YELLOW="`tput setaf 226`"
export GRAY="`tput setaf 243`"
export RESET="`tput sgr0`"
export BOLD="`tput bold`"
## Aliases ##
# Quickies #
alias reload-bash="source ~/.bashrc"
alias bash-reload="reload-bash"
alias shell-reload="reload-bash"
alias reload-shell="reload-bash"
alias reload="reload-bash"
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. #
function update-shared {
log "`date` - Reloading the '~/.rc_shared' file from env-shared.\n"
branch="$1"
if [[ -z "$branch" ]]; then
branch="dev"
fi
dir="shared-rc-deleteme"
git clone https://git.hyperling.com/me/env-shared \
$dir --branch=$branch
mv -v $dir/rc_shared.sh ~/.rc_shared
mv -v $dir ~/TRASH/"$dir-`date "+%Y%m%d-%H%M%S"`"
log "\n`date` - Complete! Please note this does NOT update bin files."
}
alias shared-update="update-shared"
alias reload-shared="update-shared"
alias shared-reload="update-shared"
# Shortcuts #
function send-master { send_master.sh; }
function goodbye { update -y; bye; }
function clone {
rsync -auPhz --delete --exclude '.gradle' --exclude 'app/build' "$@"
}
function now { date "+%Y%m%d-%H%M%S"; }
function today { date "+%Y%m%d"; }
# Enhance Bin Scripts #
function send-masters {
echo -e "`date` - Looping through MASTER directories.\n"
ls | grep MASTER | while read dir; do
echo -e "`date` - Found '$dir'..."
cd $dir
send-master
cd ..
done
echo -e "\n`date` - Done checking for MASTER directories."
}
# 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! ##
[[ $(whoami) != "root" ]] &&
echo "`date` - Shared RC Config - 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>