# # The template # use strict; use libinstall; use installvars; my $EXTRADSA_KEY = "$main::TOP_SRCDIR/install/elabinelab.pub"; sub Install($$$) { my ($server, $isupdate, $impotent) = @_; # Replace if this script does an update for ip/domain. return 0 if ($isupdate); Phase "firstuser", "Setting up initial user ($PROTOUSER)", sub { Phase "firstuser", "Calling 'firstuser' to create account", sub { PhaseSkip("$PROTOUSER already created") if (-d "$USERROOT/$PROTOUSER"); ExecQuietFatal("perl $TOP_OBJDIR/utils/firstuser -b ". (defined($password) ? " -p " . EscapeShellArg($password) : "")); }; Phase "Fixing", "Fixing up DB state for $PROTOUSER", sub { my ($exitval, @rows) = ExecQuiet("echo 'select uid from users ". " where uid=\"$PROTOUSER\" and webonly=0' ". "| $MYSQL -s $DBNAME"); if ($exitval) { PhaseFail("Error running query"); } if (scalar @rows) { PhaseSkip("Already done"); } ExecQuietFatal("echo 'update users set webonly=0 ". " where uid=\"$PROTOUSER\"' | $MYSQL -s $DBNAME"); }; Phase "Thawing", "Thawing $PROTOUSER", sub { my ($exitval, @rows) = ExecQuiet("echo 'select uid from users ". " where uid=\"$PROTOUSER\" and status=\"active\"' ". "| $MYSQL -s $DBNAME"); if ($exitval) { PhaseFail("Error running query"); } if (scalar @rows) { PhaseSkip("Already done"); } ExecQuietFatal("echo 'update users set status=\"active\" ". " where uid=\"$PROTOUSER\"' | $MYSQL -s $DBNAME"); ExecQuietFatal("$SUDO -u $PROTOUSER $WAP $TBACCT -b thaw $PROTOUSER"); }; # # Note that account/tbacct has a special case for the protouser; # the initial unencrypted keys are not created, so this check works. # Phase "DSAKey", "Adding DSA key to $PROTOUSER account", sub { my ($exitval, @rows) = ExecQuiet("echo 'select * from user_pubkeys ". " where uid=\"$PROTOUSER\"' | $MYSQL -s $DBNAME"); if ($exitval) { PhaseFail("Error running query"); } if (scalar @rows) { PhaseSkip("Already done"); } ExecQuietFatal("$SUDO -u $PROTOUSER $WAP ". " $ADDPUBKEY -f -u $PROTOUSER $PROTOUSER_KEY"); }; Phase "DSAKey2", "Adding Extra DSA key to $PROTOUSER account", sub { PhaseSkip("No key found") if (! -e $EXTRADSA_KEY); ExecQuietFatal("$SUDO -u $PROTOUSER $WAP ". " $ADDPUBKEY -R -f -u $PROTOUSER $EXTRADSA_KEY"); }; Phase "authkeys", "Generating authorized_keys for $PROTOUSER", sub { ExecQuietFatal("$SUDO -u $PROTOUSER $WAP $ADDPUBKEY -w $PROTOUSER"); }; }; return 0; } # Local Variables: # mode:perl # End: