| <<O>> Difference Topic SambaUserScripting (r1.6 - 22 Mar 2005 - RickArchibald) |
| Changed: | |
| < < | awk -F\\t '{ |
| > > | awk -F: ' /^[^#]/ { |
| Changed: | |
| < < | system ( "mkdir -p " $5) # Step 7 system ( "chown " $2 " " $5) # Step 7 |
| > > | system ( "mkdir -p " $5) # Step 7 (1) system ( "chown " $2 " " $5) # Step 7 (2) |
| Added: | |
| > > | chgrp -R accts /data # Step 7 (3) chmod -R ug+rwxs,o-r+x /data # Step 7 (4) |
| Changed: | |
| < < | Here is code to test the above fragment: |
| > > | Here is code to test the above awk script: |
| Changed: | |
| < < | awk -F: '{ |
| > > | awk -F: ' /^[^#]/ { |
| Added: | |
| > > | chgrp -R accts /data # Step 7 & 13 chmod -R ug+rwxs,o-r+x /data # Step 7 & 13 |
| <<O>> Difference Topic SambaUserScripting (r1.5 - 21 Mar 2005 - RickArchibald) |
| Added: | |
| > > | system ( "smbpasswd " $2 $3 ) # Step 6 (3) |
| Added: | |
| > > | print "smbpasswd " $2 $3 |
| <<O>> Difference Topic SambaUserScripting (r1.4 - 21 Mar 2005 - RickArchibald) |
| Changed: | |
| < < | The excersise gives a table of 10 users in Table 2.1. |
| > > | The excercise gives a table of 10 users in Table 2.1. |
| Changed: | |
| < < |
I would embed the necessary bash commands in the awk subscript
using its (awk's) system command.
|
| > > |
I would embed the necessary bash commands in the awk script
using its (awk's) system command:
|
| Changed: | |
| < < | system ( "useradd -m -G accts -c " $1 $2) system ( "echo " $3 "| passwd --stdin " $1) system ( "mkdir -p " $5) system ( "chown " $2 $5) |
| > > | system ( "useradd -m -G accts -c " "\"" $1 "\" " $2) # Step 6 (1) system ( "echo " $3 "| passwd --stdin " $2) # Step 6 (2) system ( "mkdir -p " $5) # Step 7 system ( "chown " $2 " " $5) # Step 7 |
| Changed: | |
| < < | |
| > > | Here is code to test the above fragment: |
| Changed: | |
| < < | awk -F\\t '{ print "useradd -m -G accts -c " $1 $2 print "echo " $3 "| passwd --stdin " $1 |
| > > | awk -F: '{ print "useradd -m -G accts -c " "\"" $1 "\" " $2 print "echo " $3 " | passwd --stdin " $2 |
| Changed: | |
| < < | print "chown " $2 $5 |
| > > |
print "chown " $2 " " $5
print ""
}' users.txt | less
Step 13 can be acomplished by re-running the Step 7 code:
awk -F\\t '{
system ( "mkdir -p " $5) # Step 7 & 13
system ( "chown " $2 " " $5) # Step 7 & 13
|
| <<O>> Difference Topic SambaUserScripting (r1.3 - 21 Mar 2005 - RickArchibald) |
| Added: | |
| > > |
For RH, at least, we will be able to it all in plaintext.
I would capture the user table as a text file (users.txt)
& process it using awk.
I would embed the necessary bash commands in the awk subscript
using its (awk's) system command.
#! /bin/bash
.
.
.
awk -F\\t '{
system ( "useradd -m -G accts -c " $1 $2)
system ( "echo " $3 "| passwd --stdin " $1)
system ( "mkdir -p " $5)
system ( "chown " $2 $5)
}' users.txt
# test code
awk -F\\t '{
print "useradd -m -G accts -c " $1 $2
print "echo " $3 "| passwd --stdin " $1
print "mkdir -p " $5
print "chown " $2 $5
}' users.txt
.
.
|
| Added: | |
| > > | system ( " ") |
| <<O>> Difference Topic SambaUserScripting (r1.2 - 21 Mar 2005 - RickArchibald) |
| Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > | (An on-line version of Samba 3 by Example is at: http://us2.samba.org/samba/docs/man/Samba-Guide/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
The excersise gives a table of 10 users in Table _ _ on page -.
We are instructed to do the following for each of them:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > | The excersise gives a table of 10 users in Table 2.1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
Table 2.1. Accounting Office Network Information
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
We are given 14 steps to complete the
"Migration from Windows NT4 Workstation System to Samba-3".
We are instructed to do the following for each user:
6. For each user who uses this system (see Table 2.1), execute the following:
root# useradd -m -G accts -c "Name of User" "LoginID" root# passwd "LoginID" Changing password for user "LoginID" New Password: XXXXXXXXX <-- the password from the table Retype new password: XXXXXXXXX root# smbpasswd -a "LoginID" New SMB password: XXXXXXXXX <-- the password from the table Retype new SMB password: XXXXXXXXX Added user "LoginID"7. Create the directory structure for the file shares by executing the following: root# mkdir -p /data root# chown alan /data root# for i in james suzy ursula peter dale eric jeannie russell > do > mkdir -p /data/$i > chown $i /data/$i > done root# chgrp -R accts /data root# chmod -R ug+rwxs,o-r+x /data13. Verify that the files are being copied correctly from the Windows NT4 machine to the Samba-3 server. This is best done on the Samba-3 server. Check the contents of the directory tree under /data. This can be done by executing the following command: root# ls -aR /dataMake certain to check the ownership and permissions on all files. If in doubt, execute the following: root# chown alan /data root# for i in james suzy ursula peter dale eric jeannie russell > do > chown $i /data/$i > done root# chgrp -R accts /data root# chmod -R ug+rwxs,o-r+x /data DiscussionThe set exercise calls for an RH 9 server. Your author runs Debian Woody on his server. So the current version of this paper is confined to these two distributions. Fortunately for diversity, unfortunately for consistency, tools bearing the same name vary from distro to distro in their capabilities. You will have to determine how your distribution behaves. Steps 6 & 7 can be placed in a script, provided we know how to interact withuseradd, passwd, & smbpasswd.
Let's look at the supplied versions & their capabilities in our selected distros.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <<O>> Difference Topic SambaUserScripting (r1.1 - 21 Mar 2005 - RickArchibald) |
| Added: | |
| > > |
%META:TOPICINFO{author="RickArchibald" date="1111366800" format="1.0" version="1.1"}%
Samba User ScriptingThe ProblemHow to add samba users to a Samba server using a script. Specifically, to the Samba server in Excercise 2.2.3 of Samba 3 by Example .BackgroundThe excersise gives a table of 10 users in Table _ _ on page -. We are instructed to do the following for each of them: |
| Topic SambaUserScripting . { View | Diffs | r1.6 | > | r1.5 | > | r1.4 | More } |
|
Revision r1.1 - 21 Mar 2005 - 01:00 GMT - RickArchibald Revision r1.6 - 22 Mar 2005 - 00:23 GMT - RickArchibald |
Copyright © 2003-2007 by F. A. Archibald III & the contributing authors |