Files
dotfiles/scripts/tnmount.sh
Thomas Naderer d8a20d620a chore: clean up dotfiles and add gitignore whitelist
Switch to whitelist-based .gitignore to only track essential configs:
nvim, yazi, kitty, zsh, ideavim, karabiner, tmux, scripts, starship.
Remove history, compiled files, and plugin dirs from tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 12:57:14 +01:00

48 lines
1.1 KiB
Bash
Executable File

#!/bin/zsh
set -euo pipefail
# Auto-remount TN shares when network changes.
# Credentials should be stored in macOS Keychain (connect once via Finder, remember password).
SERVER="140.78.8.107"
# Use URL-encoded path segments for spaces if needed.
SHARE1_URL="smb://$SERVER/TNGROUP/tn-group/ipec"
SHARE2_URL="smb://$SERVER/TNHOME/home/AK127132"
# Expected mount points under /Volumes (adjust if your Finder mount names differ)
MOUNT1="/Volumes/ipec"
MOUNT2="/Volumes/AK127132"
log() {
echo "[tnmount] $*"
}
is_mounted() {
local mountpoint="$1"
mount | grep -q " on ${mountpoint} "
}
mount_if_missing() {
local mountpoint="$1"
local url="$2"
if is_mounted "$mountpoint"; then
log "Already mounted: $mountpoint"
else
log "Mounting: $url"
open "$url"
fi
}
# Skip when server is unreachable (offsite/no VPN), try again on next interval.
if ! nc -zw2 "$SERVER" 445 >/dev/null 2>&1; then
log "Server $SERVER:445 not reachable; skipping"
exit 0
fi
mount_if_missing "$MOUNT1" "$SHARE1_URL"
mount_if_missing "$MOUNT2" "$SHARE2_URL"
log "Done"