Initialize files.
This commit is contained in:
parent
79f24cb223
commit
f1887073ec
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Chad
|
||||
Copyright (c) 2024 Hyperling
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
49
README.md
Normal file
49
README.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Termux Setup
|
||||
|
||||
Hyperling's scripts for a productive Termux environment.
|
||||
|
||||
# Install / How To Use
|
||||
|
||||
1. Download the repository.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/Hyperling/Termux termux
|
||||
```
|
||||
|
||||
1. Dive into the directory.
|
||||
|
||||
```sh
|
||||
cd termux
|
||||
```
|
||||
|
||||
1. Ensure all files can be executed.
|
||||
|
||||
```sh
|
||||
chmod 755 *.sh
|
||||
```
|
||||
|
||||
1. Make any modifications to the env.example file
|
||||
- Only if you do not already have a ~/.env file
|
||||
|
||||
1. Run the deployment script.
|
||||
|
||||
```sh
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
1. All done!
|
||||
|
||||
# Updates
|
||||
|
||||
Each program is developed to be run numerous times, so all that needs done is following the Install instructions again.
|
||||
|
||||
# Development
|
||||
|
||||
Since the project self-destructs, it is recommended to copy the folder for each run, then execute the copied files.
|
||||
|
||||
```sh
|
||||
cp -r ../termux ~/termux-copy
|
||||
cd ~/termux-copy
|
||||
chmod 755 *.sh
|
||||
./setup.sh
|
||||
```
|
86
bashrc.sh
Normal file
86
bashrc.sh
Normal file
@ -0,0 +1,86 @@
|
||||
# 2024-02-10 Hyperling
|
||||
|
||||
if [[ -e ~/.env ]]; then
|
||||
source ~/.env
|
||||
fi
|
||||
|
||||
## Aliases ##
|
||||
|
||||
# Quickly log onto production server.
|
||||
# Setting up ssh-keygen and ssh-copy-id make this even faster!
|
||||
if [[ -n $PROD_PORT && -n $PROD_USER && -n $PROD_NAME ]]; then
|
||||
alias prod="ssh -p $PROD_PORT $PROD_USER@$PROD_NAME"
|
||||
else
|
||||
alias prod="echo 'ERROR: .env not set up properly, please fix and reload RC.'"
|
||||
fi
|
||||
|
||||
# Easily get to storage device.
|
||||
export SS="~/storage/shared/"
|
||||
alias ss="cd $SS"
|
||||
alias sd="ss"
|
||||
alias storage="ss"
|
||||
alias home="ss"
|
||||
|
||||
# Help Prevent Mistakes
|
||||
alias cp="cp -v"
|
||||
alias mv="mv -v"
|
||||
alias rm="echo 'Move to ~/storage/shared/TRASH/ instead!'"
|
||||
|
||||
## Functions ##
|
||||
|
||||
function process-video-usage {
|
||||
echo "USAGE: process-video oldFile newFile [videoBitrate] [audioBitrate]"
|
||||
echo "Call ffmpeg with preferred video posting settings."
|
||||
}
|
||||
|
||||
function process-video {
|
||||
# Parameters
|
||||
file="$1"
|
||||
newfile="$2"
|
||||
video="$3"
|
||||
audio="$4"
|
||||
|
||||
# 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 || -e $newfile ]]; then
|
||||
echo "ERROR: New file '$newfile' already exists." >&2
|
||||
process-video-usage
|
||||
elif [[ -e $newfile ]]; then
|
||||
echo "ERROR: New file '$newfile' already exists." >&2
|
||||
process-video-usage
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z $video ]]; then
|
||||
video="-b:v 2000k"
|
||||
else
|
||||
video="-b:v $video"
|
||||
fi
|
||||
|
||||
if [[ -z $audio ]]; then
|
||||
audio="-b:a 192k"
|
||||
else
|
||||
audio="-b:a $audio"
|
||||
fi
|
||||
|
||||
echo "`date` - Converting '$file' to '$newfile' using '$video $audio'"
|
||||
|
||||
# Main
|
||||
ffmpeg -nostdin -hide_banner -loglevel quiet \
|
||||
$video $audio -movflags +faststart \
|
||||
-af "dynaudnorm=f=33:g=65:p=0.66:m=33." \
|
||||
-i "$file" "$newfile"
|
||||
status="$?"
|
||||
|
||||
echo -e "\n`date` - Finished with status '$status'."
|
||||
return $status
|
||||
}
|
||||
|
||||
cd ~/storage/shared/
|
||||
|
||||
echo "'$0' completed!"
|
8
env.example
Normal file
8
env.example
Normal file
@ -0,0 +1,8 @@
|
||||
# 2024-02-10 Hyperling
|
||||
|
||||
# Variables for a fast-access SSH alias.
|
||||
PROD_USER=username
|
||||
PROD_NAME=example.com
|
||||
PROD_PORT=2222
|
||||
|
||||
echo "'$0' completed!"
|
73
setup.sh
Normal file
73
setup.sh
Normal file
@ -0,0 +1,73 @@
|
||||
# No Shebang For Termux
|
||||
# 2024-02-10 Hyperling
|
||||
|
||||
echo "`date` - Starting Hyperling's Termux Setup"
|
||||
|
||||
DIR="`dirname $0`"
|
||||
cd $DIR
|
||||
DIR="`pwd`"
|
||||
|
||||
echo -e "\n`date` - Upgrade Package Repos"
|
||||
pkg update &&
|
||||
pkg upgrade
|
||||
|
||||
echo -e "\n`date` - Check Storage Permission"
|
||||
if [[ ! -e ~/storage/shared ]]; then
|
||||
sleep 3
|
||||
termux-setup-storage
|
||||
if [[ -e ~/storage/shared/ ]]; then
|
||||
echo "~/storage/shared/ now exists. :)"
|
||||
else
|
||||
echo "ERROR: Something ain't right, Jim! Abort!" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Everything looks good already, pal."
|
||||
fi
|
||||
|
||||
echo -e "\n`date` - Install Software"
|
||||
pkg install \
|
||||
openssh tsu vim htop git cronie \
|
||||
nmap traceroute \
|
||||
ffmpeg
|
||||
|
||||
echo -e "\n`date` - BASH Environment"
|
||||
if [[ ! -e ~/.env ]]; then
|
||||
if [[ -e env.example ]]; then
|
||||
mv -v env.example ~/.env
|
||||
else
|
||||
echo "ERROR: Neither .env or env.example found." >&2
|
||||
fi
|
||||
else
|
||||
echo "'.env' already exists. Good job!"
|
||||
rm -v env.example
|
||||
fi
|
||||
|
||||
if [[ -e bashrc.sh ]]; then
|
||||
mv -v bashrc.sh ~/.bashrc
|
||||
else
|
||||
echo "ERROR: bashrc.sh not found, skipping." >&2
|
||||
fi
|
||||
|
||||
echo -e "\n`date` - Cleanup"
|
||||
if [[ -d ~/TRASH ]]; then
|
||||
rm -rfv ~/TRASH
|
||||
fi
|
||||
if [[ ! -e ~/storage/shared/TRASH ]]; then
|
||||
mkdir -pv ~/storage/shared/TRASH
|
||||
fi
|
||||
ln -s ~/storage/shared/TRASH ~/TRASH
|
||||
|
||||
cd ..
|
||||
if [[ -n $DIR && $DIR != "/" ]]; then
|
||||
mv -v $DIR ~/TRASH/termux-"`date +'%Y%m%d%H%M%S'`" |
|
||||
grep -v '/.git/'
|
||||
fi
|
||||
|
||||
echo -e "\n*******"
|
||||
echo "Don't forget to reload your environment!"
|
||||
echo " source .bashrc"
|
||||
echo "*******"
|
||||
|
||||
echo -e "\n`date` - Finished Hyperling's Termux Setup"
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user