Plugtools

 view release on metacpan or  search on metacpan

bin/pluadd  view on Meta::CPAN

			  "-U <UID>  - The UID for the new user.\n".
			  "-g <group name>  - The primary group name for the user.\n".
			  "-G <GID>  - The GID to use for when adding the primary group.\n".
			  "-c <gecos>  - The GECOS value for new user.\n".
			  "-h <home>  - The home directory for the new user.\n".
			  "-s <shell>  - The shell for the new user.\n".
			  "-H <createHome>  - A boolean value describing if the home directory should be created.\n".
			  "-S <skel>  - The skeleton to use for the directory to use.\n".
			  "-p <chmodHome>  - A boolean value describing if the home directory should be chmoded or not.\n".
			  "-P <chmodValue>  - The chmod value for home.\n".
			  "-O <chownHome>  - A boolean value describing if the home directory should be chowned or not.\n".
			  "-l  - Call \$entry->dump on any new objects.\n".
			  "\n".
			  "createHome:\n".
			  "The this overrides the default value. If nothing is specified, the default value is '1'.\n".
			  "\n".
			  "skel:\n".
			  "This overrides the default value. If nothing is specified, '/etc/skel' is used.\n".
			  "\n".
			  "chownHome:\n".
			  "This overrides the default value. If nothing is specified, '1' is used.\n".
			  "\n".
			  "chownValue:\n".
			  "This overrides te default value. If nothing is specified, '640' is used.\n".
			  "\n".
			  "For more info, see the the perldocs for Plugtools and pluadd...\n".
			  "perldoc pluadd\n".
			  "perldoc Plugtools\n";
}

#gets the options
my %opts=();
getopts('u:U:g:G:c:h:s:H:S:p:P:O:l', \%opts);

bin/pluadd  view on Meta::CPAN


$pt->addUser({
			  user=>$opts{u},
			  uid=>$opts{U},
			  group=>$opts{g},
			  gid=>$opts{G},
			  gecos=>$opts{c},
			  shell=>$opts{s},
			  home=>$opts{h},
			  createHome=>$opts{H},
			  chownHome=>$opts{O},
			  chmodHome=>$opts{p},
			  chmodValue=>$opts{P}
			  });
if ($pt->{error}) {
	warn('pluadd: Failed to add the user');
	exit $pt->{error};
}

exit 0;

bin/pluadd  view on Meta::CPAN

=head2 -S <skel>

The skeleton directory to use if the user directory is to be created.

=head2 -H (0|1)

Override the default of config specified setting creating the home directory.

=head2 -O (0|1)

Override the default of config specified setting chowning the home directory.

=head2 -p (0|1)

Override the default of config specified setting chmoding the home directory.

=head2 -P <chownValue>

Override the default of config specified setting number to use for chmoding the home directory.

=head2 -l

Print any newly created or modified entries.

=head1 EXIT CODES

If the exit code is not listed below, it is what was the error code returned by Plugtools.

lib/Plugtools.pm  view on Meta::CPAN


This is the home directory for the user. If this is not defined, the
home prototype is used.

=head4 createHome

If this is specified, the default value for createHome will be overrode the
defaults or what is specified in the config.

If it exists, it assumes it does not need to be created, but it will still be
chowned.

=head4 skel

Use this instead of the default skeleton or the one specified in the config file.

This is skipped, if the home already exists.

=head4 chmodValue

Overrides the default value for this or the one specified in the config.

=head4 chmodHome

Overrides the default value for this or the one specified in the config.

=head4 chownHome

If home should be chowned. This overrides the value specified in the
config or the default one.

=head4 dump

If this is true, call the dump method on the create Net::LDAP::Entry object.

    #the most basic form
    $pt->addUser({
                  user=>'someUser',
                  })

lib/Plugtools.pm  view on Meta::CPAN

		$entry->dump;
	}

	#create the home directory if needed, after getting the required values
	if (!defined($args{createHome})) {
		$args{createHome}=$self->{ini}->{''}->{createHome};
	}
	if (!defined($args{skel})) {
		$args{skel}=$self->{ini}->{''}->{skeletonHome};
	}
	if (!defined($args{chownHome})) {
		$args{chownHome}=$self->{ini}->{''}->{chownHome};
	}
	if (!defined($args{chmodHome})) {
		$args{chmodHome}=$self->{ini}->{''}->{chmodHome};
	}
	if (!defined($args{chmodValue})) {
		$args{chmodValue}=$self->{ini}->{''}->{chmodValue};
	}
	if ($args{createHome}) {
		if (! -e $args{home}) {
			#copy it
			system( 'cp -r '.shell_quote($args{skel}).' '.shell_quote($args{home}) );
			if ($? ne '0') {
				$self->{error}=22;
				$self->{errorString}='Copying home from "'.$args{skel}.'" to "'.$args{home}.'" failed';
				warn('Plugtools addUser:22: '.$self->{errorString});
				return undef;
			}

			#chown it if needed
			if ($args{chownHome}) {
				system( 'chown -R '.shell_quote($args{user}).':'.shell_quote($args{group})
						.' '.shell_quote($args{home}) );
				if ($? ne '0') {
					$self->{error}=23;
					$self->{errorString}='Chowning "'.$args{home}.'" to "'.$args{chmodValue}.'" failed';
					warn('Plugtools addUser:22: '.$self->{errorString});
					return undef;
				}
			}

			#chmod it if needed

lib/Plugtools.pm  view on Meta::CPAN

	}
	if (!defined($ini->{''}->{skeletonHome})) {
		$ini->{''}->{skeletonHome}='/etc/skel/';
	}
	if (!defined($ini->{''}->{chmodValue})) {
		$ini->{''}->{chmodValue}='640';
	}
	if (!defined($ini->{''}->{chmodHome})) {
		$ini->{''}->{chmodHome}='1';
	}
	if (!defined($ini->{''}->{chownHome})) {
		$ini->{''}->{chownHome}='1';
	}
	if (!defined($ini->{''}->{createHome})) {
		$ini->{''}->{createHome}='1';
	}
	if (!defined($ini->{''}->{groupPrimary})) {
		$ini->{''}->{groupPrimary}='cn';
	}
	if (!defined($ini->{''}->{userPrimary})) {
		$ini->{''}->{userPrimary}='uid';
	}

lib/Plugtools.pm  view on Meta::CPAN

=head2 21

Failed to create home.

=head2 22

Copying the skeleton to the home location failed.

=head2 23

Failed to chown the new home directory.

=head2 24

Failed to chmod the new home directory.

=head2 25

Failed to update a entry when removing a memberUid.

=head2 26

lib/Plugtools.pm  view on Meta::CPAN

a blanked one will be created. The default is '/etc/skel'.

=head2 chmodValue

This is the numeric value the newly created home directory will be chmoded to. The default is '640'.

=head2 chmodHome

If home should be chmoded. The default value is '1', true.

=head2 chownHome

If home should be chowned. The default value is '1', true.

=head2 createHome

If this is true, it the home directory for the user will be created. The default is '1'.

=head2 groupPrimary

This is the attribute to use for when creating the DN for the group entry. Either 'cn' or
'gidNumber' are currently accepted. The default is 'cn'.



( run in 1.100 second using v1.01-cache-2.11-cpan-71847e10f99 )