diff options
| -rw-r--r-- | assets/wireguard/switzerlan-zurich1.conf | 15 | ||||
| -rw-r--r-- | assets/wireguard/switzerlan-zurich2.conf | 15 | ||||
| -rwxr-xr-x | dotfiles/system/.local/bin/dab | 72 |
3 files changed, 102 insertions, 0 deletions
diff --git a/assets/wireguard/switzerlan-zurich1.conf b/assets/wireguard/switzerlan-zurich1.conf new file mode 100644 index 0000000..4d7908e --- /dev/null +++ b/assets/wireguard/switzerlan-zurich1.conf @@ -0,0 +1,15 @@ +[Interface] +# Bouncing = 18 +# NetShield = 1 +# Moderate NAT = off +# NAT-PMP (Port Forwarding) = off +# VPN Accelerator = on +PrivateKey = CJSPw7zcMMBDJbQDYlwFvdVcXvvsGns592PiDHmhTks= +Address = 10.2.0.2/32 +DNS = 10.2.0.1 + +[Peer] +# CH#185 +PublicKey = XPVCz7LndzqWe7y3+WSo51hvNOX8nX5CTwVTWhzg8g8= +AllowedIPs = 0.0.0.0/0 +Endpoint = 149.88.27.234:51820
\ No newline at end of file diff --git a/assets/wireguard/switzerlan-zurich2.conf b/assets/wireguard/switzerlan-zurich2.conf new file mode 100644 index 0000000..c2d390f --- /dev/null +++ b/assets/wireguard/switzerlan-zurich2.conf @@ -0,0 +1,15 @@ +[Interface] +# Bouncing = 10 +# NetShield = 1 +# Moderate NAT = off +# NAT-PMP (Port Forwarding) = off +# VPN Accelerator = on +PrivateKey = ACCwCDY+Y+RlSH2dSt+IumCBYAo5Sk4an9eXZKt8jEE= +Address = 10.2.0.2/32 +DNS = 10.2.0.1 + +[Peer] +# CH#177 +PublicKey = XPVCz7LndzqWe7y3+WSo51hvNOX8nX5CTwVTWhzg8g8= +AllowedIPs = 0.0.0.0/0 +Endpoint = 149.88.27.234:51820
\ No newline at end of file diff --git a/dotfiles/system/.local/bin/dab b/dotfiles/system/.local/bin/dab new file mode 100755 index 0000000..e7d0fae --- /dev/null +++ b/dotfiles/system/.local/bin/dab @@ -0,0 +1,72 @@ +#!/bin/env bash +# dab - delete all but +# Craig Jennings <c@cjennings.net> +# deletes all files in current directory that are NOT of a specific extension + +# default switch values +recurse="" +del_dirs="" + +# help function +show_help() { + echo "Usage: $0 [extension] [OPTION]" + echo "Deletes all files that do not match the given extension from the current directory." + echo "" + echo "Options:" + echo "-r Delete files in directories recursively." + echo "-d Delete directories if they become empty after deletions." + echo "-h Display this help message and exit." + echo "" + echo "Example: $0 txt -r -d" + echo "This would delete all non-text files in the current directory and subdirectories. Any directories emptied by this process will also be deleted." + echo "" + echo "Note: Directories that were previously empty will remain untouched." +} + +# if help was requested, show it and exit +if [[ $1 = "-h" ]] || [[ $2 = "-h" ]] || [[ $3 = "-h" ]]; then + show_help + exit +fi + +# error if nothing or * was passed +if [[ -z $1 ]] || [[ $1 = "*" ]]; then + echo "ERROR: No file extension was provided or invalid extension ('*')." + show_help + exit +fi + +# identify rest of arguments +ext=$1 +if [[ $2 == *"-r"* ]] || [[ $3 == *"-r"* ]]; then + recurse="-R" +fi + +if [[ $2 == *"-d"* ]] || [[ $3 == *"-d"* ]]; then + del_dirs="true" +fi + +# Save empty directories into an array before deleting the files +empty_dirs=() +while IFS= read -r -d $'\0'; do + empty_dirs+=("$REPLY") +done < <(find . -type d -empty -print0) + +shopt -s globstar nullglob extglob + +# remove non-matching files +for file in **; do + if [[ -f "$file" ]] && [[ "$file" != *".$ext" ]]; then + rm "$file" + fi +done + +# remove directories emptied by this operation +if [[ $del_dirs == "true" ]]; then + for dir in **/; do + if [[ ! -n "$(ls -A $dir)" ]] && [[ ! "${empty_dirs[*]}" =~ $dir ]]; then + rmdir "$dir" + fi + done +fi + |
