#!/usr/bin/env python # # Paul McNett (p@ulmcnett.com) # import sys, os def usage(): return """addUser.py Adds the passed user to the registry of users that can logon to the Samba domain. The password will match the user name initially, and the user can then change it in the normal way using the Windows security screen. Usage: ./addUser [,...] """ if len(sys.argv) < 2 or "-h" in sys.argv or "--help" in sys.argv: print usage() sys.exit() for user in sys.argv[1:]: print "Creating user %s" % user os.system("useradd -d /var/local/samba/home/%s -g users %s" % (user, user)) os.system("smbpasswd -a %s" % (user,)) # Make the profiles directory for the user: os.system("mkdir /var/local/samba/profiles/%s" % user) os.system("chown %s:users /var/local/samba/profiles/%s" % (user, user)) # SBS: make the userdata directory for the user: os.system("mkdir /var/local/samba/userdata/%s" % user) os.system("chown %s:users /var/local/samba/userdata/%s" % (user, user)) os.system("chmod 700 /var/local/samba/userdata/%s" % (user,)) # Make the logon batch file for the user: f = open("/var/local/samba/netlogon/%s.bat" % user, "w") f.write("call allusers.bat\r\n") f.close() os.system("chown administrator:users /var/local/samba/netlogon/%s.bat" % user) os.system("chmod 750 /var/local/samba/netlogon/%s.bat" % user)