5 3.23 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
#
# 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";

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);
23 24 25 26 27 28 29 30 31 32 33

	    # Kill any old lines; they were hand jobs.
	    ExecQuietFatal("sed -i .orig -e '/reloadlog/d' $NEWSYSLOG_CONF");
	    ExecQuietFatal("sed -i .orig -e '/checkuplog/d' $NEWSYSLOG_CONF");
	    ExecQuietFatal("sed -i .orig -e '/poollog/d' $NEWSYSLOG_CONF");
	    ExecQuietFatal("sed -i .orig -e '/expire_dae/d' $NEWSYSLOG_CONF");
	    ExecQuietFatal("sed -i .orig -e '/sa_daemon/d' $NEWSYSLOG_CONF");
	    
	    #
	    # The ProtoGeni entries are okay; they might not be running.
	    #
34 35 36 37 38 39
	    AppendToFileFatal($NEWSYSLOG_CONF,
			      "$LOGDIR/reloadlog   640  9  1000 *  Z ".
			      "/var/run/reload_daemon.pid",
			      "$LOGDIR/checkuplog  640  9  1000 *  Z ".
			      "/var/run/checkup_daemon.pid",
			      "$LOGDIR/poollog     640  9  1000 *  Z ".
40 41 42 43 44
			      "/var/run/pool_daemon.pid",
			      "$LOGDIR/expire_daemon.log  640  9  1000 *  Z ".
			      "/var/run/expire_daemon.pid",
			      "$LOGDIR/sa_daemon.log      640  9  1000 *  Z ".
			      "/var/run/sa_daemon.pid");
45 46 47 48 49 50 51
	};
    }
    
    #
    # If something should run in the post-install phase.
    #
    if ($phase eq "post") {
52 53
	Phase "daemons", "Restarting daemons", sub {
	    Phase "reload_daemon", "Restarting reload_daemon", sub {
54 55 56 57 58
		# Old version of daemon still running.
		if (! -e "$VARRUN/reload_daemon.pid" &&
		    !ExecQuiet("pgrep -f reload_daemon")) {
		    ExecQuietFatal("pkill -f reload_daemon");
		}
59 60 61
		RestartDaemon("reload_daemon");
	    };
	    Phase "checkup_daemon", "Restarting checkup_daemon", sub {
62 63 64 65 66
		# Old version of daemon still running.
		if (! -e "$VARRUN/checkup_daemon.pid" &&
		    !ExecQuiet("pgrep -f checkup_daemon")) {
		    ExecQuietFatal("pkill -f checkup_daemon");
		}
67 68 69
		RestartDaemon("checkup_daemon");
	    };
	    Phase "pool_daemon", "Restarting pool_daemon", sub {
70 71 72 73 74
		# Old version of daemon still running.
		if (! -e "$VARRUN/pool_daemon.pid" &&
		    !ExecQuiet("pgrep -f pool_daemon")) {
		    ExecQuietFatal("pkill -f pool_daemon");
		}
75 76 77
		RestartDaemon("pool_daemon");
	    };
	    Phase "expire_daemon", "Restarting expire_daemon", sub {
78 79 80 81 82 83 84
		# Old version of daemon still running.
		if (! -e "$VARRUN/expire_daemon.pid" &&
		    !ExecQuiet("pgrep -f expire_daemon")) {
		    ExecQuietFatal("pkill -f expire_daemon");
		}
		RestartDaemon("expire_daemon",
			      "$TBROOT/sbin/protogeni/expire_daemon");
85 86
	    };
	    Phase "sa_daemon", "Restarting sa_daemon", sub {
87 88 89 90 91 92 93
		# Old version of daemon still running.
		if (! -e "$VARRUN/sa_daemon.pid" &&
		    !ExecQuiet("pgrep -f sa_daemon")) {
		    ExecQuietFatal("pkill -f sa_daemon");
		}
		RestartDaemon("sa_daemon",
			      "$TBROOT/sbin/protogeni/sa_daemon");
94 95 96
	    };
	    PhaseSucceed("Daemons Restarted");
	};
97 98 99 100
    }
    return 0;
}
1;