fix: share smb client list — show persistent automount units
persist uses x-systemd.automount, so the CIFS share is never actually mounted until first access and findmnt -t cifs stays empty — list reported 'No SMB mounts' despite configured persistent units. list now also scans $UNIT_DIR/*.mount for Type=cifs and reports them under 'Persistent (automount)' (where, what). Empty output still prints 'No SMB mounts'.
This commit is contained in:
@@ -604,7 +604,7 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`
|
|||||||
| `bin/pos-network-scan` | 271 | Parallel ping sweep of CIDR |
|
| `bin/pos-network-scan` | 271 | Parallel ping sweep of CIDR |
|
||||||
| `bin/pos-share-nfs-client` | 138 | Mount NFS shares (ephemeral or persistent systemd mount units) |
|
| `bin/pos-share-nfs-client` | 138 | Mount NFS shares (ephemeral or persistent systemd mount units) |
|
||||||
| `bin/pos-share-nfs-server` | 134 | Manage the NFS kernel server (status, share/unshare exports, enable/disable) |
|
| `bin/pos-share-nfs-server` | 134 | Manage the NFS kernel server (status, share/unshare exports, enable/disable) |
|
||||||
| `bin/pos-share-smb-client` | 183 | Mount SMB/CIFS shares (ephemeral or persistent systemd mount units) |
|
| `bin/pos-share-smb-client` | 202 | Mount SMB/CIFS shares (ephemeral or persistent systemd mount units) |
|
||||||
| `bin/pos-share-smb-server` | 253 | Manage the Samba server (status, share/unshare exports, users, enable/disable) |
|
| `bin/pos-share-smb-server` | 253 | Manage the Samba server (status, share/unshare exports, users, enable/disable) |
|
||||||
| `bin/pos-share-usb-server` | 218 | USB Redirector server control (--ls, --share; prompts when args omitted) |
|
| `bin/pos-share-usb-server` | 218 | USB Redirector server control (--ls, --share; prompts when args omitted) |
|
||||||
| `bin/pos-ssh-load-keys` | 31 | Load all SSH keys into the agent |
|
| `bin/pos-ssh-load-keys` | 31 | Load all SSH keys into the agent |
|
||||||
|
|||||||
+1
-1
@@ -255,7 +255,7 @@ Subcommands that need input prompt interactively when args are omitted.
|
|||||||
| `pos share nfs server <cmd>` | `bin/pos-share-nfs-server` | Manage the NFS kernel server: `status`, `share <path> [client]`, `unshare <path>`, `list`, `reload`, `enable`, `disable` | Requires `nfs-kernel-server` (added to `preinstall.sh` PACKAGES). Exports live in `/etc/exports`; `share` is idempotent (replaces any existing line for the path) and runs `exportfs -ra`. Default client `*(rw,sync,no_subtree_check)` — the tool warns you to restrict it; help prints Tailscale CGNAT (`100.64.0.0/10`), WireGuard (`10.10.0.0/24`) and LAN examples. Mutating commands announce via `lib/notify.sh` |
|
| `pos share nfs server <cmd>` | `bin/pos-share-nfs-server` | Manage the NFS kernel server: `status`, `share <path> [client]`, `unshare <path>`, `list`, `reload`, `enable`, `disable` | Requires `nfs-kernel-server` (added to `preinstall.sh` PACKAGES). Exports live in `/etc/exports`; `share` is idempotent (replaces any existing line for the path) and runs `exportfs -ra`. Default client `*(rw,sync,no_subtree_check)` — the tool warns you to restrict it; help prints Tailscale CGNAT (`100.64.0.0/10`), WireGuard (`10.10.0.0/24`) and LAN examples. Mutating commands announce via `lib/notify.sh` |
|
||||||
| `pos share nfs client <cmd>` | `bin/pos-share-nfs-client` | Mount and manage NFS shares: `mount <server:export> <local-dir>`, `unmount <local-dir>`, `list`, `persist <server:export> <local-dir>`, `unpersist <local-dir>` | Requires `nfs-common` (added to `preinstall.sh` PACKAGES). `persist` writes a systemd `.mount` unit (`systemd-escape --path --suffix=mount`) with `After=network-online.target` / `Wants=network-online.target` — mounts only once all interfaces are up, no fstab edits to break boot — then `daemon-reload` + `enable --now`. `unpersist` stops/disables/removes the unit. `mount`/`persist` announce via `lib/notify.sh` |
|
| `pos share nfs client <cmd>` | `bin/pos-share-nfs-client` | Mount and manage NFS shares: `mount <server:export> <local-dir>`, `unmount <local-dir>`, `list`, `persist <server:export> <local-dir>`, `unpersist <local-dir>` | Requires `nfs-common` (added to `preinstall.sh` PACKAGES). `persist` writes a systemd `.mount` unit (`systemd-escape --path --suffix=mount`) with `After=network-online.target` / `Wants=network-online.target` — mounts only once all interfaces are up, no fstab edits to break boot — then `daemon-reload` + `enable --now`. `unpersist` stops/disables/removes the unit. `mount`/`persist` announce via `lib/notify.sh` |
|
||||||
| `pos share smb server <cmd>` | `bin/pos-share-smb-server` | Manage the Samba server: `status`, `share <path> [name] [--read-only|--guest|--users u1,u2]`, `unshare <name>`, `list`, `adduser <user>`, `deluser <user>`, `reload`, `enable`, `disable` | Requires `samba` (added to `preinstall.sh` PACKAGES). Shares are idempotent marker blocks (`# >>> pos-managed share: <name>` … `# <<< end pos-managed share`) in `/etc/samba/smb.conf` — hand edits outside the markers survive; `share` validates with `testparm` before applying and hot-reloads via `smbcontrol smbd reload-config`. Defaults rw + browsable; warns when unrestricted (guest or no `valid users`). `adduser`/`deluser` manage Samba accounts via `smbpasswd`. Mutating commands announce via `lib/notify.sh` |
|
| `pos share smb server <cmd>` | `bin/pos-share-smb-server` | Manage the Samba server: `status`, `share <path> [name] [--read-only|--guest|--users u1,u2]`, `unshare <name>`, `list`, `adduser <user>`, `deluser <user>`, `reload`, `enable`, `disable` | Requires `samba` (added to `preinstall.sh` PACKAGES). Shares are idempotent marker blocks (`# >>> pos-managed share: <name>` … `# <<< end pos-managed share`) in `/etc/samba/smb.conf` — hand edits outside the markers survive; `share` validates with `testparm` before applying and hot-reloads via `smbcontrol smbd reload-config`. Defaults rw + browsable; warns when unrestricted (guest or no `valid users`). `adduser`/`deluser` manage Samba accounts via `smbpasswd`. Mutating commands announce via `lib/notify.sh` |
|
||||||
| `pos share smb client <cmd>` | `bin/pos-share-smb-client` | Mount and manage SMB/CIFS shares: `mount <//server/share> <local-dir> [user]`, `unmount <local-dir>`, `list`, `persist <//server/share> <local-dir> [user]`, `unpersist <local-dir>` | Requires `cifs-utils` (added to `preinstall.sh` PACKAGES). With a user you are prompted for the Samba password — one-shot mounts use a throwaway chmod-600 credentials file, `persist` keeps one at `/etc/samba/credentials/<name>` (chmod 600). `persist` writes a systemd `.mount` unit (`systemd-escape --path --suffix=mount`) with `x-systemd.automount` + `_netdev` — mounts on first access, never blocks boot — then `daemon-reload` + `enable --now`. `unpersist` stops/disables/removes the unit + credentials. `mount`/`persist` announce via `lib/notify.sh` |
|
| `pos share smb client <cmd>` | `bin/pos-share-smb-client` | Mount and manage SMB/CIFS shares: `mount <//server/share> <local-dir> [user]`, `unmount <local-dir>`, `list`, `persist <//server/share> <local-dir> [user]`, `unpersist <local-dir>` | Requires `cifs-utils` (added to `preinstall.sh` PACKAGES). With a user you are prompted for the Samba password — one-shot mounts use a throwaway chmod-600 credentials file, `persist` keeps one at `/etc/samba/credentials/<name>` (chmod 600). `persist` writes a systemd `.mount` unit (`systemd-escape --path --suffix=mount`) with `x-systemd.automount` + `_netdev` — mounts on first access, never blocks boot — then `daemon-reload` + `enable --now`. `unpersist` stops/disables/removes the unit + credentials. `list` shows active mounts (`findmnt -t cifs`) **and** persistent units (as automount shares aren't mounted until first access, they'd otherwise be invisible). `mount`/`persist` announce via `lib/notify.sh` |
|
||||||
|
|
||||||
### communication
|
### communication
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -220,7 +220,7 @@ Requires `cifs-utils` (in `preinstall.sh` PACKAGES).
|
|||||||
pos share smb client mount //100.100.100.1/media /mnt/smb/media # guest
|
pos share smb client mount //100.100.100.1/media /mnt/smb/media # guest
|
||||||
pos share smb client mount //100.100.100.1/media /mnt/smb/media bob # prompts for password
|
pos share smb client mount //100.100.100.1/media /mnt/smb/media bob # prompts for password
|
||||||
pos share smb client persist //100.100.100.1/media /mnt/smb/media bob # persistent (systemd)
|
pos share smb client persist //100.100.100.1/media /mnt/smb/media bob # persistent (systemd)
|
||||||
pos share smb client list # active SMB mounts
|
pos share smb client list # active + persistent SMB mounts
|
||||||
pos share smb client unmount /mnt/smb/media
|
pos share smb client unmount /mnt/smb/media
|
||||||
pos share smb client unpersist /mnt/smb/media # remove the unit
|
pos share smb client unpersist /mnt/smb/media # remove the unit
|
||||||
```
|
```
|
||||||
@@ -253,9 +253,10 @@ fstab it could). `enable --now` arms the automount immediately.
|
|||||||
server and re-run with the right user
|
server and re-run with the right user
|
||||||
- Mount fails with `NT_STATUS_ACCESS_DENIED` on a guest mount → the server
|
- Mount fails with `NT_STATUS_ACCESS_DENIED` on a guest mount → the server
|
||||||
share has no `guest ok`; use a user or add `--guest` on the server
|
share has no `guest ok`; use a user or add `--guest` on the server
|
||||||
- Persistent mount doesn't appear until accessed → intended (`x-systemd.automount`);
|
- Persistent mount doesn't appear under "Active mounts" until accessed →
|
||||||
`pos share smb client list` only shows actively mounted shares, access the
|
intended (`x-systemd.automount`); `pos share smb client list` now also lists
|
||||||
directory to trigger the mount
|
persistent units under "Persistent (automount)", so the configured shares are
|
||||||
|
visible even before their first access
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Mount and manage SMB/CIFS shares from remote servers (cifs-utils).
|
|||||||
Commands:
|
Commands:
|
||||||
mount <//server/share> <local-dir> [user] One-shot mount (creates local-dir if needed)
|
mount <//server/share> <local-dir> [user] One-shot mount (creates local-dir if needed)
|
||||||
unmount <local-dir> Unmount the share
|
unmount <local-dir> Unmount the share
|
||||||
list Show active SMB mounts
|
list Show active + persistent SMB mounts
|
||||||
persist <//server/share> <local-dir> [user] Persistent mount via a systemd .mount unit
|
persist <//server/share> <local-dir> [user] Persistent mount via a systemd .mount unit
|
||||||
(automount — never blocks boot)
|
(automount — never blocks boot)
|
||||||
unpersist <local-dir> Stop, disable and remove the mount unit
|
unpersist <local-dir> Stop, disable and remove the mount unit
|
||||||
@@ -108,11 +108,30 @@ case "$cmd" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
list)
|
list)
|
||||||
if findmnt -t cifs >/dev/null 2>&1; then
|
found=0
|
||||||
findmnt -t cifs
|
active_mounts="$(findmnt -t cifs 2>/dev/null || true)"
|
||||||
else
|
if [ -n "$active_mounts" ]; then
|
||||||
echo "No SMB mounts"
|
printf 'Active mounts:\n'
|
||||||
|
printf '%s\n' "$active_mounts"
|
||||||
|
found=1
|
||||||
fi
|
fi
|
||||||
|
persistent=()
|
||||||
|
for unit in "${UNIT_DIR}"/*.mount; do
|
||||||
|
[ -e "$unit" ] || continue
|
||||||
|
grep -q '^Type=cifs$' "$unit" || continue
|
||||||
|
what="$(sed -n 's/^What=//p' "$unit")"
|
||||||
|
where="$(sed -n 's/^Where=//p' "$unit")"
|
||||||
|
[ -n "$what" ] && [ -n "$where" ] || continue
|
||||||
|
persistent+=("$where|$what")
|
||||||
|
done
|
||||||
|
if [ "${#persistent[@]}" -gt 0 ]; then
|
||||||
|
found=1
|
||||||
|
printf 'Persistent (automount):\n'
|
||||||
|
for entry in "${persistent[@]}"; do
|
||||||
|
printf ' %-44s %s\n' "${entry%%|*}" "${entry#*|}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
[ "$found" -eq 1 ] || echo "No SMB mounts"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
persist)
|
persist)
|
||||||
|
|||||||
Reference in New Issue
Block a user