source: trunk/test/testrun_2.sh@ 16

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

Initial import

File size: 4.1 KB
Line 
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
24echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER __${E}"; echo;
25echo Working directory: $PW_DIR
26
27MAKE=`which gmake`
28if test "x$?" = x1 ; then
29 MAKE="make -s"
30else
31 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"`
32 if test "x$MAKE" = x; then
33 MAKE="make -s"
34 elif test "x$MAKE" = xno; then
35 MAKE="make -s"
36 else
37 if test "x$MAKE" = "xwhich:"; then
38 MAKE="make -s"
39 else
40 MAKE="gmake -s"
41 gmake -v >/dev/null 2>&1 || MAKE="make -s"
42 fi
43 fi
44fi
45
46echo MAKE is $MAKE
47echo
48
49# --with-database=postgresql
50# export MYLIB=-L/usr/local/pgsql/lib
51# export MYINC=-I/usr/local/pgsql/include
52# export LD_LIBRARY_PATH=/usr/local/pgsql/lib
53
54# --with-database=mysql
55# export MYLIB=-L/usr/local/mysql/lib
56# export MYINC=-I/usr/local/mysql/include
57# export LD_LIBRARY_PATH=/usr/local/mysql/lib
58
59testrun2 ()
60{
61 #
62 # test standalone compilation
63 #
64 echo "${S}Building client and server${E}"; echo;
65 #
66 if test -r "Makefile"; then
67 $MAKE distclean
68 fi
69 #
70 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-network=client --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-encrypt=2
71 #
72 if test x$? = x0; then
73 echo "configure completed, exit status 0"; echo;
74 $MAKE > /dev/null
75 if test x$? = x0; then
76 echo "$MAKE completed, exit status $?"; echo;
77 else
78 echo "${S}ERROR:${E} make failed, exit status $?"; echo;
79 exit
80 fi
81
82 else
83 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;
84 exit
85 fi
86
87 # save binary and build server
88 #
89 cp samhain samhain.build
90 make clean
91
92 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-identity=rainer --enable-encrypt=2
93 #
94 if test x$? = x0; then
95 echo "configure completed, exit status 0"; echo;
96 $MAKE > /dev/null
97 if test x$? = x0; then
98 echo "$MAKE completed, exit status $?"; echo;
99 else
100 echo "${S}ERROR:${E} make failed, exit status $?"; echo;
101 exit
102 fi
103
104 else
105 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;
106 exit
107 fi
108
109 #####################################################################
110 #
111 #
112 echo "${S}Initialize database${E}"; echo;
113
114 rm -f ./.samhain_file
115 rm -f ./.samhain_log
116 rm -f ./.samhain_lock
117
118 cp ${SCRIPTDIR}/testrc_2.in testrc_2
119
120 echo "./samhain.build -t init"
121 ./samhain.build -t init
122
123 SHINI=$?
124
125 # Create a password
126
127 SHPW=`./yule -G`
128 if test x"$SHPW" = x; then
129 echo "password not generated -- aborting"
130 exit 1
131 fi
132
133 # Set in client
134
135 echo "./samhain_setpwd samhain.build new $SHPW"
136 ./samhain_setpwd samhain.build new $SHPW
137
138 mv samhain.build.new samhain.new
139
140 rm -f ./.samhain_log.*
141 rm -f ./.samhain_lock
142
143 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
144
145 echo $SHCLT >> testrc_2
146
147 if test x$SHINI = x0; then
148 echo; echo "${S}Start Server${E}: ./yule &"; echo;
149 ./yule -l info &
150 PROC_Y=$!
151 sleep 5
152
153 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
154
155 ./samhain.new -t check -p none -l none -e info
156 if test x$? = x0; then
157 echo "${S}check completed${E}"
158 else
159 echo "${S}ERROR:${E} -- check -- failed, exit status $?"
160 echo
161 kill $PROC_Y
162 exit
163 fi
164
165 kill $PROC_Y
166 sleep 5
167 else
168 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI";
169 echo;
170 exit
171 fi
172
173}
174
175 if test x$1 = x; then
176 echo
177 echo "Please provide the local hostname as argument."
178 echo
179 exit 8
180 fi
181
182 SH_LOCALHOST=$1; export SH_LOCALHOST
183
184 testrun2
185
186
187echo; echo "${S}__ END TEST RUN CLIENT/SERVER __${E}"; echo;
188
189exit
190
Note: See TracBrowser for help on using the repository browser.