View previous topic :: View next topic |
Author |
Message |
Zed n00b
Joined: 10 Jul 2003 Posts: 1
|
Posted: Fri Jul 11, 2003 2:51 am Post subject: For SAMBA users... handy smbadduser script |
|
|
just setup a gentoo desktop and was trying to setup a smb user the hard way when I rememebered that Redhat has a script to automate it.
So i ssh'd into my redhat server at work and then scp'd the smbadduser script over to my gentoo box, after emerge'ing csh then chmod+chown and copy to /usr/bin it works like a charm
anyway, here is the contents of the file:
#!/bin/csh
#
# smbadduser - Written by Mike Zakharoff
# ripped for Gentoo by Zed
#
unalias *
set path = ($path)
#set smbpasswd = /usr/local/samba/private/smbpasswd
set smbpasswd = /etc/samba/smbpasswd
#set user_map = /usr/local/samba/lib/users.map
set user_map = /etc/samba/smbusers
#
# Set to site specific passwd command
#
set passwd = "getent passwd"
#set passwd = "cat /etc/passwd"
#set passwd = "niscat passwd.org_dir"
#set passwd = "ypcat passwd"
set line = "----------------------------------------------------------"
if ($#argv == 0) then
echo $line
echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
echo ""
echo " 1) Updates $smbpasswd"
echo " 2) Updates $user_map"
echo " 3) Executes smbpasswd for each new user"
echo ""
echo "smbadduser unixid:ntid unixid:ntid ..."
echo ""
echo "Example: smbadduser zak:zakharoffm johns:smithj"
echo $line
exit 1
endif
touch $smbpasswd $user_map
set new = ()
foreach one ($argv)
echo $one | grep ':' >& /dev/null
if ($status != 0) then
echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
continue
endif
set unix = `echo $one | awk -F: '{print $1}'`
set ntid = `echo $one | awk -F: '{print $2}'`
set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
if ($#usr != 1) then
echo "ERROR: $unix Not in passwd database SKIPPING..."
continue
endif
set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
if ($#tmp != 0) then
echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
continue
endif
echo "Adding: $unix to $smbpasswd"
# eval $passwd | \
# awk -F: '$1==USR { \
# printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd
/usr/bin/smbpasswd -a -n $unix
if ($unix != $ntid) then
echo "Adding: {$unix = $ntid} to $user_map"
echo "$unix = $ntid" >> $user_map
endif
set new = ($new $unix)
end
#
# Enter password for new users
#
foreach one ($new)
echo $line
echo "ENTER password for $one"
smbpasswd $one
end |
|
Back to top |
|
|
bloatedfish n00b
Joined: 24 Apr 2003 Posts: 45
|
Posted: Wed Dec 10, 2003 4:09 pm Post subject: |
|
|
Silly me. I had assumed that the smbadduser script was a utility included in the samba ebuild!
<request>
Someone should add this to the samba package!
</request>
Anywho, thanks for the script |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|