openbsd-ports/net/nfr/files/createuser

47 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl
#
# $OpenBSD: createuser,v 1.1.1.1 1998/07/04 20:52:53 marc 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.
$nfr_home = $ENV{'NFRHOME'};
if (!$nfr_home) {
$nfr_home = "/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");