1 | #! /bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright Rainer Wichmann (2006)
|
---|
5 | #
|
---|
6 | # License Information:
|
---|
7 | # This program is free software; you can redistribute it and/or modify
|
---|
8 | # it under the terms of the GNU General Public License as published by
|
---|
9 | # the Free Software Foundation; either version 2 of the License, or
|
---|
10 | # (at your option) any later version.
|
---|
11 | #
|
---|
12 | # This program is distributed in the hope that it will be useful,
|
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | # GNU General Public License for more details.
|
---|
16 | #
|
---|
17 | # You should have received a copy of the GNU General Public License
|
---|
18 | # along with this program; if not, write to the Free Software
|
---|
19 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | #
|
---|
21 |
|
---|
22 | SERVER_BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-debug --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-database=mysql"; export SERVER_BUILDOPTS
|
---|
23 |
|
---|
24 | CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
|
---|
25 |
|
---|
26 | check_mysql_log () {
|
---|
27 | DATE="$1"
|
---|
28 |
|
---|
29 | rm -f test_log_db
|
---|
30 | #
|
---|
31 | echo "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '"${DATE}"';" | mysql --password=samhain -u samhain samhain >test_log_db
|
---|
32 | #
|
---|
33 | egrep "START.*Yule" test_log_db >/dev/null 2>&1
|
---|
34 | if [ $? -ne 0 ]; then
|
---|
35 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
36 | return 1
|
---|
37 | fi
|
---|
38 | egrep "NEW CLIENT" test_log_db >/dev/null 2>&1
|
---|
39 | if [ $? -ne 0 ]; then
|
---|
40 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
41 | return 1
|
---|
42 | fi
|
---|
43 | egrep "Checking.*/bin" test_log_db >/dev/null 2>&1
|
---|
44 | if [ $? -ne 0 ]; then
|
---|
45 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
46 | return 1
|
---|
47 | fi
|
---|
48 | egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1
|
---|
49 | if [ $? -ne 0 ]; then
|
---|
50 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
51 | return 1
|
---|
52 | fi
|
---|
53 | egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1
|
---|
54 | if [ $? -ne 0 ]; then
|
---|
55 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
56 | return 1
|
---|
57 | fi
|
---|
58 | return 0
|
---|
59 | }
|
---|
60 |
|
---|
61 | MAXTEST=1; export MAXTEST
|
---|
62 |
|
---|
63 | testrun2c ()
|
---|
64 | {
|
---|
65 | log_start "RUN FULL CLIENT/SERVER W/MYSQL"
|
---|
66 | #
|
---|
67 | if [ -z "$doall" ]; then
|
---|
68 | log_skip 1 $MAXTEST 'Client/server w/mysql (or use --really-all)'
|
---|
69 | return 0
|
---|
70 | fi
|
---|
71 | if [ x"$1" = x ]; then
|
---|
72 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
73 | fi
|
---|
74 | MYSQL=`find_path mysql`
|
---|
75 | if [ -z "$MYSQL" ]; then
|
---|
76 | log_skip 1 $MAXTEST "mysql not found";
|
---|
77 | return 1
|
---|
78 | else
|
---|
79 | TEST=`echo "DESCRIBE log;" | mysql --password=samhain -u samhain samhain 2>/dev/null`
|
---|
80 | if [ $? -ne 0 -o -z "$TEST" ]; then
|
---|
81 | log_skip 1 $MAXTEST "mysql not default setup"
|
---|
82 | return 1
|
---|
83 | fi
|
---|
84 | fi
|
---|
85 | #
|
---|
86 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
87 | #
|
---|
88 | DATE=`date '+%Y-%m-%d %T'`
|
---|
89 | #
|
---|
90 | testrun2a_internal
|
---|
91 | #
|
---|
92 | ORIGINAL="DatabaseSeverity=none"
|
---|
93 | REPLACEMENT="DatabaseSeverity=info"
|
---|
94 | ex -s $RCFILE <<EOF
|
---|
95 | %s/$ORIGINAL/$REPLACEMENT/g
|
---|
96 | wq
|
---|
97 | EOF
|
---|
98 | #
|
---|
99 | do_test_1_a
|
---|
100 | if [ $? -ne 0 ]; then
|
---|
101 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql";
|
---|
102 | else
|
---|
103 | #
|
---|
104 | check_mysql_log "${DATE}"
|
---|
105 | if [ $? -ne 0 ]; then
|
---|
106 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql";
|
---|
107 | else
|
---|
108 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/mysql";
|
---|
109 | fi
|
---|
110 | fi
|
---|
111 | #
|
---|
112 | if [ -n "$cleanup" ]; then
|
---|
113 | rm -f ./rc.${SH_LOCALHOST}
|
---|
114 | rm -f ./file.${SH_LOCALHOST}
|
---|
115 | ALTHOST=`find_hostname`
|
---|
116 | rm -f "./file.${ALTHOST}"
|
---|
117 | rm -f "./rc.${ALTHOST}"
|
---|
118 | fi
|
---|
119 | #
|
---|
120 | log_end "RUN FULL CLIENT/SERVER W/MYSQL"
|
---|
121 | }
|
---|
122 |
|
---|