Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # $Id: auto.smb,v 1.3 2005/04/05 13:02:09 raven Exp $
- # This file must be executable to work! chmod 755!
- key="$1"
- credfile="/etc/auto.smb.$key"
- opts="-fstype=cifs,uid=1000,gid=1000"
- smbclientopts=""
- for P in /bin /sbin /usr/bin /usr/sbin
- do
- if [ -x $P/smbclient ]
- then
- SMBCLIENT=$P/smbclient
- break
- fi
- done
- [ -x $SMBCLIENT ] || exit 1
- if [ -e "$credfile" ]
- then
- opts=$opts",credentials=$credfile"
- smbclientopts="-A "$credfile
- else
- smbclientopts="-N"
- fi
- $SMBCLIENT $smbclientopts -gNL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- '
- BEGIN { ORS=""; first=1 }
- /Disk/ {
- if (first)
- print opts; first=0
- dir = $2
- loc = $2
- # Enclose mount dir and location in quotes
- # Double quote "$" in location as it is special
- gsub(/\$$/, "\\$", loc);
- print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
- }
- END { if (!first) print "\n"; else exit 1 }
- '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement