syslog 5.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
#
# The template
#
use strict;
use libinstall;
use installvars;

my @LOGFILES  = ("/var/log/logins","/var/log/tiplogs/capture.log",
		 "/var/log/mountd.log", "$LOGDIR/pubsubd.log",
Leigh B Stoller's avatar
Leigh B Stoller committed
10
		 "$LOGDIR/shellinabox.log",
11
12
13
14
15
16
17
18
19
20
		 "$LOGDIR/elvin_gateway.log");

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

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

21
    if ($IMAGEUPLOADTOFS) {
22
23
24
25
	push(@LOGFILES, "$LOGDIR/mfrisbeed.log");
	push(@LOGFILES, "$LOGDIR/frisuploadd.log");
    }

26
27
28
29
30
    # Extras for Geni Racks, to handle foam stuff.
    if ($PROTOGENI_GENIRACK) {
	push(@LOGFILES, "/var/log/foam.log");
	push(@LOGFILES, "/var/log/flowvisor.log");
    }
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    #
    # Set up syslog
    #
    Phase "syslog", "Setting up syslog", sub {
	Phase "sysconf", "Editing $SYSLOG_CONF", sub {
	    DoneIfEdited($SYSLOG_CONF);
	    
	    #
	    # Can't just append to this file, unfortunately. Have to put some of
	    # the lines in the middle of the file
	    #
	    open(SC,"+<$SYSLOG_CONF") or
		PhaseFail("Unable to open $SYSLOG_CONF : $!");
	    my @sc = <SC>;
	    if (scalar(grep(/$LOGFACIL/, @sc)) != 0) {
		PhaseFail("Testbed chosen facility $LOGFACIL already in use in /etc/syslog.conf!");
	    }
	    if (scalar(grep(/^cron/, @sc)) != 1) {
		PhaseFail("Unable to find marker in /etc/syslog.conf!");
	    }

	    #
	    # Clobber and re-write
	    #
	    seek(SC,0,0);
	    truncate(SC,0);

	    foreach my $line (@sc) {
		#
		# Modify the /var/log/messages line to exclude testbed stuff
		#
		my $pat = q(\s+/var/log/messages);
		if ($line =~ /^[^#].*$pat/) {
		    $line =~ s/($pat)/\;$LOGFACIL.none$1/;
		}

		#
		# XXX don't send anything to logged in root users.
		# Per-user linktest proxies run on ops as root in a "full"
		# ssh ("-t -t") which appears as a login shell.  Thus the
		# linktest output given to the user might include syslog
		# messages.
		#
		if ($line =~ /root$/) {
		    $line =~ s/^/#/;
		}

79
80
81
82
83
84
85
86
		#
		# XXX get rid of any old pubsubd line(s)
		# (should only happen on elabinelab nodes)
		#
		if ($line =~ /pubsubd/) {
		    $line =~ s/^/#/;
		}

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
		print SC $line;

		#
		# Find the cron line, after which we place our auth.info line
		#
		if ($line =~ /^cron/) {
		    print SC "# " . MAGIC_TESTBED_START() . "\n";
		    print SC "auth.info\t\t\t\t\t/var/log/logins\n";
		    print SC "# " . MAGIC_TESTBED_END() . "\n";
		}
	    }

	    #
	    # Put a few more lines at the end
	    #
	    print SC "# " . MAGIC_TESTBED_START() . "\n";
	    print SC "!capture\n";
	    print SC "*.*\t\t\t\t\t\t/var/log/tiplogs/capture.log\n";
	    print SC "!mountd\n";
	    print SC "*.*\t\t\t\t\t\t/var/log/mountd.log\n";
	    print SC "!pubsubd\n";
	    print SC "*.*\t\t\t\t\t\t${LOGDIR}/pubsubd.log\n";
	    print SC "!elvin_gateway\n";
	    print SC "*.*\t\t\t\t\t\t${LOGDIR}/elvin_gateway.log\n";
Leigh B Stoller's avatar
Leigh B Stoller committed
111
112
	    print SC "!shellinabox\n";
	    print SC "*.*\t\t\t\t\t\t${LOGDIR}/shellinabox.log\n";
113
	    if ($IMAGEUPLOADTOFS) {
114
115
116
117
118
		print SC "!mfrisbeed\n";
		print SC "*.*\t\t\t\t\t\t${LOGDIR}/mfrisbeed.log\n";
		print SC "!frisuploadd\n";
		print SC "*.*\t\t\t\t\t\t${LOGDIR}/frisuploadd.log\n";
	    }
119
120
	    if ($PROTOGENI_GENIRACK) {
		print SC "!foam\n";
121
		print SC "*.*\t\t\t\t\t\t/var/log/foam.log\n";
122
		print SC "!flowvisor\n";
123
		print SC "*.*\t\t\t\t\t\t/var/log/flowvisor.log\n";
124
	    }
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	    print SC "# " . MAGIC_TESTBED_END() . "\n";
	    close SC;
	};

	Phase "tiplog", "Creating $TIPLOG_DIR", sub {
	    DoneIfExists($TIPLOG_DIR);
	    mkdir($TIPLOG_DIR,0755) or PhaseFail("Unable to make $TIPLOG_DIR : $!");
	};
	
	Phase "logdir", "Creating log directory", sub {
	    DoneIfExists($LOGDIR);
	    mkdir $LOGDIR, 0775 or PhaseFail("Unable to create $LOGDIR : $!");
	    ExecQuietFatal("$CHGRP tbadmin $LOGDIR");
	    ExecQuietFatal("$CHMOD 775 $LOGDIR");
	};

	Phase "mysql-logdir", "Creating mysql log directory", sub {
	    DoneIfExists($MYSQL_LOGDIR);
	    mkdir $MYSQL_LOGDIR, 0775 or
		PhaseFail("Unable to create $MYSQL_LOGDIR : $!");
	    ExecQuietFatal("$CHOWN mysql:mysql $MYSQL_LOGDIR");
	    ExecQuietFatal("$CHMOD 775 $MYSQL_LOGDIR");
	};

	Phase "logfiles", "Creating log files", sub {
	    foreach my $logfile (@LOGFILES) {
		Phase $logfile, $logfile, sub {
		    DoneIfExists($logfile);
		    CreateFileFatal($logfile);
		    ExecQuietFatal("$CHGRP tbadmin $logfile");
		    ExecQuietFatal("$CHMOD 640 $logfile");
		};
	    }
	};

	Phase "newsyslog", "Setting up $NEWSYSLOG_CONF", sub {
	    DoneIfEdited($NEWSYSLOG_CONF);
	    AppendToFileFatal($NEWSYSLOG_CONF,
163
164
165
166
167
		"/var/log/logins\t\t\t\t640  7     200 *      Z",
		"/var/log/mountd.log\t\t\t640  5     200 *      Z",
		"$LOGDIR/pubsubd.log\t\t\t640  5     1000 *     Z",
		"$LOGDIR/elvin_gateway.log\t\t\t640  5     1000 *     Z",
		"/var/log/tiplogs/capture.log\t\t644  7     *    168   Z",
168
169
		"/var/log/foam.log\t\t640  7     *    168   Z",
		"/var/log/flowvisor.log\t\t640  7    1000 *    Z",
Leigh B Stoller's avatar
Leigh B Stoller committed
170
		"$LOGDIR/shellinabox.log\t\t640  7    1000 *    Z",
171
172
		"$LOGDIR/mfrisbeed.log\t\t640  7    1000 *    Z",
		"$LOGDIR/frisuploadd.log\t\t640  7    1000 *    Z",
173
		);
174
175
176
177
178
179
180
181
182
	};
    };

    return 0;
}

# Local Variables:
# mode:perl
# End: