1 | #! /bin/sh
|
---|
2 |
|
---|
3 | 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=postgresql"; export SERVER_BUILDOPTS
|
---|
4 |
|
---|
5 | CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$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
|
---|
6 |
|
---|
7 | check_psql_log () {
|
---|
8 | DATE="$1"
|
---|
9 |
|
---|
10 | rm -f test_log_db
|
---|
11 | PGPASSWORD=samhain; export PGPASSWORD
|
---|
12 | psql -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';" >test_log_db
|
---|
13 | #
|
---|
14 | egrep "START.*Yule" test_log_db >/dev/null 2>&1
|
---|
15 | if [ $? -ne 0 ]; then
|
---|
16 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
17 | return 1
|
---|
18 | fi
|
---|
19 | egrep "NEW CLIENT" test_log_db >/dev/null 2>&1
|
---|
20 | if [ $? -ne 0 ]; then
|
---|
21 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
22 | return 1
|
---|
23 | fi
|
---|
24 | egrep "Checking.*/bin" test_log_db >/dev/null 2>&1
|
---|
25 | if [ $? -ne 0 ]; then
|
---|
26 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
27 | return 1
|
---|
28 | fi
|
---|
29 | egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1
|
---|
30 | if [ $? -ne 0 ]; then
|
---|
31 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
32 | return 1
|
---|
33 | fi
|
---|
34 | egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1
|
---|
35 | if [ $? -ne 0 ]; then
|
---|
36 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
37 | return 1
|
---|
38 | fi
|
---|
39 | return 0
|
---|
40 | }
|
---|
41 |
|
---|
42 | MAXTEST=1; export MAXTEST
|
---|
43 |
|
---|
44 | testrun2d ()
|
---|
45 | {
|
---|
46 | log_start "RUN FULL CLIENT/SERVER W/POSTGRESQL"
|
---|
47 | #
|
---|
48 | if [ -z "$doall" ]; then
|
---|
49 | log_skip 1 $MAXTEST 'Client/server w/postgresql (or use --really-all)'
|
---|
50 | return 0
|
---|
51 | fi
|
---|
52 | if [ x"$1" = x ]; then
|
---|
53 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
54 | fi
|
---|
55 | PSQL=`find_path psql`
|
---|
56 | if [ -z "$PSQL" ]; then
|
---|
57 | log_skip 1 $MAXTEST "psql not found";
|
---|
58 | return 1
|
---|
59 | else
|
---|
60 | PGPASSWORD="samhain"; export PGPASSWORD
|
---|
61 | TEST=`psql -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null`
|
---|
62 | if [ $? -ne 0 -o -z "$TEST" ]; then
|
---|
63 | log_skip 1 $MAXTEST "psql not default setup"
|
---|
64 | return 1
|
---|
65 | fi
|
---|
66 | fi
|
---|
67 | #
|
---|
68 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
69 | #
|
---|
70 | DATE=`date '+%Y-%m-%d %T'`
|
---|
71 | #
|
---|
72 | testrun2a_internal
|
---|
73 | #
|
---|
74 | ORIGINAL="DatabaseSeverity=none"
|
---|
75 | REPLACEMENT="DatabaseSeverity=info"
|
---|
76 | ex $RCFILE <<EOF
|
---|
77 | :%s/$ORIGINAL/$REPLACEMENT/g
|
---|
78 | :wq
|
---|
79 | EOF
|
---|
80 | #
|
---|
81 | do_test_1_a
|
---|
82 | #
|
---|
83 | if [ $? -ne 0 ]; then
|
---|
84 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
|
---|
85 | else
|
---|
86 | #
|
---|
87 | check_psql_log "${DATE}"
|
---|
88 | if [ $? -ne 0 ]; then
|
---|
89 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
|
---|
90 | else
|
---|
91 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/postgresql";
|
---|
92 | fi
|
---|
93 | fi
|
---|
94 | #
|
---|
95 | if [ -n "$cleanup" ]; then
|
---|
96 | rm -f ./rc.${SH_LOCALHOST}
|
---|
97 | rm -f ./file.${SH_LOCALHOST}
|
---|
98 | ALTHOST=`find_hostname`
|
---|
99 | rm -f "./file.${ALTHOST}"
|
---|
100 | rm -f "./rc.${ALTHOST}"
|
---|
101 | fi
|
---|
102 | #
|
---|
103 | log_end "RUN FULL CLIENT/SERVER W/POSTGRESQL"
|
---|
104 | }
|
---|
105 |
|
---|