mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-18 00:10:04 +00:00
587c8c488f
group already exist.
62 lines
1.5 KiB
Perl
62 lines
1.5 KiB
Perl
#!/usr/bin/perl
|
|
#
|
|
|
|
eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
|
|
& eval 'exec /usr/bin/perl -S $0 $argv:q'
|
|
if 0;
|
|
|
|
if( ! -x "/usr/sbin/pw" ) {
|
|
print "\nYou require the pw command, which was included in FreeBSD v2.2 builds\n";
|
|
print "as of Dec 9th 1996. If you don't have it, try looking in\n";
|
|
print "/usr/src/usr.sbin/pw and building it\n\n";
|
|
exit 1;
|
|
}
|
|
|
|
if( getpwnam( "majordom" ) ) {
|
|
$have_user = 1;
|
|
( $null, $null, $mjUID ) = getpwnam( "majordom" );
|
|
} else {
|
|
$mjUID = 54;
|
|
while( getpwuid( $mjUID ) ) {
|
|
$mjUID++;
|
|
}
|
|
}
|
|
|
|
if( getgrnam( "majordom" ) ) {
|
|
$have_group = 1;
|
|
( $null, $null, $mjGID ) = getgrnam( "majordom" );
|
|
} else {
|
|
$mjGID = 54;
|
|
while( getgrgid( $mjGID ) ) {
|
|
$mjGID++;
|
|
}
|
|
}
|
|
|
|
if( $have_group && $have_user ) {
|
|
exit 0;
|
|
} elsif( $> ) {
|
|
print "\nYou must be root to run this step!\n\n";
|
|
exit 1;
|
|
}
|
|
|
|
print "majordom user using uid $mjUID\n";
|
|
print "majordom user using gid $mjGID\n";
|
|
|
|
if( ! $have_group ) {
|
|
$result = system( "/usr/sbin/pw groupadd majordom -g $mjGID" );
|
|
if( $result ) {
|
|
print "Failed to add group majordom!\n";
|
|
exit 1;
|
|
}
|
|
}
|
|
|
|
if( ! $have_user ) {
|
|
$result = system( "pw useradd majordom -u $mjUID -g $mjGID -d \"$ENV{PREFIX}/majordomo\" -c \"Majordomo Pseudo User\" -p \"*\" -s \"/nonexistent\"" );
|
|
} else {
|
|
$result = system( "pw usermod majordom -u $mjUID -g $mjGID -d \"$ENV{PREFIX}/majordomo\" -c \"Majordomo Pseudo User\" -p \"*\" -s \"/nonexistent\"" );
|
|
}
|
|
if( $result ) {
|
|
print "Failed to add/modify user majordom!\n";
|
|
exit 1;
|
|
}
|