80 Commits
main ... dev

Author SHA1 Message Date
46e6b205a9 Hide output from .git folder deletion. 2026-03-28 15:17:45 -07:00
ea40967e2b Install the vimrc from shared env project. 2026-03-28 15:13:24 -07:00
86ad8c5b5c Add exports to env setup. 2026-03-28 15:00:41 -07:00
fd227c810c Add verbosity to deleting shared env. 2026-03-28 14:58:23 -07:00
4744d996a1 Fix path to TRASH. 2026-03-28 14:56:48 -07:00
bd0c01fda6 Fix single quote location. 2026-03-28 14:55:44 -07:00
c323748cec Add date to file completion output. 2026-03-28 14:51:51 -07:00
6226d00a1c Change brackets from purple to gray. 2026-03-28 14:49:54 -07:00
f199605915 Remove test code, skip is working now. 2026-03-28 14:48:44 -07:00
6356497cb6 Add more test code to troubleshoot skipping updates. 2026-03-28 14:46:50 -07:00
b7d189af66 Pass reload-termux params to setup.sh. 2026-03-28 14:44:48 -07:00
dbc0a711c4 Add text code to see why skip is not working. 2026-03-28 14:43:21 -07:00
ae636f4fbe Fix deleting shared env project. 2026-03-28 14:39:24 -07:00
42f4ef919f Move now and today t shared env. 2026-03-28 14:24:20 -07:00
2662966098 Move scan to be in shared env. 2026-03-28 14:18:49 -07:00
16ded2672e Move ffmpeg functions to shared. 2026-03-28 14:17:19 -07:00
bd7ac08dfe Move clone and ls aliases to shared. 2026-03-28 13:34:47 -07:00
b1a0586df7 Use source keyword to be more explicit. 2026-03-28 13:24:23 -07:00
09aec0e5d0 Move sourcing shared RC to beginning so variables are available. 2026-03-28 13:22:24 -07:00
891822aad3 Remove extra newline. 2026-03-28 13:04:36 -07:00
6d728dd9ad Fix PS1 prompts to use single quotes and remove colors since they are in env-shared. 2026-03-28 12:09:13 -07:00
f0a2c39bf8 Try fixing ability to skip. 2026-03-28 11:33:22 -07:00
132ae721e7 Add custom PS1 settings. 2026-03-28 11:28:29 -07:00
d25e94d267 Add tput to Termux environment for changing PS1 colors. 2026-03-28 11:28:12 -07:00
226aa5dd6d Add local bin to PATH if it exists. 2026-03-27 18:50:25 -07:00
b8e4b9bfc3 Add code to install env-shared. 2026-03-27 18:49:02 -07:00
83f3288031 Change the order of the variables and add a DIR for the data server. 2026-03-27 18:36:30 -07:00
a8952795bd Change setup.sh to use renamed example.env which has now been created. 2026-03-27 17:31:04 -07:00
9bde085ab4 Change PROD_NAME to PROD_HOST to be more specific. 2026-03-27 17:26:07 -07:00
7e7214eaf7 Add an example file for .env setup as well as new env variables. 2026-03-27 17:25:21 -07:00
ab396a9739 Change bye to be a function. Add spaces to the end of some aliases. Fix indentation to consistently be tabs. 2026-03-27 17:13:14 -07:00
abc56b57cd Add loading the shared RC config if it exists. 2026-03-23 12:17:20 -07:00
68fea2f314 Try fixing the qpv video getting named 'home.mp4'. 2026-01-26 13:58:06 -07:00
7237184456 Add a newline to Termux code-check. 2026-01-09 17:40:55 -07:00
ee651659aa Also pull recordings and cropped photos. 2026-01-09 08:10:13 -07:00
aa5a6e7b77 Improve and streamline video production aliases. 2026-01-08 17:42:40 -07:00
0485f27205 Add baller alias to easily transcode the video with the proper name. 2026-01-08 17:34:23 -07:00
f811070949 Add shortcut to pull memetastic icons. Add shortcut to pull all content types at once. 2026-01-08 17:18:47 -07:00
1e3f6a7402 Fix pulling screenshots and youcuts. /sdcard/ works way better than storage/shared/. 2026-01-08 17:11:22 -07:00
37db32a78b Build ss alias without leaving current directory. 2026-01-04 20:09:46 -07:00
40af484ddd Remove duplicated code. Something weird happened to this file? 2026-01-04 20:06:21 -07:00
fa98b50827 Remove bad text, again. Squircle not working properly. 2026-01-04 20:01:45 -07:00
7f9494411b Remove bad text. 2026-01-04 19:57:28 -07:00
1957f4fdab -m 2026-01-04 17:16:31 -07:00
14d8a61f49 -m 2026-01-04 17:10:27 -07:00
07ca207fd1 -m 2026-01-04 16:59:50 -07:00
0494b05bb7 -m 2026-01-04 16:51:08 -07:00
55102cc9fd Add the load-branch command from desktop env project env-ansible. 2026-01-03 14:34:12 -07:00
4d740d7d2f Add rsync to package list. 2025-11-30 17:59:39 -07:00
080669359a Add clone alias from env-ansible project. 2025-11-30 17:46:49 -07:00
4cfeb6073c Add missing params variable to final update command. 2025-11-25 07:28:10 -07:00
74bdd45ef7 Add sort. 2025-10-24 15:25:59 -07:00
98fc25a132 Bring over enhancements and fixed from Ansible side. 2025-10-24 15:19:54 -07:00
a0962cb04d Add more aliases for reloading shell. 2025-10-24 14:55:26 -07:00
e85947cb0c Additional enhancements to pulling Production backups. 2025-10-24 14:53:41 -07:00
3c285298eb Add more output. 2025-10-23 20:02:49 -07:00
a9c9f3b784 Add check on whether any zips were successful. 2025-10-23 19:59:52 -07:00
53fbb829a3 Properly handle removing the failed files. 2025-10-23 19:50:49 -07:00
28219c97ed Add production backup pulling logic to Termux from Ansible. 2025-10-23 19:47:03 -07:00
876a106ea0 Add ls alias for only showing size, not all the file data. 2025-10-14 08:18:24 -07:00
3554a40622 All ll for Android. 2025-10-14 07:15:36 -07:00
b0fcdb9429 Add trailing folder to SS. Add sorting on check-trashed. 2025-10-09 07:32:12 -07:00
0a26a3b3e8 Change ss to no longer use ~. 2025-10-09 07:19:17 -07:00
663079c0cd Change trashed commands to hit the main Android storage. 2025-10-09 07:16:04 -07:00
33c60504bd Add methods to easily start a video project and pull files over. 2025-10-09 07:06:47 -07:00
a5791e2bc6 Add 'trashed*' file cleanup for Android. 2025-10-09 06:59:27 -07:00
3763fc6000 Add a comment to explain the swap between commands. 2025-09-16 13:57:38 -07:00
49d9c95c85 Alter the update function and move / edit some of its aliases. 2025-09-16 13:55:51 -07:00
6220e70480 Add TODO for changing apt to pkg. 2025-09-16 10:32:46 -07:00
2324acb6d6 Allow skipping the pkg commands. 2025-08-14 16:36:43 -07:00
e27924f062 Only delete the project if deleteme is in the name. 2025-08-14 16:26:23 -07:00
d3dc527b26 -m 2025-08-14 16:21:17 -07:00
7ceb1f436b Add Code directory and some helpers to seed and sync it. 2025-08-14 16:12:04 -07:00
8ef92669cd Add scanning alias for analyzing network systems. 2025-07-23 05:49:19 -07:00
d793218215 Add extra switches to dist-upgrade like on desktop. 2025-01-03 12:32:11 -07:00
bb0bcc27c8 Upgrade the update alias to a function like done for desktops. 2025-01-03 12:23:27 -07:00
bdd7e7855b Modify project to use Gitea URLs. 2025-01-03 11:59:53 -07:00
060a3b25d8 Add zip!! 2025-01-01 12:44:27 -07:00
6b3975176a Fix videos not compressing properly. 2024-07-05 12:31:17 -07:00
67ef7d128f Allow old usage of making the video bitrate something specific. 2024-07-03 18:28:37 -07:00
5 changed files with 337 additions and 250 deletions

