summaryrefslogtreecommitdiffstats
path: root/.root
diff options
context:
space:
mode:
Diffstat (limited to '.root')
-rw-r--r--.root/tracked2
-rwxr-xr-x.root/usr/local/bin/encrypted6
-rwxr-xr-x.root/usr/local/bin/group-media104
-rwxr-xr-x.root/usr/local/bin/proxyctl16
4 files changed, 120 insertions, 8 deletions
diff --git a/.root/tracked b/.root/tracked
index e89a45f..9e62670 100644
--- a/.root/tracked
+++ b/.root/tracked
@@ -7,9 +7,9 @@
/usr/local/bin/grub-update
/usr/local/bin/encrypted
/usr/local/bin/proxyctl
+/usr/local/bin/group-media
/boot/efi/grub-workaround.sh
-
/etc/default/grub
/etc/mkinitcpio.conf
/etc/pacman.conf
diff --git a/.root/usr/local/bin/encrypted b/.root/usr/local/bin/encrypted
index b3132c6..73e2ff0 100755
--- a/.root/usr/local/bin/encrypted
+++ b/.root/usr/local/bin/encrypted
@@ -9,6 +9,12 @@ encrypted_datasets=("zfsroot/encrypted")
function __mount() {
for i in "${encrypted_datasets[@]}"; do
+ zfs list -o mounted "$i" | grep --quiet yes
+ if [ $? -eq 0 ]; then
+ echo "Dataset $i is already mounted. Skipping."
+ continue
+ fi
+
zfs load-key "$i";
if [ $? -ne 0 ]; then
echo "Error importing the key! Aborting dataset ${i}"
diff --git a/.root/usr/local/bin/group-media b/.root/usr/local/bin/group-media
new file mode 100755
index 0000000..fb253e0
--- /dev/null
+++ b/.root/usr/local/bin/group-media
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+set -e
+
+DIR="."
+INTERACTIVE=0
+VERBOSE=0
+DO_THING=true
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h | --help)
+ echo "this is a script for grouping songs in 1 directory into subdirectories based on album."
+ echo "command line options:"
+ echo -e "\t-h, --help: print this message"
+ echo -e "\t-i, -ii: interactiveness. -i asks whether to create a directory, -ii asks before moving each file"
+ echo -e "\t -v, -vv: verboseness. -v prints all albums, -vv prints all moved files"
+ echo -e "\t-r, --dry-run: do not change anything, only print what would have been done. useless without verboseness."
+ echo -e "\t-d [DIR], --directory [DIR]: working directory for the script"
+ echo -e "I AM NOT responsible for anything that might go wrong in this script"
+ exit 0
+ ;;
+ -d | --directory)
+ if ! test -z "$2"; then
+ DIR="$2"
+ else
+ echo "-d requires a value"
+ exit 1
+ fi
+ shift 2
+ ;;
+ -r | --dry-run)
+ DO_THING=false
+ shift
+ ;;
+ -i)
+ ((++INTERACTIVE))
+ shift
+ ;;
+ -ii)
+ ((INTERACTIVE += 2))
+ shift
+ ;;
+ -v)
+ ((++VERBOSE))
+ shift
+ ;;
+ -vv)
+ ((VERBOSE += 2))
+ shift
+ ;;
+ *)
+ echo "unknown argument: $1"
+ exit 1
+ ;;
+ esac
+done
+
+if ! which eyeD3 &> /dev/null; then
+ echo "eyeD3 must be available in PATH for this script to work. try installing it throug python-pip (or pipx)"
+ exit 1
+fi
+
+for i in "$DIR"/*; do
+ if test -f "$i"; then
+ ALB="$DIR"/$(eyeD3 "$i" | awk '/album:/{$1="";print $0}' | xargs);
+ if test -z "$ALB"; then
+ echo "song \"$i\" does not have an album."
+ continue
+ fi
+ if test 0 -eq $INTERACTIVE; then
+ if $DO_THING; then mkdir -p "$ALB"; fi
+ if test 1 -le $VERBOSE; then
+ echo "made directory $ALB"
+ fi
+ else
+ if ! test -d "$ALB"; then
+ unset cont; read -n 1 -p "mkdir \"$ALB\" ? [Y/n]"
+ echo
+ if [[ $cont =~ ^[Yy]$ ]] || [ -z $cont ]; then
+ if $DO_THING; then mkdir "$ALB"; fi
+ if test 1 -le $VERBOSE; then
+ echo "made directory \"$ALB\""
+ fi
+ fi
+ fi
+ fi
+
+ if test 2 -eq $INTERACTIVE; then
+ unset cont; read -n 1 -p "mv \"$i\" -> \"$ALB\" ? [Y/n]" cont
+ echo
+ if [[ $cont =~ ^[nN]$ ]]; then
+ continue
+ fi
+ fi
+
+ if $DO_THING; then mv "$i" "$ALB"; fi
+ if test 2 -eq $VERBOSE; then
+ echo "moved \"$i\" to \"$ALB\""
+ fi
+ fi
+done
+
+# vim: filetype=bash
diff --git a/.root/usr/local/bin/proxyctl b/.root/usr/local/bin/proxyctl
index d46ec4f..839ef66 100755
--- a/.root/usr/local/bin/proxyctl
+++ b/.root/usr/local/bin/proxyctl
@@ -1,24 +1,24 @@
-#!/bin/env /bin/bash
+#!/bin/bash
. /etc/profile.d/proxy.sh
function proxy_update_config() {
if [ $UID -ne 0 ]; then
echo "This command requires root privileges. Aborting..."
- exit 1
+ return 1
fi
SRCD=/etc/sing-box
${SRCD}/libconfig_to_json.py ${SRCD}/libconfig ${SRCD}/config.json
if [ $? -ne 0 ]; then
echo "Failed to write config. Aborting..."
- exit 1
+ return 1
fi
systemctl restart sing-box
status=$(systemctl status sing-box)
if [ $? -ne 0 ]; then
echo "Failed to start sing-box. Manual intervention needed."
- exit 1
+ return 1
else
echo "Success"
fi
@@ -41,7 +41,7 @@ function __help() {
if [ $# -lt 1 ]; then
echo "insufficient arguments. needed: . provided: $#"
__help
- exit 1
+ return 1
fi
if [ $1 = update ] || [ $1 = reload ]; then
proxy_update_config
@@ -57,9 +57,11 @@ elif [ $1 = start ] || [ $1 = stop ] || [ $1 = enable ] || [ $1 = disable ]; the
echo "Failed to $1 sing-box"
echo "otput of 'systemctl status sing-box':"
echo ${STATUS_TEXT}
- exit ${STATUS}
+ return ${STATUS}
fi
+elif [ $1 = "--help" ] || [ $1 = help ] || [ $1 = "-h" ]; then
+ __help
else
echo "Unknown command."
- exit 1
+ return 1
fi