Compare commits

..

31 Commits

Author SHA1 Message Date
6e4f76dc58 Add functions for full level reload and update. 2026-05-05 15:41:39 -07:00
eb63e0321c Simplify verbiage and shorten the length. 2026-05-05 15:24:34 -07:00
c9889f6a23 Remove the 2 since the updater functions have been merged. 2026-05-05 09:45:48 -07:00
20b130e931 Switch order of subshells in case it helps with the file getting called home.mp4 every time. 2026-05-05 09:29:18 -07:00
de6ca756da Add shortcut to get to main library. 2026-05-05 09:21:02 -07:00
332631e3dd Move trash related code to shared env. 2026-04-25 10:33:21 -07:00
a6b5cd9297 Fix the URLs to get the raw file. Thought this was already done! 2026-04-25 09:19:16 -07:00
14ce936e9b Promote update-shared2 to be the new default. 2026-04-25 09:15:38 -07:00
79a35be993 Move the update checker to be after all functions are declared so that log works properly. 2026-04-25 08:17:29 -07:00
0c54259a38 Add message to video processing function that a sync is being done. 2026-04-25 07:48:51 -07:00
4791e1c168 Fix typo. 2026-04-23 09:15:22 -07:00
9d604c6e90 Add missing quotes and do not use cd. 2026-04-17 18:06:44 -07:00
cf1b7a160a Finalize output (for now). 2026-04-17 16:20:20 -07:00
74d727faa9 Fix output for both update shared functions. 2026-04-17 16:17:03 -07:00
56969e9ee9 Prevent the code from being spit onto the screen by having it in a subshell. 2026-04-17 16:13:27 -07:00
340667329c Remove the output from fetch. 2026-04-17 16:10:51 -07:00
e1d9b6cf94 Continue enhancing the auto-update version of env-shared. 2026-04-17 16:09:40 -07:00
71875470c2 Add missing variables. 2026-04-17 15:57:21 -07:00
1989377b8b Begin adding the code which syncs up the project and distributes the files. 2026-04-17 15:56:30 -07:00
6887a1e131 Add what will happen if updates are found. 2026-04-17 15:52:20 -07:00
209af03777 Modify how the default branch is determined. 2026-04-17 15:46:04 -07:00
21b2ddf4a5 Begin adding code for checking for updates upon terminal opening. 2026-04-17 15:34:42 -07:00
890bc05e4d Add shortcuts to get to clones. 2026-04-17 15:20:34 -07:00
e2ec550fab Increase sleep timer for sync-all-loop and allow a custom time to be passed. 2026-04-14 08:39:20 -07:00
495a140805 Fix the newline to be after the output. 2026-04-13 19:13:06 -07:00
9d609568f7 Ensure bin files are executable. 2026-04-13 14:06:49 -07:00
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

View File

