#!/usr/bin/perl -w use strict; use diagnostics; my $defaultgroups="users,audio,games,cdrom,scanner,floppy,video,plugdev,dialout"; my $homebase="/home/"; my $shell="/bin/bash"; if ($#ARGV < 0){ printusage(); exit(0); } my @args=@ARGV; my $argcnt=$#ARGV; main(); sub main{ my $arg=$args[0]; my ($help,$qmark)=($arg,$arg); my $username=$arg; my $grouplist; if(($help=~/help/)||($qmark=~/\?/)){ printusage(); }else{ $grouplist=$defaultgroups; print("\nAdding user $username with group membership = $username,$grouplist..."); system("groupadd $username"); system("useradd -m -d $homebase$username -g $username -s $shell -G $grouplist $username"); print("done.\n"); print("Setting password for user $username:\n"); system("passwd $username"); print("Password set.\n"); system("chmod go+x $homebase$username"); # print("Rehashing NFS stuff...\n"); # system("make -C /var/yp"); print("All done.\n"); # print("----- Don't Forget -----\n"); # print("If you want the user to have smb access\n"); # print("Run 'smbpasswd -a username' to add them\n"); # print("(Remember, you wanted it this way to limit SMB access)\n"); } } sub printusage{ print "\nUsage is mc-useradd username\n"; }