Compare commits

...

73 Commits

Author SHA1 Message Date
7a53a8ced6 Add quotes to variable in conditional. 2026-05-08 10:39:04 -07:00
c7d2dafa11 Hopefully fix the reason that the shared rc has not always been updating correctly. 2026-05-06 18:01:56 -07:00
13c22faa9d Put the file extension on the wrong side. :) 2026-05-06 17:57:28 -07:00
ee325db486 Change log files to txt files because Android file haanddler is dumb. 2026-05-06 17:55:05 -07:00
4a13b5cea8 Add note that bash will still need reloaded after automatic updates, lol. 2026-05-06 17:50:29 -07:00
e063f4c4b7 Double wrap the updater commands so that the DONE code does not appear in the terminl. 2026-05-06 17:48:24 -07:00
deffc60730 Remove old terminal output ommands fior updater. 2026-05-06 17:47:16 -07:00
032fa387b6 Fix the report location. 2026-05-06 17:37:04 -07:00
487399e18f Try fixing the notification message from being TBD/TBD. 2026-05-06 17:36:27 -07:00
d3a5bbc9c3 Try to do the output redirect a different way, fork at the very very end,. 2026-05-06 17:34:17 -07:00
0d450e9172 Try to fix auto-update notification as well as output. 2026-05-06 17:28:48 -07:00
4ee3dc69c9 Remove the middle sorts which threw a weird error. 2026-05-06 17:22:05 -07:00
de1628353f Add filesize sorting to trash checking. 2026-05-06 17:15:30 -07:00
6c5dc2c8bf Also add copy of the vimrc file. 2026-05-06 17:11:25 -07:00
9f9cdf0361 Add missing copy of rc_shared, as well as some comments. 2026-05-06 17:10:22 -07:00
facb2836c9 Just auto update, yo! 2026-05-06 16:49:14 -07:00
142317d46b Fix typo in Update. 2026-05-06 16:46:30 -07:00
000c52417c Fix the '$project' variable being shared across environments incorrectly. 2026-05-06 15:24:32 -07:00
3f74195968 Shorten the message. 2026-05-06 15:06:59 -07:00
a28d00d3ad Only show the changed permissions. 2026-05-06 15:02:09 -07:00
5a7bd88c70 Ensure path is quoted just in case. 2026-05-06 14:57:30 -07:00
aec0449ed2 No longer push the update information to the screen, use notifications. 2026-05-06 14:50:33 -07:00
bcfde6c172 Hide the .git dir deletion. 2026-05-06 10:26:45 -07:00
d49116a884 Remove the old project as not to clutter the home directory. 2026-05-06 09:33:49 -07:00
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
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
4 changed files with 378 additions and 59 deletions

View File

@@ -1,47 +0,0 @@
#!/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

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

@@ -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,13 +60,21 @@ 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"
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"
git clone https://git.hyperling.com/me/env-shared \
@@ -60,17 +82,136 @@ 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 -Rc "$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_SHARED="$HOME/.git-env-shared"
function update-shared2 {
# Refresh the local env-shared repo.
if [[ -d $PROJECT_SHARED ]]; then
log "`date` - Updating '$PROJECT_SHARED'.\n"
git -C "$PROJECT_SHARED" switch "$branch"
git -C "$PROJECT_SHARED" pull --recurse-submodules || \
( echo "Failed to pull project, exiting." && return 1 )
else
log "`date` - Downloading '$PROJECT_SHARED'.\n"
git clone https://git.hyperling.com/me/env-shared \
"$PROJECT_SHARED" --branch=$branch
fi
# Tha main piece! Reload the shared RC file.
cp -v "$PROJECT_SHARED"/rc_shared.sh ~/.rc_shared
cp -v "$PROJECT_SHARED"/vimrc.vim ~/.vimrc
# Copy the scripts from the shared bin to the home bin.
local_bin="$HOME/bin"
remote_bin="$PROJECT_SHARED/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 -Rc "$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"
PROJECT_SHARED_OLD01="$HOME/.env-shared"
if [[ -d "$PROJECT_SHARED_OLD01" ]]; then
log "`date` - Removing old project name '$PROJECT_SHARED_OLD01'."
mv -v "$PROJECT_SHARED_OLD01" "$TRASH"/env-shared-deleteme | grep -v ".git"
fi
# 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 {
@@ -80,18 +221,117 @@ 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.
function send-masters {
echo -e "`date` - Looping through MASTER directories.\n"
ls | grep MASTER | while read dir; do
echo -e "`date` - Found '$dir'..."
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."
}
alias push-masters="send-masters"
alias sync-masters="send-masters"
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"
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` - 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.
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 #
@@ -200,9 +440,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"
@@ -215,7 +457,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.
@@ -316,9 +558,67 @@ 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 | sort -h; 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_SHARED" ]]; then
git -C "$PROJECT_SHARED" fetch >/dev/null 2>&1 \
&& git -C "$PROJECT_SHARED" status \
| grep "is behind" \
| while read status; do
title=TBD
message=TBD
success=0
reload-shared || success=1
if [[ "$success" == 0 ]]; then
title="env-shared Updated"
message="Reloaded automatically, please reload BASH. :)"
else
title="env-shared Updates Available"
message="Update with 'reload-shared'."
fi
if [[ -d /sdcard ]]; then
termux-notification \
-t "$title" \
-c "$message"
else
notify-send "$title" "$message"
fi
done
fi
) >> "$HOME"/Reports/env-shared.log.txt 2>&1 &
)
## Complete! ##