@@ -37,6 +37,20 @@ alias l='ls '
alias ll='ls -alh '
alias lh='ls -ash '
function cl {
if [[ -d /sdcard ]]; then
cd /sdcard/Library/Clones
else
cd $HOME/Clones
fi
}
alias clones="cl"
alias cdl="cl"
alias cdc="cl"
alias library="clones && cd .."
alias lib="library"
# Networking #
alias scan="nmap -A -p- --script=vuln "
@@ -46,11 +60,19 @@ alias scan="nmap -A -p- --script=vuln "
# 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="$BRANCH"
if [[ -z "$branch" ]]; then
branch="$PROD_GIT_BRANCH"
fi
if [[ -z "$branch" ]]; then
branch="dev"
fi
function update-shared-old {
log "`date` - Reloading the '~/.rc_shared' file from env-shared.\n"
if [[ -n "$1" ]]; then
branch="$1"
fi
dir="shared-rc-deleteme"
@@ -60,14 +82,102 @@ 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/raw/branch/main/refactor_music_library.sh
mv -v $refactor_script "$local_bin"/
chmod 755 -Rv "$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."
log "\n`date` - Complete!"
}
project="$HOME/.env-shared"
function update-shared2 {
if [[ -d $project ]]; then
log "`date` - Updating '$project'.\n"
git -C "$project" switch "$branch"
git -C "$project" pull --recurse-submodules || \
( echo "Failed to pull project, exiting." && return 1 )
else
log "`date` - Downloading '$project'.\n"
git clone https://git.hyperling.com/me/env-shared \
"$project" --branch=$branch
fi
local_bin="$HOME/bin"
remote_bin="$project/bin-shared"
if [[ -d "$local_bin" ]]; then
log "\n`date` - Found '$local_bin', adding scripts.\n"
cp -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/raw/branch/main/refactor_music_library.sh
mv -v $refactor_script "$local_bin"/
chmod 755 -Rv "$local_bin"
else
echo "Did not find '$local_bin', did not copy scripts."
fi
log "\n`date` - Complete!"
}
alias shared-update2="update-shared2"
alias reload-shared2="update-shared2"
alias shared-reload2="update-shared2"
alias update-shared="update-shared2"
alias shared-update="update-shared"
alias reload-shared="update-shared"
alias shared-reload="update-shared"
function reload-all {
log "`date` - Reloading BASH"
reload-bash
log "\n`date` - Reloading Main (Termux/Ansible)"
if [[ -d /sdcard ]]; then
reload-termux
else
scm.sh
fi
reload-bash
log "\n`date` - Reloading Shared"
reload-shared
reload-bash
}
alias all-reload="reload-all"
function update-all {
log "`date` - Updating env projects..."
reload-all
log "\n\n\n`date` - Running system updates..."
update -y
if [[ $(type -t update-sdk 2>/dev/null 1>&2) ]]; then
log "\n\n\n`date` - Updating SDKs..."
update-sdk
fi
log "\n\n\n`date` - Done with update-all!"
}
alias all-update="update-all"
# Shortcuts #
function send-master { send_master.sh; }
@@ -99,6 +209,25 @@ function clone {
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.
@@ -139,7 +268,22 @@ function sync-all {
echo "- $dir"
done
echo -e "`date` - \nDone."
echo -e "`date` - Done.\n"
}
function sync-all-loop {
typeset -i sleep_time
if [[ "$1" ]]; then
sleep_time="$1"
fi
if [[ -z "$sleep_time" || "$sleep_time" == 0 ]]; then
sleep_time="300"
fi
log "`date` - Sleep timer set for '$sleep_time' seconds."
while true; do
sync-all
echo -e "\n\n*** Sleeping... ***\n\n"
sleep 300
done
}
# SYNC folders.
@@ -284,9 +428,11 @@ function process-video {
mv -v ffmpeg2pass*.log* ~/TRASH/
fi
echo "`date` - Syncing data."
sync
sleep 10
sync
if [[ -s $newfile ]]; then
echo "`date` - Getting file sizes."
du -h "$file"
@@ -299,7 +445,7 @@ function process-video {
return $status
}
alias pv="process-video"
alias qpv="pv ./raw/YouCut*.mp4 `basename $(pwd)`.mp4"
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.
@@ -400,9 +546,46 @@ alias vta="v2a"
alias pull-audio="v2a"
alias pa="v2a"
## Trash Related ##
TRASH_ROOT="/"
if [[ -d "/sdcard" ]]; then
# Android / Termux
TRASH_ROOT="/sdcard"
else
# Desktop
TRASH_ROOT="$HOME"
fi
TRASH="$TRASH_ROOT/TRASH"
alias trash="cd $TRASH"
alias clean-trash="bash -c 'rm -rfv "$TRASH"/*'; clean-trashed"
alias trash-clean="clean-trash"
alias check-trash='du -h $TRASH; find "$TRASH_ROOT" -name .Trash"*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \;'
alias trash-check="check-trash"
alias check-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \; | sort -h'
alias clean-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -delete | sort -h'
## Finalize ##
# Export all functions! #
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
# Run update checker in background.
( if [[ -d "$project" ]]; then
git -C "$project" fetch >/dev/null 2>&1 && git -C "$project" status | grep "is behind" \
| while read status; do
log "\n\n`date` - env-shared has been improved."
log " '$status'"
log "\n\n`date` - Run 'update-shared' to update."
done
fi & )
## Complete! ##