2 # Add a user to the system wide wikilist.
3 # This script can safely be made suid or put in /etc/sudoers.
9 my $remove=(@ARGV && $ARGV[0] eq '-r');
11 my $username=getpwuid($REAL_USER_ID);
12 if (! defined $username || ! length $username) {
13 die "unable to determine user name for UID $REAL_USER_ID\n";
16 my $wikilist="/etc/ikiwiki/wikilist";
18 die "$wikilist does not exist\n";
24 open (my $list, "<$wikilist") || die "read $wikilist: $!";
27 if (/^\s*([^\s]+)\s*$/) {
29 if ($user eq $username) {
46 if (! $seen && ! $remove) {
47 push @lines, $username;
51 close $list || die "ikiwiki-update-wikilist: error reading $list: $!\n";
52 open ($list, ">$wikilist") || die "ikiwiki-update-wikilist: cannot write to $wikilist\n";
57 print "ikiwiki-update-wikilist: removed user $username from $wikilist\n";
60 print "ikiwiki-update-wikilist: added user $username to $wikilist\n";
62 close $list || die "ikiwiki-update-wikilist: error writing $wikilist: $!\n";
65 print "ikiwiki-update-wikilist: no changes need to be made\n";