2 # Add a user to the system wide wikilist.
3 # This script can safely be made suid or put in /etc/sudoers.
8 my $remove=(@ARGV && $ARGV[0] eq '-r');
10 my $username=getpwuid($REAL_USER_ID);
11 if (! defined $username || ! length $username) {
12 die "unable to determine user name for UID $REAL_USER_ID\n";
15 my $wikilist="/etc/ikiwiki/wikilist";
17 die "$wikilist does not exist\n";
23 open (my $list, "<$wikilist") || die "read $wikilist: $!";
26 if (/^\s*([^\s]+)\s*$/) {
28 if ($user eq $username) {
45 if (! $seen && ! $remove) {
46 push @lines, $username;
50 close $list || die "ikiwiki-update-wikilist: error reading $list: $!\n";
51 open ($list, ">$wikilist") || die "ikiwiki-update-wikilist: cannot write to $wikilist\n";
56 print "ikiwiki-update-wikilist: removed user $username from $wikilist\n";
59 print "ikiwiki-update-wikilist: added user $username to $wikilist\n";
61 close $list || die "ikiwiki-update-wikilist: error writing $wikilist: $!\n";
64 print "ikiwiki-update-wikilist: no changes need to be made\n";