shellinabox 2.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#
# Install shellinabox using source code from Utah.
#
use strict;
use libinstall;
use installvars;

sub Install($$$)
{
    my ($server, $isupdate, $impotent) = @_;

    # Replace if this script does an update for ip/domain.
    return 0
	if ($isupdate);

    my $SOURCEURL     = "http://$OUTER_BOSS/downloads/shellinabox.tar.Z";
    my $SOURCEDIR     = "$PREFIX/src/shellinabox";
    my $BUILDDIR      = "$PREFIX/obj/shellinabox";
    my $localtarfile  = "/tmp/shellinabox.tar.gz";
    my $LOGFILE       = "$PREFIX/log/shellinabox.log";

    Phase "shellinabox", "Installing shellinabox", sub {
	PhaseSkip("shellinabox not enabled")
	    if (!$BROWSER_CONSOLE_ENABLE);
	
	Phase "fetching", "Fetching shellinabox distribution", sub {
	    DoneIfExists($localtarfile);
	    FetchFileFatal($SOURCEURL, $localtarfile);
	};

	Phase "unpacking", "Unpacking shellinabox distribution", sub {
	    if (! -e "$SOURCEDIR") {
		mkdir("$SOURCEDIR", 0770) or
		    PhaseFail("Unable to make $SOURCEDIR : $!");
	    }
	    ExecQuietFatal("$CHOWN elabman $SOURCEDIR");
	    PhaseSkip("shellinabox already unpacked")
		if (-e "$SOURCEDIR/shellinabox");
	    ExecQuietFatal("$TAR zxf $localtarfile -C $SOURCEDIR"); 
	};
	Phase "config", "Configuring shellinabox", sub {
	    if (! -e "$BUILDDIR") {
		mkdir("$BUILDDIR", 0770) or
		    PhaseFail("Unable to make $BUILDDIR : $!");
	    }
	    ExecQuietFatal("$CHOWN elabman $BUILDDIR");
	    ExecQuietFatal("cd $BUILDDIR ; $SOURCEDIR/shell*/configure ");
	};
	Phase "building", "Building shellinabox", sub {
	    ExecQuietFatal("cd $BUILDDIR; make");
	};
	Phase "installing", "Installing", sub {
	    ExecQuietFatal("cd $BUILDDIR; make install");
	};
	Phase "json", "Installing json port", sub {
56
	    DoneIfPackageInstalled("p5-JSON");
57 58 59
	    ExecQuietFatal("cd /usr/ports/converters/p5-JSON; make install");
	};
	Phase "hmac", "Installing hmac digest port", sub {
60
	    DoneIfPackageInstalled("p5-Digest-HMAC");
61 62 63
	    ExecQuietFatal("cd /usr/ports/security/p5-Digest-HMAC; make install");
	};
	Phase "sha1", "Installing sha1 digest port", sub {
64
	    DoneIfPackageInstalled("p5-Digest-SHA1");
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
	    ExecQuietFatal("cd /usr/ports/security/p5-Digest-SHA1; make install");
	};
	Phase "logfile", "Creating $LOGFILE", sub {
	    ExecQuietFatal("touch $LOGFILE; chmod 640 $LOGFILE");
	};
	Phase "syslog", "Setting up syslog", sub {
	    if (ExecQuiet("grep -q -s shellinabox $SYSLOG_CONF")) {
		ExecQuietFatal("echo '!shellinabox' >> $SYSLOG_CONF");
		ExecQuietFatal("echo '*.*\t\t $LOGFILE' >> $SYSLOG_CONF");
		ExecQuietFatal("echo '$LOGFILE\t\t640   7 1000 *    Z' ".
			       "   >> $NEWSYSLOG_CONF");
	    }
	};
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: