45 lines
1.1 KiB
Perl
Executable File
45 lines
1.1 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
#
|
|
# $OpenBSD: createuser,v 1.2 1999/03/06 22:51:40 dugsong Exp $
|
|
#
|
|
# Create the NFR user and group, if they don't already exist.
|
|
|
|
if ($>) {
|
|
print "\nYou must be root to run this step!\n\n";
|
|
exit 1;
|
|
}
|
|
|
|
# Find NFR homedir.
|
|
$prefix = $ENV{'PREFIX'};
|
|
$nfr_home = $prefix . "/nfr";
|
|
|
|
# Create NFR group if it doesn't exist.
|
|
if (getgrnam("nfr")) {
|
|
($null, $null, $nfr_gid) = getgrnam("nfr");
|
|
}
|
|
else {
|
|
$nfr_gid = 42;
|
|
while (getgrgid($nfr_gid)) {
|
|
$nfr_gid++;
|
|
}
|
|
print("Creating NFR group 'nfr' with gid $nfr_gid\n");
|
|
system("echo nfr:\*:$nfr_gid: >> /etc/group");
|
|
}
|
|
|
|
# Create NFR user if it doesn't exist.
|
|
if (getpwnam("nfr")) {
|
|
($null, $null, $nfr_uid) = getpwnam("nfr");
|
|
}
|
|
else {
|
|
$nfr_uid = 42;
|
|
while (getpwuid($nfr_uid)) {
|
|
$nfr_uid++;
|
|
}
|
|
($null, $null, $nfr_gid) = getgrnam("nfr");
|
|
print "Creating NFR user 'nfr' with uid $nfr_uid, gid $nfr_gid\n";
|
|
system( "/usr/bin/chpass -a \"nfr:*:$nfr_uid:$nfr_gid:\:\:\:Network Flight Recorder:$nfr_home:/sbin/nologin\"" );
|
|
}
|
|
|
|
print("Using NFR user 'nfr' with uid $nfr_uid, gid $nfr_gid, and homedir $nfr_home\n\n");
|
|
|