-my @args = ( 'htpasswd' );
-push @args, '-c' if $opt_c;
-push @args, $opt_h, $user;
-system(@args) == 0 or die "htpasswd failed: $?";
+#if ( -e "$FREESIDE_CONF/mapsecrets" ) {
+# open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
+# or die "can't open $FREESIDE_CONF/mapsecrets: $!";
+# while (<MAPSECRETS>) {
+# /^(\S+) / or die "unparsable line in mapsecrets: $_";
+# die "user $user already exists\n" if $user eq $1;
+# }
+# close MAPSECRETS;
+#}
+
+if ( $opt_h ) {
+ my @args = ( 'htpasswd' );
+ push @args, '-b' if $opt_b;
+ push @args, '-c' if $opt_c;
+ push @args, $opt_h, $user;
+ push @args, shift if $opt_b;
+ #warn join(', ', @args)."\n";
+ system(@args) == 0 or die "htpasswd failed: $?";
+}
+
+if ( $opt_s ) {
+ open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets")
+ and flock(MAPSECRETS,LOCK_EX)
+ or die "can't open $FREESIDE_CONF/mapsecrets: $!";
+ print MAPSECRETS "$user $opt_s\n";
+ close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
+}
+
+###
+
+exit if $opt_n;
+
+###
+
+use FS::UID qw(adminsuidsetup);
+use FS::CurrentUser;
+use FS::access_user;
+use FS::access_usergroup;
+
+$FS::CurrentUser::upgrade_hack = 1;
+#adminsuidsetup $rootuser;
+adminsuidsetup $user;