2 1.66 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
#
# Note that all actions *MUST* be idempotent; if this script is run
# again, it should always do the right thing, not break if something
# was already done. See boss-install for lots of example of how to use
# libinstall to help with this.
#
use strict;
use libinstall;

my $NEWSYSLOG_CONF  = "/etc/newsyslog.conf";
my $TESTBED_STARTUP = "/usr/local/etc/rc.d/3.testbed.sh";

sub InstallUpdate($$)
{
    my ($version, $phase) = @_;

    #
    # If something should run in the pre-install phase.
    #
    if ($phase eq "pre") {
	Phase "newsyslog", "Updating $NEWSYSLOG_CONF", sub {
	    DoneIfEdited($NEWSYSLOG_CONF);
	    BackUpFileFatal($NEWSYSLOG_CONF);
Leigh B Stoller's avatar
Leigh B Stoller committed
24
	    ExecQuietFatal("sed -i .orig -e '/checknodes/d' $NEWSYSLOG_CONF");
25
26
	    AppendToFileFatal($NEWSYSLOG_CONF,
			      "$LOGDIR/checknodes.log 640 14 300 ".
Leigh B Stoller's avatar
Leigh B Stoller committed
27
			      "* Z /var/run/checknodes_daemon.pid");
28
29
30
	};
	Phase "startupfile", "Updating testbed startup file", sub {
	    DoneIfIdentical("$TOP_OBJDIR/rc.d/3.testbed.sh", $TESTBED_STARTUP);
31
	    main::MarkForReboot($version);
32
33
34
35
36
37
38
39
40
41
42
	    DiffFiles("$TOP_OBJDIR/rc.d/3.testbed.sh", $TESTBED_STARTUP);
	    ExecQuietFatal("$GMAKE -C $TOP_OBJDIR/rc.d install");
	};
    }
    
    #
    # If something should run in the post-install phase.
    #
    if ($phase eq "post") {
	Phase "checknodes_daemon", "Starting up checknodes daemon", sub {
	    # Testbed not running.
43
44
45
	    if (! -e "$VARRUN/stated.pid") {
		PhaseSkip("Testbed not running");
	    }
46
47
	    # Old version of daemon still running.
	    if (-e "$VARRUN/checknodes.pid" &&
Leigh B Stoller's avatar
Leigh B Stoller committed
48
		! ExecQuiet("pgrep -f checknodes_daemon")) {
49
		SignalDaemon("checknodes", "TERM");
Leigh B Stoller's avatar
Leigh B Stoller committed
50
	    };
51
	    RestartDaemon("checknodes_daemon");
52
53
54
55
56
	};
    }
    return 0;
}
1;