summaryrefslogtreecommitdiff
path: root/debian/.local/bin/ecrypt
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
commit28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch)
tree85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/ecrypt
parent8470ff001befcfd0f626dea69a9e76d43aee0511 (diff)
updates
Diffstat (limited to 'debian/.local/bin/ecrypt')
-rwxr-xr-xdebian/.local/bin/ecrypt39
1 files changed, 39 insertions, 0 deletions
diff --git a/debian/.local/bin/ecrypt b/debian/.local/bin/ecrypt
new file mode 100755
index 0000000..e13c033
--- /dev/null
+++ b/debian/.local/bin/ecrypt
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+mount_encrypted() {
+ ! mount | grep -q " $1 " && echo "$passphrase" | sudo mount -t ecryptfs "$1" "$2" \
+ -o ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes,ecryptfs_sig=$ecryptfs_sig,ecryptfs_fnek_sig=$fnek_sig,key=passphrase:passphrase_passwd=$(printf '%s' "$passphrase")
+}
+
+attempt_mount() {
+ if mount | grep -q " $2 "; then
+ if sudo umount "$2"; then
+ notify-send "🔒 Locked: $3"
+ else
+ notify-send "❗ Unable to lock" "Mounted: $3"
+ fi
+ else
+ ecryptfs_sig=$(pass show encryption/ecryptfs-sig-"$4")
+ fnek_sig=$ecryptfs_sig
+ passphrase=$(pass show encryption/ecryptfs)
+ [ -z "$passphrase" ] && {
+ notify-send "❌ Failed to retrieve passphrase."
+ exit 1
+ }
+ mount_encrypted "$1" "$2" && notify-send "🔑 Unlocked: $3"
+ fi
+}
+
+targets="$HOME/.secret"
+mounts="$HOME/Private"
+pw="default"
+set -- $mounts # Set positional parameters to mounts
+i=1
+for target in $targets; do
+ mp=$(eval echo "\$$i") # Get the mount point using indirect expansion
+ path=$(basename "$mp") # Extract last directory component
+ pw=$(echo "$pw" | cut -d' ' -f$i) # Get the corresponding passthrough option
+
+ attempt_mount "$target" "$mp" "$path" "$pw"
+ i=$((i + 1))
+done