From c895a3cda09f4b66ce044506b863777587dbda7c Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Sun, 2 Mar 2014 12:41:21 -0700 Subject: [PATCH] Install phase for shellinabox support. --- install/phases/boss/shellinabox | 87 +++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 install/phases/boss/shellinabox diff --git a/install/phases/boss/shellinabox b/install/phases/boss/shellinabox new file mode 100644 index 000000000..c3dd88c6b --- /dev/null +++ b/install/phases/boss/shellinabox @@ -0,0 +1,87 @@ +# +# Install shellinabox. This does not install shellinabox on ops, +# currently need to do that by hand. Get the code from Utah at +# +# git clone http://git-public.flux.utah.edu/git/shellinabox.git +# +# Then (on ops) cd into the top directory: +# +# ops> ./configure +# ops> make +# ops> sudo make install +# +use strict; +use libinstall; +use installvars; + +my $SHAREDKEY = "$PREFIX/etc/sshauth.key"; +my $LOGFILE = "$PREFIX/log/shellinabox.log"; + +sub Install($$$) +{ + my ($server, $isupdate, $impotent) = @_; + + # Replace if this script does an update for ip/domain. + return 0 + if ($isupdate); + + Phase "shellinabox", "Adding ShellInABox Support", sub { + Phase "syslog", "Setting up syslog on ops", sub { + if (ExecQuiet("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " grep -q -s shellinabox $SYSLOG_CONF")) { + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'echo \"\\\!shellinabox\" >> $SYSLOG_CONF'"); + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'echo \"*.*\t\t $LOGFILE\" >> $SYSLOG_CONF'"); + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'echo \"$LOGFILE\t\t640 7 1000 * Z\" ". + " >> $NEWSYSLOG_CONF'"); + } + }; + # + # Need a secret shared key for signing. + # + Phase "createkey", "Creating shared key", sub { + DoneIfExists($SHAREDKEY); + ExecQuietFatal("/bin/dd if=/dev/urandom count=128 bs=1 | ". + " /sbin/md5 -q > $SHAREDKEY"); + }; + Phase "copykey", "Copying shared key to users", sub { + ExecQuietFatal("$SCP -p $SHAREDKEY ${USERNODE}:${SHAREDKEY}"); + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'chmod 600 $SHAREDKEY'"); + }; + Phase "httpdconf", "Copying new httpd.conf to ops", sub { + ExecQuietFatal("$GMAKE -C $TOP_OBJDIR/apache all"); + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " '/bin/cp -fp ${INSTALL_APACHE_CONFIG}/httpd.conf ". + " ${INSTALL_APACHE_CONFIG}/httpd.conf.$$'"); + ExecQuietFatal("$SCP -p $TOP_OBJDIR/apache/httpd.conf-ops ". + " ${USERNODE}:${INSTALL_APACHE_CONFIG}/httpd.conf"); + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " $APACHE_START_COMMAND restart"); + }; + Phase "logfile", "Creating logfile on ops", sub { + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'touch $LOGFILE; chmod 640 $LOGFILE'"); + }; + Phase "json", "Installing json port on ops", sub { + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'cd /usr/ports/converters/p5-JSON; make install'"); + }; + Phase "hmac", "Installing hmac digest port on ops", sub { + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'cd /usr/ports/secret/p5-Digest-HMAC; make install'"); + }; + Phase "sha1", "Installing sha1 digest port on ops", sub { + ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ". + " 'cd /usr/ports/secret/p5-digest-SHA1; make install'"); + }; + }; + return 0; +} + +# Local Variables: +# mode:perl +# End: + -- GitLab