source: trunk/test/testrun_2b.sh@ 17

Last change on this file since 17 was 1, checked in by katerina, 19 years ago

Initial import

File size: 5.5 KB
RevLine 
[1]1#! /bin/sh
2
3
4# The following two are the ANSI sequences for start and end embolden
5case $TERM in
6vt*|ansi*|con*|xterm*|linux*|screen*)
7 S=[1m
8 E=[m
9 ;;
10*)
11 S=
12 E=
13 ;;
14esac
15
16PW_DIR=`pwd`
17
18if test x$UID != x; then
19 TRUST="--with-trusted=0,2,$UID"
20else
21 TRUST="--with-trusted=0,2"
22fi
23
24TEST_MYSQL=
25# TEST_MYSQL=" --with-database=mysql --with-libs=-L/usr/local/mysql/lib "
26export TEST_MYSQL
27
28echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER W/GPG __${E}"; echo;
29echo Working directory: $PW_DIR
30
31MAKE=`which gmake`
32if test "x$?" = x1 ; then
33 MAKE="make -s"
34else
35 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"`
36 if test "x$MAKE" = x; then
37 MAKE="make -s"
38 elif test "x$MAKE" = xno; then
39 MAKE="make -s"
40 else
41 if test "x$MAKE" = "xwhich:"; then
42 MAKE="make -s"
43 else
44 MAKE="gmake -s"
45 gmake -v >/dev/null 2>&1 || MAKE="make -s"
46 fi
47 fi
48fi
49
50echo MAKE is $MAKE
51echo
52
53# $GPG_PATH _must_ be an absolute path
54#
55if test x${GPG_PATH} = x; then
56 GPG_PATH=`which gpg | sed -e "s%\([a-z:]\) .*%\1%g"`
57fi
58
59if test x${GPG_PATH} = x; then
60 echo "ERROR: gpg (GnuPG) not found"
61 exit
62else
63 GPG_OK=`echo ${GPG_PATH} | sed -e "s%\(/.*\)%OK%g"`
64 if test x${GPG_OK} = xOK; then
65 echo "GPG_PATH is ${GPG_PATH}"
66 else
67 echo "ERROR: GPG_PATH (${GPG_PATH}) is _not_ an absolute path."
68 echo
69 echo " Apparently the command 'which gpg' did not yield an absolute path."
70 echo " You can fix the problem by setting the environment variable GPG_PATH"
71 echo " to the absolute path to gpg (GnuPG) and start the test again."
72 exit
73 fi
74fi
75
76echo
77
78testrun2b ()
79{
80 #
81 # test standalone compilation
82 #
83 echo "${S}Building client and server${E}"; echo;
84 #
85 if test -r "Makefile"; then
86 $MAKE distclean
87 fi
88 #
89 GPG_HASH=`${GPG_PATH} --load-extension tiger --print-md TIGER192 ${GPG_PATH}`
90 #
91 echo GPG_HASH is ${GPG_HASH}
92 #
93 ${TOP_SRCDIR}/configure --quiet $TRUST --with-gpg=${GPG_PATH} --enable-xml-log --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2.signed --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock
94 #
95 if test x$? = x0; then
96 echo "configure completed, exit status 0"; echo;
97 $MAKE > /dev/null
98 if test x$? = x0; then
99 echo "$MAKE completed, exit status $?"; echo;
100 else
101 echo "${S}ERROR:${E} make failed, exit status $?"; echo;
102 exit
103 fi
104
105 else
106 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;
107 exit
108 fi
109
110 # save binary and build server
111 #
112 cp samhain samhain.build
113 make clean
114
115 #
116 ${TOP_SRCDIR}/configure --quiet $TRUST --with-gpg=${GPG_PATH} --enable-xml-log ${TEST_MYSQL} --enable-debug --enable-network=server --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2.signed --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 --enable-identity=rainer
117 #
118 if test x$? = x0; then
119 echo "configure completed, exit status 0"; echo;
120 $MAKE > /dev/null
121 if test x$? = x0; then
122 echo "$MAKE completed, exit status $?"; echo;
123 else
124 echo "${S}ERROR:${E} make failed, exit status $?"; echo;
125 exit
126 fi
127
128 else
129 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;
130 exit
131 fi
132 echo "${S}Initialize database${E}"; echo;
133
134 rm -f ./.samhain_file
135 rm -f ./.samhain_log
136 rm -f ./.samhain_lock
137 rm -f ./rc.${SH_LOCALHOST}
138 rm -f ./file.${SH_LOCALHOST}
139
140 cp ${SCRIPTDIR}/testrc_2.in testrc_2.signed
141
142 # Create a password
143 SHPW=`./yule -G`
144 if test x"$SHPW" = x; then
145 echo "password not generated -- aborting"
146 exit 1
147 fi
148
149 # Set in client
150 echo "./samhain_setpwd samhain.build new $SHPW"
151 ./samhain_setpwd samhain.build new $SHPW
152 mv samhain.build.new samhain.new
153 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
154 echo $SHCLT >> testrc_2.signed
155
156 echo "--- You need to sign the config file testrc_2.signed now ---"
157 echo
158 ${GPG_PATH} -a --clearsign --not-dash-escaped $PW_DIR/testrc_2.signed
159 mv $PW_DIR/testrc_2.signed.asc $PW_DIR/testrc_2.signed
160
161 echo "./samhain.new -t init"
162 ./samhain.new -t init
163
164 SHINI=$?
165
166 rm -f ./.samhain_log
167 rm -f ./.samhain_lock
168
169 cp ./testrc_2.signed ./rc.${SH_LOCALHOST}
170 mv ./.samhain_file ./file.${SH_LOCALHOST}
171
172 if test x$SHINI = x0; then
173 echo
174 echo "--- You need to sign the database file.${SH_LOCALHOST} now ---"
175 echo
176 ${GPG_PATH} -a --clearsign --not-dash-escaped $PW_DIR/file.${SH_LOCALHOST}
177 mv $PW_DIR/file.${SH_LOCALHOST}.asc $PW_DIR/file.${SH_LOCALHOST}
178
179 echo; echo "${S}Start Server${E}: ./yule &"; echo;
180 ./yule &
181 PROC_Y=$!
182 sleep 5
183
184 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
185
186 ./samhain.new -t check -p none -l none -e info
187 if test x$? = x0; then
188 echo "${S}check completed${E}"
189 else
190 echo "${S}ERROR:${E} -- check -- failed, exit status $?"
191 echo
192 kill $PROC_Y
193 exit
194 fi
195
196 kill $PROC_Y
197 sleep 5
198 else
199 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI";
200 echo;
201 exit
202 fi
203
204}
205
206 if test x$1 = x; then
207 echo
208 echo "Please provide the local hostname as argument."
209 echo
210 exit 8
211 fi
212
213 SH_LOCALHOST=$1; export SH_LOCALHOST
214
215 testrun2b
216
217
218echo; echo "${S}__ END TEST RUN CLIENT/SERVER W/GPG __${E}"; echo;
219
220exit
221
Note: See TracBrowser for help on using the repository browser.