diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-05-04 09:19:40 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-05-04 09:19:40 +0200 |
commit | 41712f9a97da7ee3c98ccbc6a17e119c09d0b7e2 (patch) | |
tree | 9e837a156fc2af20b2149bd857755d29c8e15881 /config/essentials/shell/functions.sh | |
parent | d1fd4c1c04b9fefcdaa21d18b0262c2a700847a9 (diff) | |
parent | 80462e764abf047544be6026c5d67c1f54599ae5 (diff) |
Merge branch 'main' of debuc.com:dotfiles
Diffstat (limited to 'config/essentials/shell/functions.sh')
-rw-r--r-- | config/essentials/shell/functions.sh | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 3078f46..1fd6e92 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -296,6 +296,15 @@ edit_in_dir() { $EDITOR "$file" } +# Download a file from google drive +# link like this: https://drive.usercontent.google.com/download?id=1TiJDEftTtF1KTMBI950Bj487ndYqkwpQ&export=download +gdown () { + agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '0-1' | cut -c1).0.0.0 Safari/537.36" + uuid=$(curl -sL "$1" -A "$agent" | sed -nE 's|.*(uuid=[^"]*)".*|\1|p') + aria2c -x16 -s16 "$1&confirm=t&$uuid" -U "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" --summary-interval=0 -d "${2:-.}" +} + +# toggle wireguard vpn on $1 -> interface wgtoggle() { d="${1:-wg0}" ip -br a | awk '{print $1}' | grep "$d" > /dev/null && @@ -303,9 +312,34 @@ wgtoggle() { doas wg-quick up "$d" } +# serve a file through dufs serve() { - docker container run \ - --rm \ - --volume "$(readlink -f "$1")":/data \ - --publish 80:5000 sigoden/dufs:latest /data --allow-all + if [ "$1" ] + then + logn "Serving $1" + docker container run \ + --rm \ + --volume "$(readlink -f "$1")":/data \ + --publish 80:5000 sigoden/dufs /data + else + + logn "Receiving files.." + docker container run \ + --rm \ + --volume /tmp/data:/data \ + --publish 80:5000 sigoden/dufs /data --allow-upload + fi +} + +ssh_keyadd() { ssh-keygen -f "$HOME"/.ssh/"$1" -P "$(pass generate -f keys/"$HOST"/ssh/"$1" | tail -n 1)" -t ed25519; } + + +fchange() +{ + [ "$1" ] || return 1 + inotifywait -m -e create,modify,delete --format "%f" "${2:-.}" | + while read -r EVENT + do + eval "$1" + done } |