rlm@2: #!/usr/bin/env perl rlm@2: rlm@2: if ($ARGV[0] eq "--help"){ rlm@2: print <<"HERE"; rlm@2: rlm@2: pkg -- create a package user. rlm@2: rlm@2: syntax: rlm@2: pkg package-name description rlm@2: pkg --help rlm@2: rlm@2: Create a package user for the purpose of compiling rlm@2: a particular package. rlm@2: rlm@2: The user will be created with user and group both rlm@2: equal to the name you specify. rlm@2: rlm@2: You will then be put into the user's home rlm@2: directory where you may proceed with rlm@2: compiling/installation of the package. rlm@2: rlm@2: If the user already exists, this is equivalent to rlm@2: su package-name; cd ~; rlm@2: rlm@2: Written by Robert McIntyre. This software is free rlm@2: software and is released to the public domain. rlm@2: rlm@2: HERE rlm@2: exit 0; rlm@2: } rlm@2: rlm@2: rlm@2: $pkg_name = $ARGV[0]; rlm@2: rlm@2: $pkg_desc = $ARGV[1]; rlm@2: rlm@2: # Validate pkg_user as a user name. rlm@2: if (!($pkg_name =~ m/^[A-Za-z][A-Za-z0-9_-]*$/)){ rlm@2: print "$pkg_name is not a valid user name!\n"; rlm@2: exit 0; rlm@2: } rlm@2: rlm@2: # Validate description. rlm@2: if ($pkg_desc =~ m/:/){ rlm@2: print "Package Description cannot contain \":\"\n"; rlm@2: exit 0 rlm@2: } rlm@2: rlm@2: rlm@2: print "name: $pkg_name\ndesc: $pkg_desc\n"; rlm@2: rlm@2: