Quick Usage
-
Install Bashly (one-time):
Terminal window gem install bashly -
Generate the executable:
Terminal window cd packages/debian-ubuntu/scripts/netshare-mounterbashly generate -
Verify installation:
Terminal window ./netshare-mounter --help
Common Tasks
Section titled “Common Tasks”Mount a Network Share
Section titled “Mount a Network Share”Interactive (prompts for credentials):
sudo ./netshare-mounter mount //192.168.1.100/share /mnt/myshareNon-interactive (full automation):
sudo ./netshare-mounter mount //192.168.1.100/share /mnt/myshare \ --username myuser \ --password mypass \ --auto-installCheck Status
Section titled “Check Status”All mounts:
./netshare-mounter statusSpecific mount:
./netshare-mounter status /mnt/myshareDetailed status:
./netshare-mounter status /mnt/myshare --verboseValidate Before Mounting
Section titled “Validate Before Mounting”sudo ./netshare-mounter validate //192.168.1.100/share --check-connectivityUnmount
Section titled “Unmount”Clean unmount (prompts for confirmation):
sudo ./netshare-mounter unmount /mnt/myshareKeep credentials for later:
sudo ./netshare-mounter unmount /mnt/myshare --keep-credentialsForce unmount:
sudo ./netshare-mounter unmount /mnt/myshare --forceComplete cleanup (purge - no prompts):
sudo ./netshare-mounter unmount /mnt/myshare --purgeAdvanced Examples
Section titled “Advanced Examples”Custom Permissions
Section titled “Custom Permissions”sudo ./netshare-mounter mount //server/share /mnt/share \ --username admin \ --password secretpass \ --uid 1001 \ --gid 1001 \ --file-mode 0640 \ --dir-mode 0750Older CIFS Version
Section titled “Older CIFS Version”sudo ./netshare-mounter mount //old-server/share /mnt/old \ --username user \ --password pass \ --cifs-version 2.0Enable Without Starting
Section titled “Enable Without Starting”sudo ./netshare-mounter mount //server/share /mnt/share \ --username user \ --password pass \ --enable-onlyThis will configure the mount but not start it immediately (will mount on next boot).
Domain Authentication
Section titled “Domain Authentication”sudo ./netshare-mounter mount //server/share /mnt/share \ --username DOMAIN\\user \ --password pass \ --domain DOMAINTroubleshooting
Section titled “Troubleshooting”View Systemd Logs
Section titled “View Systemd Logs”sudo journalctl -xeu mnt-myshare.mountCheck Systemd Status
Section titled “Check Systemd Status”sudo systemctl status mnt-myshare.mountManual Test Mount
Section titled “Manual Test Mount”sudo mount -t cifs //server/share /mnt/test \ -o credentials=/root/.smbcredentialsFind What’s Using Mount
Section titled “Find What’s Using Mount”sudo lsof /mnt/mysharesudo fuser -vm /mnt/myshare- Always validate first - Use
validate --check-connectivitybefore mounting - Test credentials - Mount interactively first to verify credentials work
- Check logs - If mount fails, check
journalctl -xeu <unit-name> - Use JSON output - For scripting, use
--jsonflag with status command - Keep credentials - When unmounting, consider
--keep-credentialsif you’ll remount later
System-wide Installation
Section titled “System-wide Installation”To use the command from anywhere:
sudo cp netshare-mounter /usr/local/bin/sudo chmod +x /usr/local/bin/netshare-mounter
# Now you can run from anywherenetshare-mounter --versionScripting Example
Section titled “Scripting Example”#!/bin/bash
# Automated mount scriptSHARE="//nas.local/media"MOUNT="/mnt/media"
# Validate firstif ! netshare-mounter validate "$SHARE" --check-connectivity; then echo "Validation failed, aborting" exit 1fi
# Mount using environment variables for credentialsnetshare-mounter mount "$SHARE" "$MOUNT" \ --username "$SMB_USER" \ --password "$SMB_PASS" \ --auto-install
# Check if successfulif netshare-mounter status "$MOUNT" --json | jq -r '.mounted' | grep -q 'true'; then echo "Mount successful!"else echo "Mount failed!" exit 1fi