source: trunk/dsys/comINSTALL@ 28

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

Support for server-to-server relay and more user policies

File size: 22.7 KB
RevLine 
[1]1#########################################################################
2#
3# Subroutine for the 'install' command
4#
5#########################################################################
[27]6#
7# Copyright Rainer Wichmann (2005)
8#
9# License Information:
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
[1]24
25commandINSTALL() {
26
27 printINFO "About to run \"$action\" on host \"$host\""
28 #
29 # configuration options we should know about
30 #
31 is_packed=0
32 is_nocl="start"
33 is_xor="no"
34
35
36 if test -f "${basedir}/configs/${arch}.configure"
37 then
38 :
39 else
40 printFATAL "Configure options ${basedir}/configs/${arch}.configure missing."
41 fi
42
43 if test -f "${basedir}/configs/${arch}.samhainrc"
44 then
45 :
46 else
47 printFATAL "Configuration file ${basedir}/configs/${arch}.samhainrc missing."
48 fi
49
50 realformat=`echo $format | sed s,solaris-,,`; export realformat
51
52 if test -f "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}"
53 then
54 :
55 else
56 printFATAL "Binary package OS: ${arch}, version: ${src_version}, format ${format} does not exist."
57 fi
58
59 if test -f "${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
60 then
61 :
62 else
63 printFATAL "Binary package OS: ${arch}, version: ${src_version}, format ${format} is incomplete and cannot be installed."
64 fi
65
66
67 if test -f "${basedir}/archpkg/${arch}/PASSWD-${src_version}.${realformat}"
68 then
69 printINFO "Binary package OS: ${arch}, version: ${src_version}, format ${format} is packed."
70 is_packed=1
71 is_passwd=`cat "${basedir}/archpkg/${arch}/PASSWD-${src_version}.${realformat}" | tr -d '\n'`
72 else
73 is_passwd=`eval "${yule_exec}" -G`
74 if test x$? != x0
75 then
76 printFATAL "Could not generate password. Is yule in your PATH ?"
77 fi
78 fi
79
80 if test -f "${basedir}/configs/${arch}.preinstall"
81 then
82 cp "${basedir}/configs/${arch}.preinstall" "${tmpD}/preinstall" || \
83 printFATAL "Could not copy ${basedir}/configs/${arch}.preinstall to ${tmpD}/preinstall"
84 is_preinstall_full="${tmpD}/preinstall"
85 else
86 is_preinstall_full="${basedir}/libexec/preinstall"
87 fi
88
89 if test -f "${basedir}/configs/${arch}.postinstall"
90 then
91 cp "${basedir}/configs/${arch}.postinstall" "${tmpD}/postinstall" || \
92 printFATAL "Could not copy ${basedir}/configs/${arch}.postinstall to ${tmpD}/postinstall"
93 is_postinstall_full="${tmpD}/postinstall"
94 else
95 is_postinstall_full="${basedir}/libexec/postinstall"
96 fi
97
98 if test -f "${basedir}/configs/${arch}.initscript"
99 then
100 cp "${basedir}/configs/${arch}.initscript" "${tmpD}/initscript" || \
101 printFATAL "Could not copy ${basedir}/configs/${arch}.initscript to ${tmpD}/initscript"
102 is_initscript_full="${tmpD}/initscript"
103 else
104 is_initscript_full="${basedir}/libexec/initscript"
105 fi
106
107 #---------------------------------------------------------------------
108 # Get important configuration options.
109 #---------------------------------------------------------------------
110
111 getconfopts "${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}" || printFATAL "Could not check config file ${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}"
112
113
114 #---------------------------------------------------------------------
115 # Prepare the configuration file
116 #---------------------------------------------------------------------
117
118 if test -f "${basedir}/hosts/${host}/${arch}.samhainrc"
119 then
120 hostconfig="${basedir}/hosts/${host}/${arch}.samhainrc"
121 elif test -f "${basedir}/hosts/${host}/samhainrc"
122 then
123 hostconfig="${basedir}/hosts/${host}/samhainrc"
124 else
125 hostconfig="${basedir}/configs/${arch}.samhainrc"
126 fi
127
128 test -f "${hostconfig}" || printFATAL "Configuration file ${hostconfig} missing."
129
130 # Handle the '--enable-stealth' option
131 #
132 if test x"${is_xor}" = xno
133 then
134 :
135 else
136 test -f "${basedir}/private/stealth_template.ps" || \
137 printFATAL "${basedir}/private/stealth_template.ps not available."
138 ${basedir}/libexec/samhain_stealth -o "${hostconfig}" >/dev/null ||\
139 printFATAL "Problem reading ${hostconfig}".
140 ccount=`${basedir}/libexec/samhain_stealth -o "${hostconfig}" 2>&1 | awk '{ print $1 }'`
141 ${basedir}/libexec/samhain_stealth -i "${basedir}/private/stealth_template.ps" >/dev/null || \
142 printFATAL "Problem reading ${basedir}/private/stealth_template.ps"
143 mcount=`${basedir}/libexec/samhain_stealth -i "${basedir}/private/stealth_template.ps" 2>&1 | awk '{ print $7 }'`
144
145 if test ${mcount} -lt ${ccount}
146 then
147 printFATAL "Configuration file ${hostconfig} too big."
148 fi
149
150 cp "${basedir}/private/stealth_template.ps" "$tmpD" || \
151 printFATAL "Could not copy ${basedir}/private/stealth_template.ps to ${tmpD}/"
152 ${basedir}/libexec/samhain_stealth -s "${tmpD}/stealth_template.ps" "${hostconfig}" >/dev/null
153 if test "x$?" = x0
154 then
155 printINFO "Configuration file hidden into stealth_template.ps"
156 hostconfig="${tmpD}/stealth_template.ps"
157 else
158 printFATAL "Could not run ${basedir}/libexec/samhain_stealth -s ${tmpD}/stealth_template.ps ${hostconfig}"
159 fi
160 fi
161
162 rm -f "${tmpD}/prepared_samhainrc"
163 cp "${hostconfig}" "${tmpD}/prepared_samhainrc" || \
164 printFATAL "Could not copy ${hostconfig} to ${tmpD}/prepared_samhainrc"
165 hostconfig="${tmpD}/prepared_samhainrc"
166
167 #---------------------------------------------------------------------
168 # Create temporary directory on host.
169 #---------------------------------------------------------------------
170
171 tmpdir=`eval echo "/tmp/sh_${src_version}_${arch}_${format}_$$"`
172
173 if test x"$simulate" = x0
174 then
175 ssh -x -l "root" "${host}" '(umask 0077; mkdir "'${tmpdir}'")'
176 else
177 printINFO "ssh -x -l root ${host} (umask 0077; mkdir ${tmpdir})"
178 fi
179 if test x"$?" != x0
180 then
181 printFATAL "Could not create temporary directory ${tmpdir} on host ${host}."
182 else
183 printLOG "Directory ${tmpdir} created on host ${host}."
184 fi
185
186 #---------------------------------------------------------------------
187 # Copy to host.
188 #---------------------------------------------------------------------
189 if test x"$simulate" = x0
190 then
191 if test x"$silent" = x0
192 then
193 scp "${is_initscript_full}" "${is_preinstall_full}" "${is_postinstall_full}" "${hostconfig}" "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}" "${basedir}/archpkg/${arch}/install-${src_version}.${realformat}" "root@${host}:${tmpdir}/"
194 else
195 scp -q "${is_initscript_full}" "${is_preinstall_full}" "${is_postinstall_full}" "${hostconfig}" "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}" "${basedir}/archpkg/${arch}/install-${src_version}.${realformat}" "root@${host}:${tmpdir}/"
196 fi
197 else
198 if test x"$silent" = x0
199 then
200 printINFO "scp ${is_initscript_full} ${is_preinstall_full} ${is_postinstall_full} ${hostconfig} ${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat} ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} root@${host}:${tmpdir}/"
201 else
202 printINFO "scp -q ${is_initscript_full} ${is_preinstall_full} ${is_postinstall_full} ${hostconfig} ${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat} ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} root@${host}:${tmpdir}/"
203 fi
204 fi
205 if test x"$?" != x0
206 then
207 printFATAL "Could not copy package to host ${host}."
208 else
209 printINFO "Package copied to host ${host}."
210 fi
211
212 #---------------------------------------------------------------------
213 # Run preinstall script.
214 #---------------------------------------------------------------------
215 if test x"$simulate" = x0
216 then
217 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && cp "'install-${src_version}.${realformat}'" samhain-install.sh && chmod +x samhain-install.sh && chmod +x preinstall && ./preinstall)'
218 else
219 printINFO "ssh -x -l root ${host} (cd ${tmpdir} && cp install-${src_version}.${realformat} samhain-install.sh && chmod +x samhain-install.sh && chmod +x preinstall && ./preinstall)"
220 fi
221 if test x"$?" != x0
222 then
223 printFATAL "Could not run preinstall script on host ${host}."
224 else
225 printLOG "Preinstall script executed on host ${host}"
226 fi
227
228 #---------------------------------------------------------------------
229 # Install.
230 #---------------------------------------------------------------------
231
232 if test "x$format" = "xrun"; then
233 is_command="/bin/sh"
234 elif test "x$format" = "xdeb"; then
235 is_command="dpkg --install --force-downgrade --force-confnew"
236 elif test "x$format" = "xrpm"; then
237 is_command="rpm --upgrade --quiet --oldpackage"
238 elif test "x$format" = "xtbz2"; then
239 is_command="emerge -K"
240 elif test "x$format" = "xsolaris-pkg"; then
241 is_command="pkgadd -n -d"
242 elif test "x$format" = "xdepot"; then
243 is_command="/usr/sbin/swinstall -x fix_explicit_directories=false -v -s "
244 else
245 printFATAL "Don't know how to install package format ${format}"
246 fi
247
248 if test "x$format" = "xdepot"
249 then
250 tmp_iname=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config name`
251 if test x"$simulate" = x0
252 then
253 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && PATH="'/usr/local/sbin:/usr/sbin:/sbin:$PATH'" && export PATH && eval "'${is_command}'" "'${tmpdir}/samhain-${src_version}.${realformat}'" "'${tmp_iname}'") >/dev/null '\'
254 else
255 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} ${tmpdir}/samhain-${src_version}.${realformat} ${tmp_iname})'"
256 fi
257 elif test "x$format" = "xtbz2"
258 then
259 # Gentoo is a PITA
260 #
261 tmp_iname=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config name`
262 if test x"$simulate" = x0
263 then
264 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && PATH="'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH'" && export PATH && cp "'samhain-${src_version}.${realformat}'" "'/usr/portage/packages/All/${tmp_iname}-${src_version}.tbz2'" && eval "'${is_command}'" "'${tmp_iname}-${src_version}.${realformat}'") >/dev/null '\'
265 else
266 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && cp samhain-${src_version}.${realformat} /usr/portage/packages/${tmp_iname}-${src_version}.tbz2 && eval ${is_command} ${tmp_iname}-${src_version}.${realformat})'"
267 fi
268 else
269 if test x"$simulate" = x0
270 then
271 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && PATH="'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH'" && export PATH && eval "'${is_command}'" "'samhain-${src_version}.${realformat}'") >/dev/null '\'
272 else
273 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} samhain-${src_version}.${realformat})'"
274 fi
275 fi
276
277 if test x"$?" != x0
278 then
279 printFATAL "Could not install package on host ${host}."
280 else
281 printLOG "Package installed on host ${host}"
282 fi
283
284
285 #---------------------------------------------------------------------
286 # Run postinstall script to fix the client password.
287 #---------------------------------------------------------------------
288 if test x"$simulate" = x0
289 then
290 if test "x${is_packed}" = "x0"
291 then
292 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x postinstall && ./postinstall "'${is_passwd}'") >/dev/null'
293 else
294 # Dummy argument
295 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x postinstall && ./postinstall DUMMY ) >/dev/null'
296 fi
297 else
298 if test "x${is_packed}" = "x0"
299 then
300 printINFO "ssh -x -l root ${host} (cd ${tmpdir} && chmod +x postinstall && ./postinstall ${is_passwd})"
301 else
302 # Dummy argument
303 printINFO "ssh -x -l root ${host} (cd ${tmpdir} && chmod +x postinstall && ./postinstall DUMMY )"
304 fi
305 fi
306
307 if test x"$?" != x0
308 then
309 printFATAL "Could not run postinstall script on host ${host}."
310 else
311 printLOG "Postinstall script executed on host ${host}"
312 fi
313
314 #---------------------------------------------------------------------
315 # Update the rc file
316 #---------------------------------------------------------------------
317
318 if test "x${is_rcfile}" = xy
319 then
320 mytest_file=`ls -1 "${yule_data}/rc*" 2>/dev/null | tail -n 1 2>/dev/null`
321 if test "x$mytest_file" = x; then
322 rcfile_perm=640;
323 rcfile_owner=`ls -ld ${yule_data} | awk '{print $3 }'`
324 rcfile_group=`ls -ld ${yule_data} | awk '{print $4 }'`
325 else
326 mytest_file=`basename $mytest_file`
327 rcfile_perm=`ls -l "${yule_data}/${mytest_file}" | \
328 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
329 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
330 print "u=" u ",g=" g ",o=" o; }'`
331 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
332 rcfile_owner=`ls -l "${yule_data}/${mytest_file}" | \
333 awk '{print $3 }'`
334 rcfile_group=`ls -l "${yule_data}/${mytest_file}" | \
335 awk '{print $4 }'`
336 fi
337
338 if test -f "${hostconfig}"
339 then
340 if test x"$simulate" = x0
341 then
342 ageFILE "${yule_data}/rc.${host}" || printFATAL "Could not backup ${yule_data}/rc.${host}."
343 cp "${hostconfig}" "${yule_data}/rc.${host}" || printFATAL "Could not copy ${hostconfig} to ${yule_data}/rc.${host}"
344 chown ${rcfile_owner}:${rcfile_group} "${yule_data}/rc.${host}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_data}/rc.${host}"
345 chmod ${rcfile_perm} "${yule_data}/rc.${host}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_data}/rc.${host}"
346 else
347 printINFO "Backup existing ${yule_data}/rc.${host}"
348 printINFO "Copy ${hostconfig} to ${yule_data}/rc.${host}"
349 fi
350 else
351 printFATAL "${hostconfig} is missing."
352 fi
353 printLOG "Server-side config file ${yule_data}/rc.${host} copied from ${hostconfig}."
354 fi
355
356 #---------------------------------------------------------------------
357 # Server entry and restart
358 #---------------------------------------------------------------------
359
[3]360 instlock="${yule_conf}.lockdir";
361 trap "rm -rf ${instlock}" 1 2 13 15
362
363 if test x"$simulate" = x0
364 then
365 #
366 # A lockfile will not work, because 'root' can write anyway.
367 # However, 'mkdir' an existing directory will fail even for root
368 #
369 until (umask 222; mkdir "${instlock}") 2>/dev/null # test & set
370 do
371 printINFO "Waiting for lock"
372 sleep 1
373 done
374 fi
375
[1]376 Replace=`"${yule_exec}" -P "${is_passwd}" | sed s%HOSTNAME%${host}%g`
377 if test "x$Replace" = x
378 then
[3]379 rm -rf "${instlock}"
[1]380 printFATAL "Could not execute ${yule_exec} -P ${is_passwd}."
381 fi
382 SearchString="Client=${host}@"
383 Seen=n
384 echo >"$tmpF" || printFATAL "Cannot write new server configuration."
385 while read line
386 do
387 if test "x$Seen" = xn
388 then
389 echo "$line" >>"$tmpF"
390 if test -n "`echo $line | awk '/^\[Clients\]/'`"
391 then
392 Seen=y
[3]393 echo "$Replace" >>"$tmpF"
394 if [ $? -ne 0 ]; then
395 rm -rf "${instlock}"
396 printFATAL "Cannot write new server configuration."
397 fi
[1]398 fi
399 else
400 if test -n "`echo $line | awk '/^'${SearchString}'/'`"
401 then
402 :
403 else
[3]404 echo "$line" >>"$tmpF"
405 if [ $? -ne 0 ]; then
406 rm -rf "${instlock}"
407 printFATAL "Cannot write new server configuration."
408 fi
[1]409 fi
410 fi
411 done <"${yule_conf}"
412
413 rcfile_perm=`ls -l "${yule_conf}" | \
414 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
415 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
416 print "u=" u ",g=" g ",o=" o; }'`
417 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
418 rcfile_owner=`ls -l "${yule_conf}" | \
419 awk '{print $3 }'`
420 rcfile_group=`ls -l "${yule_conf}" | \
421 awk '{print $4 }'`
422
423 if test x"$simulate" = x0
424 then
[3]425 ageFILE "${yule_conf}"
426 if [ $? -ne 0 ]; then
427 rm -rf "${instlock}"
428 printFATAL "Could not backup ${yule_conf}"
429 fi
430
431 rm -f "${yule_conf}" && cp "$tmpF" "${yule_conf}"
432 if [ $? -ne 0 ]; then
433 rm -rf "${instlock}"
434 printFATAL "Could not write new server config. Backup is ${yule_conf}.1"
435 fi
436
437 chown ${rcfile_owner}:${rcfile_group} "${yule_conf}"
438 if [ $? -ne 0 ]; then
439 rm -rf "${instlock}"
440 printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
441 fi
442
443 chmod ${rcfile_perm} "${yule_conf}"
444 if [ $? -ne 0 ]; then
445 rm -rf "${instlock}"
446 printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
447 fi
[1]448 else
449 printINFO "Backup and update ${yule_conf}"
450 fi
451
452 if test "x${local_command}" = x
453 then
454 :
455 else
456 if test x"$simulate" = x0
457 then
458 eval "${local_command}" "${host}" "${arch}" "${basedir}" "${yule_data}" "first"
459 else
460 printINFO "eval ${local_command} ${host} ${arch} ${basedir} ${yule_data} first"
461 fi
462 fi
463
464 yule_name=`basename "${yule_exec}"`
465
466 if test x"$simulate" = x0
467 then
468 if test -f "/etc/init.d/${yule_name}"
469 then
470 eval "/etc/init.d/${yule_name}" reload
471 if test x"$?" != x0
472 then
473 printWARNING "Could not reload server using: /etc/init.d/${yule_name} reload."
474 fi
475 else
476 eval "${yule_exec}" reload
477 if test x"$?" != x0
478 then
479 printWARNING "Could not reload server using: ${yule_exec} reload."
480 fi
481 fi
482 #
483 # wait for the server to pick up the new configuration
484 #
485 sleep 5
486 #
[3]487 rm -rf "${instlock}"
[1]488 else
489 printINFO "Reloading server configuration."
490 fi
491
492 printLOG "Server configuration updated and reloaded."
493
[3]494
[1]495 #---------------------------------------------------------------------
496 # Write/update client database
497 #---------------------------------------------------------------------
498
499 SH_NAME=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config name`; export SH_NAME
500 SH_PREFIX=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config prefix`; export SH_PREFIX
501
502 if test x"$simulate" = x0
503 then
504 updateDB
505 else
506 printINFO "Updating client database."
507 fi
508
509 #---------------------------------------------------------------------
510 # Initialize and fetch database
511 #---------------------------------------------------------------------
512
513 if test "x${is_init}" = xy
514 then
515 if test x"$simulate" = x0
516 then
517 if test x"$silent" != x0
518 then
519 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && chmod +x initscript && ./initscript ${is_nocl} >/dev/null 2>&1 )'\'
520 else
521 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && chmod +x initscript && ./initscript ${is_nocl} >/dev/null 2>&1 )'\'
522 fi
523 if test x"$?" != x0
524 then
525 printFATAL "Could not initialize database on host ${host}."
526 else
527 printLOG "Database initialized on host ${host}"
528 fi
529 scp -q "root@${host}:${tmpdir}/data" "$tmpD" || \
530 printFATAL "Could not retrieve database file root@${host}:${tmpdir}/data"
531 else
532 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && chmod +x initscript && ./initscript ${is_nocl})'"
533 printLOG "Database initialized on host ${host}"
534 printINFO "scp -q root@${host}:${tmpdir}/data $tmpD"
535 fi
536
537 mytest_file=`ls -1 "${yule_data}/file*" 2>/dev/null | tail -n 1 2>/dev/null`
538 if test "x$mytest_file" = x; then
539 rcfile_perm=640;
540 rcfile_owner=`ls -ld ${yule_data} | awk '{print $3 }'`
541 rcfile_group=`ls -ld ${yule_data} | awk '{print $4 }'`
542 else
543 mytest_file=`basename $mytest_file`
544 rcfile_perm=`ls -l "${yule_data}/${mytest_file}" | \
545 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
546 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
547 print "u=" u ",g=" g ",o=" o; }'`
548 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
549 rcfile_owner=`ls -l "${yule_data}/${mytest_file}" | \
550 awk '{print $3 }'`
551 rcfile_group=`ls -l "${yule_data}/${mytest_file}" | \
552 awk '{print $4 }'`
553 fi
554
555 if test x"$simulate" = x0
556 then
557 if test -f "$tmpD/data"
558 then
559 ageFILE "${yule_data}/file.${host}" || printFATAL "Could not backup ${yule_conf}."
560 mv "$tmpD/data" "${yule_data}/file.${host}" || printFATAL "Could not move database file to ${yule_data}/file.${host}"
561 chown ${rcfile_owner}:${rcfile_group} "${yule_data}/file.${host}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_data}/file.${host}"
562 chmod ${rcfile_perm} "${yule_data}/file.${host}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_data}/file.${host}"
563 else
564 printFATAL "Database file not downloaded from host ${host}"
565 fi
566 else
567 printINFO "Backup and replace ${yule_data}/file.${host}"
568 fi
569 fi
570
571 #---------------------------------------------------------------------
572 # Start up.
573 #---------------------------------------------------------------------
574
575 if test "x${local_command}" = x
576 then
577 :
578 else
579 if test x"$simulate" = x0
580 then
581 eval "${local_command}" "${host}" "${arch}" "${basedir}" "${yule_data}" "second"
582 else
583 printINFO "eval ${local_command} ${host} ${arch} ${basedir} ${yule_data} second"
584 fi
585 fi
586
587 if test "x${is_startup}" = xy
588 then
589 if test x"$simulate" = x0
590 then
591 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x initscript && eval "'./initscript ${is_nocl} start'")'
592 else
593 printINFO "Starting remote client now."
594 fi
595 if test x"$?" != x0
596 then
597 printFATAL "Could not start client on host ${host}."
598 else
599 printLOG "Client started on host ${host}."
600 fi
601 fi
602
603 #---------------------------------------------------------------------
604 # Clean up.
605 #---------------------------------------------------------------------
606
607 if test x"$simulate" = x0
608 then
609 ssh -x -l "root" "${host}" '(rm -rf "'${tmpdir}'")'
610 else
611 printINFO "ssh -x -l root ${host} (rm -rf ${tmpdir})"
612 fi
613 if test x"$?" != x0
614 then
615 printFATAL "Could not remove temporary directory ${tmpdir} on host ${host}."
616 else
617 printLOG "Directory ${tmpdir} deleted on host ${host}."
618 fi
619
620}
621
Note: See TracBrowser for help on using the repository browser.