Chad 742f225de1
General Enhancements (#51)
* Fix website not being trashed during reseed.

* Fix port flags.

* Fix errors about comments by being sneaky.

* Add `encfs`.

* Leave the audio alone when compressing videos unless explicitly requested.

* ffmpeg seems to default to 128k audio, raise it to 192k.

* Handle `time` not being installed more gracefully.

* Add audio normlization per Cahlen Lee.

* Try preventing directories from being renamed.

* Add ability to resize videos, similar to process-video in my Termux project's bashrc.

* Add an -A parameter similar to compress_image.sh.

* Handle uppercase extensions, use TRASH for old compressed copies if it exists, print the FFMPEG command.

* Add datestamps around the conversion.

* Maxrate has been working well in Termux project, use it on desktop too, but don't worry about 2-pass.

* Automatically source Docker environment for using manage.sh if user is root and file exists.

* Add android studio.

* Add missing pipes.

* Stop including Nix, inclue TTT, add git stash to reset.
2024-05-16 10:00:49 -07:00

89 lines
2.2 KiB
Bash

#!/bin/bash
# 2024-01-28 Hyperling
# Make it a little easier to handle IPv6 addresses with SSH and SCP.
## Variables ##
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "Running '$DIR/$PROG'."
# Defaults
user="$LOGNAME"
port=22
output=""
receive="N"
## Functions ##
function usage {
echo -n "$PROG -d DESTINATION [-p PORT] [-u USER] [-i INPUT] "
echo "[-o OUTPUT] [-r] [-h]"
cat <<- EOF
Script around having to sometimes doing "[IPv6]" syntax.
-d : The IP address of the external system to connect to.
-u : User to connect as. Defaults to current user.
-p : Port which the external system is listening on.
-i : File or folder which needs sent. This is done recursively.
If this is not provided then only an SSH is done, not SCP.
-o : Location on the receiving end where things should land.
Defaults to :, meaning the foreign user's home directory.
-r : Receive a file to the local machine, rather than send a file out.
-h : Print this usage text.
EOF
exit $1
}
## Parameters ##
while getopts ":d:u:i:o:rh" opt; do
case "$opt" in
d) destination="$OPTARG" ;;
u) user="$OPTARG" ;;
p) port="$OPTARG" ;;
i) input="$OPTARG" ;;
o) output="$OPTARG" ;;
r) receive="Y" ;;
h) usage 0 ;;
*) echo "ERROR: $OPTARG not recognized." >&2
usage 1;;
esac
done
## Validations ##
if [[ -z $destination ]]; then
echo "ERROR: Destination was not provided. $destination" >&2
usage 2
fi
if [[ -z $input && -n $output ]]; then
echo "ERROR: Output '$output' was provided but not input. $input" >&2
usage 3
fi
## Main ##
date
if [[ -n $input ]]; then
if [[ $receive == "N" ]]; then
echo -n "Sending '$input' from localhost to '$user@$destination' "
echo " at '$output' using port '$port'."
scp -r -P$port "$user@[$destination]":"$input" "$output"
elif [[ $receive == "Y" ]]; then
echo -n "Receiving '$input' from '$user@$destination' "
echo " to '$output' on localhost using port '$port'."
scp -r -P$port "$input" "$user@[$destination]":"$output"
else
echo "ERROR: Receive variable is screwed up. $receive" >&2
fi
else
echo "No input file provided, connecting to destination."
ssh -t -p$port $user@$destination
fi
date
## Finish ##
exit 0