View File

@@ -7,7 +7,7 @@ Hyperling's scripts for a productive Termux environment.
1. Download the repository. 1. Download the repository.
```sh ```sh
git clone https://github.com/Hyperling/Termux termux git clone https://git.hyperling.com/me/env-termux env-termux
``` ```
1. Dive into the directory. 1. Dive into the directory.

459
bashrc.sh
View File

@@ -1,30 +1,49 @@
# 2024-02-10 Hyperling # 2024-02-10 Hyperling
## Environment Setup ##
export PATH="~/bin:$PATH"
if [[ -e ~/.env ]]; then if [[ -e ~/.env ]]; then
source ~/.env source ~/.env
fi fi
if [ -f ~/.rc_shared ]; then
source ~/.rc_shared
fi
# PS1
# This helps to determine the color palette numbers:
# https://robotmoon.com/bash-prompt-generator/
# Colors are in env-shared.
if [[ "`whoami`" == "root" ]]; then
export PS1='\[$BOLD\]\[$ORANGE\][\[$SCARLET\]\t \[$RED\]\w\[$ORANGE\]]\[$GRAY\]\$ \[$RESET\]'
else
export PS1='\[$BOLD\]\[$GRAY\][\[$ORANGE\]\t \[$GREEN\]\w\[$GRAY\]]\[$RESET\]\$ '
fi
## Aliases ## ## Aliases ##
# Quickly log onto production server. # Quickly log onto production server.
# Setting up ssh-keygen and ssh-copy-id make this even faster! # Setting up ssh-keygen and ssh-copy-id make this even faster!
if [[ -n $PROD_PORT && -n $PROD_USER && -n $PROD_NAME ]]; then if [[ -n $PROD_PORT && -n $PROD_USER && -n $PROD_HOST ]]; then
alias prod="ssh -p $PROD_PORT $PROD_USER@$PROD_NAME" alias prod="ssh -p $PROD_PORT $PROD_USER@$PROD_HOST"
else else
alias prod="echo 'ERROR: .env not set up properly, please fix and reload RC.'" alias prod="echo 'ERROR: .env not set up properly, please fix and reload RC.'"
fi fi
# Quickies
alias reload-bash="source ~/.bashrc"
alias bash-reload="reload-bash"
alias reload="reload-bash"
# Easily get to storage devices. # Easily get to storage devices.
export SS="~/storage/shared" curr="`pwd`"
cd
cd storage/shared
#export SS="`pwd`"
export SS="/sdcard"
cd
alias ss="cd $SS" alias ss="cd $SS"
alias sd="ss" alias sd="ss"
alias storage="ss" alias storage="ss"
alias home="ss" alias home="ss"
cd "$curr"
# Shortcut to media. # Shortcut to media.
export DCIM="$SS/DCIM/Camera" export DCIM="$SS/DCIM/Camera"
@@ -37,146 +56,74 @@ alias code="cd $CODE"
# Shortcuts for TRASH. # Shortcuts for TRASH.
export TRASH="$SS/TRASH" export TRASH="$SS/TRASH"
alias trash="cd $TRASH" alias trash="cd $TRASH"
alias clean-trash="bash -c 'rm -rfv $TRASH/*'" alias clean-trash="bash -c 'rm -rfv $TRASH/*'; clean-trashed"
alias trash-clean="clean-trash" alias trash-clean="clean-trash"
alias check-trash="du -h $TRASH" alias check-trash="du -h $TRASH"
alias trash-check="check-trash" alias trash-check="check-trash"
alias clean-trashed='find "$SS" -name ".trashed*" -exec du -h {} \; -delete | sort -h'
alias check-trashed='find "$SS" -name ".trashed*" -exec du -h {} \; -exec mv -v {} ~/TRASH/ \; | sort -h'
# Help prevent mistakes. # Help prevent mistakes.
alias cp="cp -v " alias cp="cp -v "
alias mv="mv -v " alias mv="mv -v "
alias rm="echo 'Move to ~/storage/shared/TRASH/ instead!'" alias rm="echo 'Move to ~/storage/shared/TRASH/ instead!'"
# Quickies # Quickies
alias update="pkg update && pkg upgrade" function bye { exit; }
alias bye="exit"
alias goodbye="update -y && bye"
alias install="pkg install " alias install="pkg install "
alias uninstall="pkg uninstall "
alias remove="uninstall "
## Functions ##
# Optimize the bitrate and audio levels for an edited video. ### Functions ###
function process-video-usage {
echo "USAGE: process-video oldFile newFile [videoBitrate] [audioBitrate] [sizeRating]" ## Code Related ##
echo -n "Purpose: Call ffmpeg with preferred video posting settings. "
echo -n "Bitrates default to 2000k and 192k, size is 720. " function code-projects {
echo "These work well on Odysee and are fairly small as backups." cat <<- EOF
echo "Examples:" env-termux dev
echo "- Create a small file for quick streaming." env-ansible dev
echo " process-video youcut.mp4 20240210.mp4 1200k 128k 480" env-docker dev
echo "- Create a larger file for something like YouTube." nodejs-website dev
echo " process-video youcut.mp4 20240210_1080p.mp4 5000k 256k 1080" hugo-jackanope main
EOF
} }
function process-video { function code-reseed {
# Parameters cd ~/Code
file="$1" code-projects | while read project branch; do
newfile="$2" git clone ssh://git@$GIT_SERVER:$GIT_PORT/$GIT_USER/$project --branch $branch --recurse-submodules
video="$3" done
audio="$4" }
size="$5" alias reseed-code="code-reseed"
passes="$6"
# Validations function check-code {
if [[ -z $file || ! -e $file ]]; then cd ~/Code
echo "ERROR: Original file '$file' does not exist." >&2 ls | while read project; do
process-video-usage echo -e "\nChecking $project..."
return 1 cd $project
fi if [[ -d .git ]]; then
git pull
if [[ -z $newfile ]]; then git push
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
video="-maxrate $video"
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 else
echo "ERROR: New file not created or has a 0 size." >&2 echo "* Not a valid git project, skipping."
fi fi
cd ..
echo -e "\n`date` - Finished with status '$status'." done
return $status
} }
alias pv="process-video" alias code-check="check-code"
# Quickly commit code to a repo. # Quickly commit code to a repo.
function commit { function commit {
message="$1" message="$1"
if [[ -z $message ]]; then if [[ -z "$message" ]]; then
echo "ERROR: A message is required." >&2 echo "ERROR: A message is required." >&2
echo 'USAGE: commit "My commit message."' >&2 echo 'USAGE: commit "My commit message."' >&2
return 1 return 1
fi fi
if [[ "$1" == "-m" ]]; then
message="$2"
fi
git add . && git commit -m "$message" && git push git add . && git commit -m "$message" && git push
} }
@@ -184,116 +131,202 @@ function commit {
# Otherwise can just source this file unless testing setup.sh. # Otherwise can just source this file unless testing setup.sh.
function test-termux { function test-termux {
sh -c "rm -rf ~/termux-deleteme ~/TRASH/termux-deleteme" 2>/dev/null sh -c "rm -rf ~/termux-deleteme ~/TRASH/termux-deleteme" 2>/dev/null
git clone https://github.com/Hyperling/Termux ~/termux-deleteme --branch=dev git clone https://git.hyperling.com/me/env-termux \
--branch=dev ~/termux-deleteme
chmod 755 ~/termux-deleteme/*.sh chmod 755 ~/termux-deleteme/*.sh
~/termux-deleteme/setup.sh ~/termux-deleteme/setup.sh "$@"
} }
alias reload-termux="test-termux " alias reload-termux="test-termux "
alias termux-test="test-termux " alias termux-test="test-termux "
alias termux-reload="reload-termux " alias termux-reload="reload-termux "
# Allow converting video to audio ad 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" # Pulled from /me/env-ansible, need to make a shared library between it and Termux.
# Change a branch to point at another.
function load-branch {
rcvr="$1" # branch which we want to modify
base="$2" # branch with the changes we want
# Validations if [[ "$rcvr" == "main" ]]; then
if [[ -z $input || ! -e $input ]]; then echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***"
echo "ERROR: Input file '$input' does not exist." >&2
basic-process-usage
return 1 return 1
fi fi
if [[ -z $output ]]; then if [[ -z "$base" ]]; then
echo "ERROR: Output file's name must be provided." >&2 if [[ "$rcvr" == "prod" ]]; then
basic-process-usage base="stage"
return 1 elif [[ "$rcvr" == "stage" ]]; then
elif [[ -e $output ]]; then base="dev"
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 else
echo "No audio normalization is being done." echo "* Unsure which branch to use for '$rcvr'. Please specify."
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 return 1
fi fi
echo "* Base was not specified, using '$base' for '$rcvr'."
else
echo "* Requested pointing '$rcvr' branch to '$base'."
fi
sync echo -e "\n* Ensuring we are on base branch '$base'." &&
echo "`date` - '$output' has been created successfully." git switch "$base" &&
sleep 3 echo -e "\n* Changing pointer for '$rcvr' to '$base'." &&
du -h "$input" git branch -f "$rcvr" "$base" &&
du -h "$output" #echo -e "\n* Switching to branch '$rcvr'." &&
#git switch "$rcvr" &&
echo -e "\n* Forcing push on branch '$rcvr'." &&
git push --force --set-upstream origin "$rcvr" &&
echo -e "\n* Done! Displaying list of remote branches." &&
git ls-remote --heads | sort
echo "`date` - Finished basic-process" if [[ "$base" != "dev" ]]; then
echo -e "\n* Checking if a dev branch exists."
git ls-remote --exit-code --heads origin dev
dev_exists="$?"
if [[ "$dev_exists" == 0 ]]; then
echo -e "\n* Switching back to dev."
git switch dev
elif [[ "$dev_exists" == 2 ]]; then
echo -e "\n* Switching back to main."
git switch main
else
echo "*** ERROR: Unknown status for dev_exists, '$dev_exists'. ***"
fi
fi
echo -e "\n* Verifying which branch we're on."
git branch
}
alias load-prod="load-branch prod"
alias load-stage="load-branch stage"
alias rollback-prod="load-branch prod main"
alias rollback-stage="load-branch stage prod"
alias rollback-dev="load-branch dev stage"
alias reset-prod="load-branch prod main"
alias reset-stage="load-branch stage main"
alias reset-dev="load-branch dev main"
## Termux Related ##
function update {
params="$1"
echo "******* Apt / Pkg *******" &&
echo "*** Update Cache ***" &&
apt update &&
echo -e "\n*** Auto Remove ***" &&
apt autoremove $params &&
echo -e "\n*** Clean ***" &&
pkg clean $params &&
echo -e "Cleaned!\n\n*** Fix Broken/Missing ***" &&
apt --fix-broken --fix-missing install &&
echo -e "\n*** Upgrade ***" &&
# No longer using `apt`, in favor of Termux's wrapper `pkg`.
#apt dist-upgrade --allow-downgrades --fix-broken --fix-missing $params &&
pkg upgrade $params
echo -e "\n******* Mission Complete!! *******"
}
alias upgrade="update"
alias goodbye="update -y && bye"
## Video Related ##
alias pull-content="mv -v $SS/DCIM/Camera/`date +"%Y-%m-%d"`* ./raw/"
alias pull-screenshots="mv -v $SS/Pictures/Screenshots/* ./raw/"
alias pull-screenshot="pull-screenshots"
alias pull-sc="pull-screenshots"
alias pull-crops="mv -v $SS/Documents/*/`date +"%Y%m%d"`*.{jpg,png} ./raw/"
alias pull-youcuts="mv -v $SS/Movies/youcut/* ./raw/"
alias pull-youcut="pull-youcuts"
alias pull-yc="pull-youcut"
alias pull-memes="mv -v $SS/Pictures/memetastic/memes/*.jpg ./"
alias pull-meme="pull-memes"
alias pull-icon="pull-meme"
function init-video-contents {
if [[ -n "$1" ]]; then
mkdir "$1"
cd "$1"
fi
touch README.md
#touch title.md
#touch desc.md
#touch tags.md
mkdir -pv raw
}
alias init-video="init-video-contents"
alias init-vid="init-video"
alias initvid="init-vid"
alias mkvid="init-video; pull-content; pull-yc; pull-sc; pull-crops; pull-icon; qpv"
alias mkv="mkvid"
alias qvd="mkv"
alias qv="qvd"
## End Video Section ##
## Backup Related ##
export BACKUP_DIR="/srv/backup"
export DOCKER="Docker"
export SYSTEM="System"
function pull_prod_backup {
if [[ -z "$1" || ("$1" != "$DOCKER" && "$1" != "$SYSTEM") ]]; then
echo "ERROR: Parameter 1 not correct, expecting '$DOCKER' or '$SYSTEM'."
return 1
fi
backup_type="$1"
echo "Looking for '*${backup_type}*.zip'"
ls -lh *${backup_type}*.zip 2>/dev/null
status="$?"
if [[ "$status" == "0" ]]; then
echo "File already downloaded, skipping."
return 0 return 0
} else
alias bp="basic-process" echo "File still needed, downloading to local tmp/."
alias bv="bp"
# Function to automatically append tbe Y.
function fix-audio {
basic-process "$1" Y
}
# 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 fi
volume="" mkdir -pv tmp
if [[ ( "$2" == "Y" && -z "$3" ) || "$3" == "Y" ]]; then scp -P $PROD_PORT \
$volume="Y" $PROD_USER@$PROD_HOST:"$BACKUP_DIR/*${backup_type}*.zip" \
tmp/
if [[ "$?" == "0" ]]; then
echo "Succeeded!"
mv -v tmp/*.zip ./
rmdir -v tmp
else
echo "Failed!"
mv tmp "$TRASH/tmp_`now`"
fi fi
basic-process "$video" "$audio" $volume
} }
alias v2a="convert-to-audio" function pull_prod_backups {
alias vta="v2a" dir="ProductionBackups-Pulled`today`"
alias va="v2a" mkdir -pv "$dir"
alias pa="v2a" cd "$dir"
pull_prod_backup "$DOCKER"
# Go to normal storage. DISABLED, use shortcut aliases instead. pull_prod_backup "$SYSTEM"
#cd ~/storage/shared/ du -h *.zip | sort -h
status="$?"
cd ..
if [[ "$status" != 0 ]]; then
echo "Failed to find zip files, removing folder."
rmdir -v "$dir"
return 1
fi
echo "Done!"
}
alias pull-prod-backups="pull_prod_backups"
alias pull-backups="pull_prod_backups"
alias prod-backups="pull_prod_backups"
alias prod-backup="pull_prod_backups"
alias pull-prod="pull_prod_backups"
alias prod-pull="pull_prod_backups"
# Complete!
PROG="$(basename -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "'$PROG' completed!" echo "`date` - '$PROG' completed!"

View File

@@ -1,9 +0,0 @@
# 2024-02-10 Hyperling
# Variables for a fast-access SSH alias.
PROD_USER=username
PROD_NAME=example.com
PROD_PORT=2222
PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "'$PROG' completed!"

17
example.env Normal file
View File

@@ -0,0 +1,17 @@
# Variables for fast-access of production server.
export PROD_HOST=example.com
export PROD_PORT=2222
export PROD_USER=user
export PROD_GIT_HOST=git.example.com
export PROD_GIT_PORT=8080
export PROD_GIT_USER=git
export PROD_DATA_HOST=sftp.example.com
export PROD_DATA_PORT=2200
export PROD_DATA_USER=data
export PROD_DATA_DIR=/srv/sftp
PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "'`date` - $PROG' completed!"

View File

@@ -9,11 +9,23 @@ cd $DIR
DIR="`pwd`" DIR="`pwd`"
echo "Working in '$DIR'." echo "Working in '$DIR'."
skip="false"
if [[ "$1" == "skip" || "$2" == "skip" || "$3" == "skip" ]]; then
skip="true"
fi
if [[ "$skip" == "true" ]]; then
echo "\n`date` - Skipping Updates"
else
echo -e "\n`date` - Upgrade Package Repos" echo -e "\n`date` - Upgrade Package Repos"
pkg update && pkg update &&
pkg upgrade -y pkg upgrade -y
fi
echo -e "\n`date` - Check Storage Permission" echo -e "\n`date` - Check Storage Permission"
if [[ ! -e ~/storage/shared ]]; then if [[ ! -e ~/storage/shared ]]; then
sleep 3 sleep 3
termux-setup-storage termux-setup-storage
@@ -27,23 +39,30 @@ else
echo "Everything looks good already, pal." echo "Everything looks good already, pal."
fi fi
if [[ "$skip" == "true" ]]; then
echo "\n`date` - Skipping Installs"
else
echo -e "\n`date` - Install Software" echo -e "\n`date` - Install Software"
pkg install -y \ pkg install -y \
openssh tsu vim htop git cronie man \ openssh tsu vim htop git cronie man zip ncurses-utils \
nmap traceroute wget \ nmap traceroute wget rsync \
ffmpeg imagemagick \ ffmpeg imagemagick \
kotlin php nodejs python libllvm kotlin php nodejs python libllvm hugo
fi
echo -e "\n`date` - BASH Environment" echo -e "\n`date` - BASH Environment"
if [[ ! -e ~/.env ]]; then if [[ ! -e ~/.env ]]; then
if [[ -e env.example ]]; then if [[ -e example.env ]]; then
mv -v env.example ~/.env mv -v example.env ~/.env
else else
echo "ERROR: Neither .env or env.example found." >&2 echo "ERROR: Neither .env or example.env found." >&2
fi fi
else else
echo "'.env' already exists. Good job!" echo "'.env' already exists. Good job!"
rm -v env.example rm -v example.env
fi fi
if [[ -e bashrc.sh ]]; then if [[ -e bashrc.sh ]]; then
@@ -52,7 +71,9 @@ else
echo "ERROR: bashrc.sh not found, skipping." >&2 echo "ERROR: bashrc.sh not found, skipping." >&2
fi fi
echo -e "\n`date` - Cleanup"
echo -e "\n`date` - Directories"
if [[ -d ~/TRASH ]]; then if [[ -d ~/TRASH ]]; then
rm -rfv ~/TRASH rm -rfv ~/TRASH
fi fi
@@ -61,16 +82,41 @@ if [[ ! -e ~/storage/shared/TRASH ]]; then
fi fi
ln -s ~/storage/shared/TRASH ~/TRASH ln -s ~/storage/shared/TRASH ~/TRASH
if [[ -n $DIR && $DIR != "/" && -d .git ]]; then if [[ ! -d ~/Code && ! -d ~/storage/shared/Code ]]; then
mkdir -pv ~/Code
ln -s ~/Code ~/storage/shared/Code
fi
echo -e "\n`date` - env-shared"
env_shared_dir="env-shared-dev-deleteme"
git clone https://git.hyperling.com/me/env-shared \
--branch=dev ~/$env_shared_dir
cp -v ~/$env_shared_dir/rc_shared.sh ~/.rc_shared
cp -v ~/$env_shared_dir/vimrc.vim ~/.vimrc
if [[ ! -d ~/bin ]]; then
mkdir -pv ~/bin
fi
cp -v ~/$env_shared_dir/bin-shared/* ~/bin/
mv -v ~/$env_shared_dir \
~/TRASH/$env_shared_dir-"`date "+%Y%m%d-%H%M%S"`" \
| grep -v '/.git/'
echo -e "\n`date` - Cleanup"
if [[ -n $DIR && $DIR != "/" && $DIR == *"deleteme" && -d .git ]]; then
echo "We are in a git clone, remove the project." echo "We are in a git clone, remove the project."
cd .. cd ..
mv -v $DIR ~/TRASH/termux-"`date +'%Y%m%d%H%M%S'`" | mv -v $DIR \
grep -v '/.git/' ~/TRASH/termux-"`date +'%Y%m%d%H%M%S'`" \
| grep -v '/.git/'
else else
echo "File was used individually, remove it." echo "File was used individually, remove it."
mv "$PROG" ~/TRASH/ mv "$PROG" ~/TRASH/
fi fi
echo -e "\n*******" echo -e "\n*******"
echo "Don't forget to reload your environment!" echo "Don't forget to reload your environment!"
echo " source ~/.bashrc" echo " source ~/.bashrc"