From f85882f944f271c4971a085084aaaf93230ce4da Mon Sep 17 00:00:00 2001 From: Samuel O'Neal Date: Thu, 23 Jul 2026 06:11:33 -0600 Subject: [PATCH] attempting to add NAS drive connection as automount systemd service --- Makefile | 10 +++++++-- local/.local/bin/fetch-nas-credentials.sh | 22 +++++++++++++++++++ .../systemd/user/mnt-nas-credentials.service | 17 ++++++++++++++ .../systemd/user/op-cli-signin.service | 13 +++++++++++ .../systemd/system/mnt-nas-docker.automount | 9 ++++++++ .../etc/systemd/system/mnt-nas-docker.mount | 13 +++++++++++ .../systemd/system/mnt-nas-media.automount | 9 ++++++++ .../etc/systemd/system/mnt-nas-media.mount | 13 +++++++++++ systemd/etc/systemd/system/nas-mounts.target | 6 +++++ zsh/.zshrc | 2 ++ 10 files changed, 112 insertions(+), 2 deletions(-) create mode 100755 local/.local/bin/fetch-nas-credentials.sh create mode 100644 systemd/.config/systemd/user/mnt-nas-credentials.service create mode 100644 systemd/.config/systemd/user/op-cli-signin.service create mode 100644 systemd/etc/systemd/system/mnt-nas-docker.automount create mode 100644 systemd/etc/systemd/system/mnt-nas-docker.mount create mode 100644 systemd/etc/systemd/system/mnt-nas-media.automount create mode 100644 systemd/etc/systemd/system/mnt-nas-media.mount create mode 100644 systemd/etc/systemd/system/nas-mounts.target diff --git a/Makefile b/Makefile index bd7d856..3307dcc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -STOW_TARGET := $(HOME) +HOME_TARGET := $(HOME) .PHONY: check-stow check-stow: @@ -47,5 +47,11 @@ link: check-stow @for pkg in *; do \ [ -d "$$pkg" ] || continue; \ echo "📦 stowing $$pkg"; \ - stow -R "$$pkg" -t "$(STOW_TARGET)" --adopt; \ + if [ -d "$$pkg/etc" ] || [ -d "$$pkg/usr" ] || [ -d "$$pkg/mnt" ]; then \ + echo "[System] Stowing '$$pkg' to /..."; \ + sudo stow -R "$$pkg" -t / --adopt; \ + else \ + echo "[User] Stowing '$$pkg' to $(HOME_TARGET)..."; \ + stow -R "$$pkg" -t "$(HOME_TARGET)" --adopt; \ + fi; \ done diff --git a/local/.local/bin/fetch-nas-credentials.sh b/local/.local/bin/fetch-nas-credentials.sh new file mode 100755 index 0000000..9e34fa7 --- /dev/null +++ b/local/.local/bin/fetch-nas-credentials.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -xe + +USERNAME=$(op read "op://Personal/Main NAS/username" 2>&1) +PASSWORD=$(op read "op://Personal/Main NAS/password" 2>&1) + +if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then + echo "Failed to fetch credentials" >&2 + exit 1 +fi + +CRED_DIR="$HOME/.nas" +mkdir -p "$CRED_DIR" +chmod 700 "$CRED_DIR" + +cat >"$CRED_DIR/.smbcredentials" <