source: trunk/test/testrun_2b.sh@ 22

Last change on this file since 22 was 22, checked in by rainer, 19 years ago

Minor code revisions.

File size: 5.3 KB
Line 
1#! /bin/sh
2
3LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
4RCFILE="$PW_DIR/testrc_2"; export RCFILE
5RCFILE_C="$PW_DIR/testrc_1.dyn"; export RCFILE_C
6
7SERVER_BUILDOPTS="--quiet $TRUST --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"; export SERVER_BUILDOPTS
8
9CLIENT_BUILDOPTS="--quiet $TRUST --enable-micro-stealth=137 --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER${RCFILE_C} --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
10
11testrun2b_internal ()
12{
13 GPG="$1"
14
15 [ -z "$verbose" ] || {
16 echo;
17 echo Working directory: $PW_DIR; echo MAKE is $MAKE; echo GPG is $GPG;
18 echo;
19 }
20
21 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
22
23 if test -r "Makefile"; then
24 $MAKE distclean
25 fi
26
27 ${TOP_SRCDIR}/configure --with-gpg=${GPG} --with-checksum=no ${CLIENT_BUILDOPTS} >/dev/null 2>&1
28
29 if test x$? = x0; then
30 [ -z "$verbose" ] || log_msg_ok "configure...";
31 $MAKE > /dev/null 2>>test_log
32 if test x$? = x0; then
33 [ -z "$verbose" ] || log_msg_ok "make...";
34 else
35 [ -z "$quiet" ] && log_msg_fail "make...";
36 return 1
37 fi
38 else
39 [ -z "$quiet" ] && log_msg_fail "configure...";
40 return 1
41 fi
42
43 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
44
45 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
46 if [ $? -eq 0 ]; then
47 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
48 mv "./testrc.gpg.asc" "${RCFILE_C}"
49 else
50 tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
51 mv "./testrc.gpg.asc" "${RCFILE_C}"
52 fi
53 if test x$? = x0; then
54 [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
55 else
56 [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
57 return 1
58 fi
59
60 # save binary and build server
61
62 cp samhain samhain.build || return 1
63 make clean >/dev/null || return 1
64
65 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
66
67 if test x$? = x0; then
68 [ -z "$verbose" ] || log_msg_ok "configure...";
69 $MAKE > /dev/null 2>>test_log
70 if test x$? = x0; then
71 [ -z "$verbose" ] || log_msg_ok "make...";
72 else
73 [ -z "$quiet" ] && log_msg_fail "make...";
74 return 1
75 fi
76
77 else
78 [ -z "$quiet" ] && log_msg_fail "configure...";
79 return 1
80 fi
81
82
83 #####################################################################
84 #
85 #
86 rm -f ./.samhain_file
87 rm -f ./.samhain_log
88 rm -f ./.samhain_lock
89 rm -f ./rc.${SH_LOCALHOST}
90 rm -f ./file.${SH_LOCALHOST}
91
92 cp ${SCRIPTDIR}/testrc_2.in testrc_2
93
94 ./samhain.build -t init -p none
95
96 if test x$? = x0; then
97 [ -z "$verbose" ] || log_msg_ok "init...";
98 else
99 [ -z "$quiet" ] && log_msg_fail "init...";
100 return 1
101 fi
102
103 # Create a password
104
105 SHPW=`./yule -G`
106 if test x"$SHPW" = x; then
107 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
108 return 1
109 fi
110
111 # Set in client
112
113 ./samhain_setpwd samhain.build new $SHPW >/dev/null
114
115 if test x$? = x0; then
116 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
117 else
118 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
119 return 1
120 fi
121
122 mv samhain.build.new samhain.new || return 1
123
124 rm -f ./.samhain_log*
125 rm -f ./.samhain_lock
126
127 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
128
129 if test x$? = x0; then
130 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
131 else
132 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
133 return 1
134 fi
135
136 echo $SHCLT >> testrc_2
137
138 cp "${RCFILE_C}" ./rc.${SH_LOCALHOST}
139 mv $PW_DIR/.samhain_file.asc ./file.${SH_LOCALHOST}
140
141 ALTHOST=`find_hostname`
142 cp "${RCFILE_C}" "./rc.${ALTHOST}"
143 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
144}
145
146MAXTEST=1; export MAXTEST
147
148testrun2b ()
149{
150 log_start "RUN FULL CLIENT/SERVER W/GPG";
151 #
152 if [ x"$1" = x ]; then
153 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
154 fi
155 #
156 GPG=`find_path gpg`
157 if [ -z "$GPG" ]; then
158 log_skip 1 $MAXTEST 'gpg not found in $PATH'
159 else
160 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
161 if [ $? -ne 0 ]; then
162 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
163 else
164
165 SH_LOCALHOST=$1; export SH_LOCALHOST
166
167 testrun2b_internal "$GPG"
168
169 SAVE_VALGRIND="${VALGRIND}"; VALGRIND=''; export VALGRIND
170 do_test_1_a
171 VALGRIND="${SAVE_VALGRIND}"; export VALGRIND
172 if [ $? -eq 0 ]; then
173 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging w/gpg";
174 else
175 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging w/gpg";
176 fi
177
178 if [ -n "$cleanup" ]; then
179 rm -f ./rc.${SH_LOCALHOST}
180 rm -f ./file.${SH_LOCALHOST}
181 ALTHOST=`find_hostname`
182 rm -f "./file.${ALTHOST}"
183 rm -f "./rc.${ALTHOST}"
184 fi
185 fi
186 fi
187 log_end "RUN FULL CLIENT/SERVER W/GPG"
188}
189
Note: See TracBrowser for help on using the repository browser.