Verified Commit 9d425864 authored by Sofus Albert Høgsbro Rose's avatar Sofus Albert Høgsbro Rose
Browse files

Added more scripts!

parent 7bc41443
......@@ -3,8 +3,19 @@
## Literally a little cache of little little-scripts!
These are little tools that help my life along. Run each with -h for deeper info:
These are little tools for everyday life.
*Requires standard Linux tools - python3, rsync, tar - to work, as a general rule!*
### General Tools:
-**linkPath**: Call with sudo; automatically links (or deletes a link with -d) an executable to /usr/local/bin, removing any extension.
-**syncGate**: Rsync through an ssh gateway using ssh agent forwarding. Call with gateway, target, target path, and optionally local path!
### **Requires gpg**
-**enc**: Pipe anything in, and it will encrypt it (as text) for given recipients and output on stdout.
* Pipe into `xclip -selection c` to automatically copy to clipboard!
-**decr**: Pipe encrypted data in (like from `xclip -o`), and it will check sigs & decrypt it to stdout.
### **Requires ffmpeg**
......@@ -14,4 +25,4 @@ These are little tools that help my life along. Run each with -h for deeper info
### **Requires djv-view**
-**sek**: The universal sequence viewer! Point sek at directories & MOVs alike - it'll open up djv-view to play it!
-**sek**: The universal sequence viewer! Point sek at directories & videos alike - it'll open up djv-view to play it.
#!/bin/bash
# Decrypt any message you're able to. Shows signature status too.
supp=false
binData="--armor"
help() {
less -R << EOF
Usage:
other program | $(echo -e "\033[1m./decr.sh\033[0m [OPTIONS]")
PATTERN GUIDELINES:
Decrypts PGP encrypted text and binary data easily, and prints decrypted data to stdout.
OPTIONS:
-s suppress - Only show decrypted message on stdout; suppressed stderr.
-b binary - Incoming data is treated as binary data.
EOF
}
while getopts "vh s b" opt; do
case "$opt" in
h)
help
exit 0
;;
v)
echo -e "See decr.sh -h"
exit 0
;;
s)
supp=true
;;
b)
binData=""
;;
*)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
if test -t 0; then help; exit 1; fi
if [[ $supp == "false" ]]; then
gpg --decrypt --output - $binData /dev/stdin
else
gpg --decrypt --output - $binData /dev/stdin 2>/dev/null
fi
#!/bin/bash
#Creates a signed message for the argument from stdin and writes to stdout. Use in a pipe.
RECIP="-r sofus@sofusrose.com"
binData="--armor"
help() {
less -R << EOF
Usage:
other program | $(echo -e "\033[1m./enc.sh\033[0m -r <recipient> ...optional repeat... [OPTIONS]")
PATTERN GUIDELINES:
Encrypts data using your PGP private key, printing encrypted data to stdout.
OPTIONS:
-r recipient - Specify a recipient, who will be the only person able to decrypt the message.
*Multiple -r's = multiple recipients
-b binary - Binary data is outputted.
EOF
}
while getopts "vh r: b" opt; do
case "$opt" in
h)
help
exit 0
;;
v)
echo -e "See decr.sh -h"
exit 0
;;
r)
RECIP+=" -r ${OPTARG}"
;;
b)
binData=""
;;
*)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
if test -t 0; then help; exit 1; fi
gpg --encrypt --sign $binData $RECIP --output - /dev/stdin > /dev/stdout
#!/bin/bash
# Link (or unlink) an executable to your PATH.
lPath="/usr/local/bin"
delete=false
help() {
less -R << EOF
Usage:
other program | $(echo -e "\033[1m./linkPath.sh\033[0m [OPTIONS] executable")
PATTERN GUIDELINES:
Links the specified executable to PATH (/usr/local/bin), removing any extensions (like .sh).
OPTIONS:
-s sbin - Put the program in /usr/local/sbin instead of /usr/local/bin.
-d delete - The program already at PATH (bin or sbin) will be removed.
*Won't touch the real program.
EOF
}
while getopts "vh s d" opt; do
case "$opt" in
h)
help
exit 0
;;
v)
echo -e "See decr.sh -h"
exit 0
;;
s)
lPath="/usr/local/sbin"
;;
d)
delete=true
;;
*)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift $((OPTIND-1))
exPath="$1"
filename=$(basename "$exPath")
name="${filename%.*}"
if [[ $delete == "true" ]]; then
rm "$lPath/$name"
if [ $? -eq 0 ]; then echo "Removed executable at $lPath/$name !"; fi
exit 0
fi
absPath() {
#Depends python3.
python3 -c "import os; print(os.path.abspath('$1'));"
}
ln -s $(absPath "$exPath") "$lPath/$name"
if [ $? -eq 0 ]; then echo "Linked executable to $lPath/$name !"; fi
#!/bin/bash
#Usage: ./rsyncGate.sh GATEWAY TARGET TARGET_PATH (optional) LOCAL_PATH
# GATEWAY is the gateway user@hostname.
# TARGET is the target user@hostname, from the perspective of the gateway.
# TARGET_PATH is the path to copy over from the target machine.
# LOCAL_PATH is the path to copy to on the local machine. Defaults to current dir.
GATEWAY=$1
TARGET=$2
TARGET_PATH=$3
LOCAL_PATH=$4
if [[ -z $LOCAL_PATH ]]; then LOCAL_PATH="."; fi
rsync -avuz --stats --progress -e "ssh -A $GATEWAY ssh" $TARGET:$TARGET_PATH $LOCAL_PATH
#!/bin/bash
#Switches back to the normal pulseaudio driver from the jack server that's started at login.
jack_control exit && pulseaudio -k && pulseaudio -D
#!/bin/bash
#Some sourceable utilities.
absPath() {
#Depends python3.
python3 -c "import os; print(os.path.abspath('.'));"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment