AlternC/src/mem_add

44 lines
795 B
Plaintext
Raw Normal View History

#!/usr/bin/perl
use strict;
my ($name,$uid) = @ARGV;
if (!$name || !$uid) {
print "Usage: sudo mem_add <name> <uid>\n";
print " Create the AlternC account <name> having uid number <uid>\n";
exit(1);
}
$ENV{PATH} = "";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
if (!($name =~ /^([a-z0-9]+)$/)) {
die "Account name is incorrect.";
}
$name=$1;
if (!($uid =~ /^([0-9]+)$/)) {
die "uid is incorrect.";
}
$uid=$1;
if ( $< != 0 ) {
die "please launch mem_add as root (or using sudo)";
}
#$< = $>;
#$( = $);
my $PTH="/var/alternc/html/".substr($name,0,1)."/".$name;
my @create_paths = ($PTH);
for my $p (@create_paths) {
mkdir($p);
2011-05-22 17:23:59 +00:00
chown($uid, $uid, $p);
system("/bin/chmod 02770 '$p'");
2012-06-26 08:08:49 +00:00
system("/usr/lib/alternc/fixperms.sh -u '$uid' ");
}
0;