attempting to add NAS drive connection as automount systemd service

This commit is contained in:
2026-07-23 06:11:33 -06:00
parent a3be54e03a
commit f85882f944
10 changed files with 112 additions and 2 deletions
+8 -2
View File
@@ -1,4 +1,4 @@
STOW_TARGET := $(HOME) HOME_TARGET := $(HOME)
.PHONY: check-stow .PHONY: check-stow
check-stow: check-stow:
@@ -47,5 +47,11 @@ link: check-stow
@for pkg in *; do \ @for pkg in *; do \
[ -d "$$pkg" ] || continue; \ [ -d "$$pkg" ] || continue; \
echo "📦 stowing $$pkg"; \ 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 done
+22
View File
@@ -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" <<EOF
username=$USERNAME
password=$PASSWORD
EOF
chmod 600 "$CRED_DIR/.smbcredentials"
@@ -0,0 +1,17 @@
[Unit]
Description=Fetch NAS credentials from 1Password
After=graphical-session.target
[Service]
Type=oneshot
Environment="DISPLAY=:0"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="OP_BIOMETRIC_UNLOCK_ENABLED=true"
ExecStart=sudo -u sammieo -E /home/sammieo/.local/bin/fetch-nas-credentials.sh
ExecStartPost=sudo -u sammieo /usr/bin/systemctl start nas-mounts.target
RemainAfterExit=yes
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.target
@@ -0,0 +1,13 @@
[Unit]
Description=1Password CLI SignIn
After=graphical-session.target
[Service]
Type=oneshot
Environment="DISPLAY=:0"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="OP_BIOMETRIC_UNLOCK_ENABLED=true"
ExecStart=/bin/sh op signin
[Install]
WantedBy=default.target
@@ -0,0 +1,9 @@
[Unit]
Description=Automount NAS Docker Share
[Automount]
Where=/mnt/nas/docker
TimeoutIdleSec=600
[Install]
WantedBy=nas-mounts.target
@@ -0,0 +1,13 @@
[Unit]
Description=NAS SMB Mount (Docker)
After=network-online.target
Wants=network-online.target
[Mount]
What=//192.168.68.77/docker/
Where=/mnt/nas/docker/
Type=cifs
Options=credentials=/home/sammieo/.nas/.smbcredentials,uid=1000,gid=1000,file_mode=0755,dir_mode=0755
TimeoutSec=30
@@ -0,0 +1,9 @@
[Unit]
Description=Automount NAS Docker Share
[Automount]
Where=/mnt/nas/media
TimeoutIdleSec=600
[Install]
WantedBy=nas-mounts.target
@@ -0,0 +1,13 @@
[Unit]
Description=NAS SMB Mount (Media)
After=network-online.target
Wants=network-online.target
[Mount]
What=//192.168.68.77/Partition_1/media/
Where=/mnt/nas/media/
Type=cifs
Options=credentials=/home/sammieo/.nas/.smbcredentials,uid=1000,gid=1000,file_mode=0755,dir_mode=0755
TimeoutSec=30
@@ -0,0 +1,6 @@
[Unit]
Description=All NAS Network Mounts
StopWhenUnneeded=yes
[Install]
WantedBy=default.target
+2
View File
@@ -137,3 +137,5 @@ export HOSTALIASES=$HOME/.config/hosts
# Pip # Pip
alias pip=pip3 alias pip=pip3
. "/home/sammieo/.deno/env" . "/home/sammieo/.deno/env"
export LC_ALL="en_US.UTF-8"