source: trunk/dsys/comINSTALL@ 46

Last change on this file since 46 was 40, checked in by rainer, 18 years ago

Fix for tickets #13, #14, #15, #16, #17

File size: 23.2 KB
Line 
1#########################################################################
2#
3# Subroutine for the 'install' command
4#
5#########################################################################
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#
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" = "xsolaris-pkg"
258 then
259 if test x"$simulate" = x0
260 then
261 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} all'") >/dev/null '\'
262 else
263 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} samhain-${src_version}.${realformat}) all'"
264 fi
265 elif test "x$format" = "xtbz2"
266 then
267 # Gentoo is a PITA
268 #
269 tmp_iname=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config name`
270 if test x"$simulate" = x0
271 then
272 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 '\'
273 else
274 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})'"
275 fi
276 else
277 if test x"$simulate" = x0
278 then
279 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 '\'
280 else
281 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} samhain-${src_version}.${realformat})'"
282 fi
283 fi
284
285 if test x"$?" != x0
286 then
287 printFATAL "Could not install package on host ${host}."
288 else
289 printLOG "Package installed on host ${host}"
290 fi
291
292
293 #---------------------------------------------------------------------
294 # Run postinstall script to fix the client password.
295 #---------------------------------------------------------------------
296 if test x"$simulate" = x0
297 then
298 if test "x${is_packed}" = "x0"
299 then
300 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x postinstall && ./postinstall "'${is_passwd}'") >/dev/null'
301 else
302 # Dummy argument
303 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x postinstall && ./postinstall DUMMY ) >/dev/null'
304 fi
305 else
306 if test "x${is_packed}" = "x0"
307 then
308 printINFO "ssh -x -l root ${host} (cd ${tmpdir} && chmod +x postinstall && ./postinstall ${is_passwd})"
309 else
310 # Dummy argument
311 printINFO "ssh -x -l root ${host} (cd ${tmpdir} && chmod +x postinstall && ./postinstall DUMMY )"
312 fi
313 fi
314
315 if test x"$?" != x0
316 then
317 printFATAL "Could not run postinstall script on host ${host}."
318 else
319 printLOG "Postinstall script executed on host ${host}"
320 fi
321
322 #---------------------------------------------------------------------
323 # Update the rc file
324 #---------------------------------------------------------------------
325
326 if test "x${is_rcfile}" = xy
327 then
328 mytest_file=`ls -1 "${yule_data}/rc*" 2>/dev/null | tail -n 1 2>/dev/null`
329 if test "x$mytest_file" = x; then
330 rcfile_perm=640;
331 rcfile_owner=`ls -ld ${yule_data} | awk '{print $3 }'`
332 rcfile_group=`ls -ld ${yule_data} | awk '{print $4 }'`
333 else
334 mytest_file=`basename $mytest_file`
335 rcfile_perm=`ls -l "${yule_data}/${mytest_file}" | \
336 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
337 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
338 print "u=" u ",g=" g ",o=" o; }'`
339 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
340 rcfile_owner=`ls -l "${yule_data}/${mytest_file}" | \
341 awk '{print $3 }'`
342 rcfile_group=`ls -l "${yule_data}/${mytest_file}" | \
343 awk '{print $4 }'`
344 fi
345
346 if test -f "${hostconfig}"
347 then
348 if test x"$simulate" = x0
349 then
350 ageFILE "${yule_data}/rc.${host}" || printFATAL "Could not backup ${yule_data}/rc.${host}."
351 cp "${hostconfig}" "${yule_data}/rc.${host}" || printFATAL "Could not copy ${hostconfig} to ${yule_data}/rc.${host}"
352 chown ${rcfile_owner}:${rcfile_group} "${yule_data}/rc.${host}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_data}/rc.${host}"
353 chmod ${rcfile_perm} "${yule_data}/rc.${host}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_data}/rc.${host}"
354 else
355 printINFO "Backup existing ${yule_data}/rc.${host}"
356 printINFO "Copy ${hostconfig} to ${yule_data}/rc.${host}"
357 fi
358 else
359 printFATAL "${hostconfig} is missing."
360 fi
361 printLOG "Server-side config file ${yule_data}/rc.${host} copied from ${hostconfig}."
362 fi
363
364 #---------------------------------------------------------------------
365 # Server entry and restart
366 #---------------------------------------------------------------------
367
368 instlock="${yule_conf}.lockdir";
369 trap "rm -rf ${instlock}" 1 2 13 15
370
371 if test x"$simulate" = x0
372 then
373 #
374 # A lockfile will not work, because 'root' can write anyway.
375 # However, 'mkdir' an existing directory will fail even for root
376 #
377 until (umask 222; mkdir "${instlock}") 2>/dev/null # test & set
378 do
379 printINFO "Waiting for lock"
380 sleep 1
381 done
382 fi
383
384 Replace=`"${yule_exec}" -P "${is_passwd}" | sed s%HOSTNAME%${host}%g`
385 if test "x$Replace" = x
386 then
387 rm -rf "${instlock}"
388 printFATAL "Could not execute ${yule_exec} -P ${is_passwd}."
389 fi
390 SearchString="Client=${host}@"
391 Seen=n
392 echo >"$tmpF" || printFATAL "Cannot write new server configuration."
393 while read line
394 do
395 if test "x$Seen" = xn
396 then
397 echo "$line" >>"$tmpF"
398 if test -n "`echo $line | awk '/^\[Clients\]/'`"
399 then
400 Seen=y
401 echo "$Replace" >>"$tmpF"
402 if [ $? -ne 0 ]; then
403 rm -rf "${instlock}"
404 printFATAL "Cannot write new server configuration."
405 fi
406 fi
407 else
408 if test -n "`echo $line | awk '/^'${SearchString}'/'`"
409 then
410 :
411 else
412 echo "$line" >>"$tmpF"
413 if [ $? -ne 0 ]; then
414 rm -rf "${instlock}"
415 printFATAL "Cannot write new server configuration."
416 fi
417 fi
418 fi
419 done <"${yule_conf}"
420
421 rcfile_perm=`ls -l "${yule_conf}" | \
422 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
423 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
424 print "u=" u ",g=" g ",o=" o; }'`
425 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
426 rcfile_owner=`ls -l "${yule_conf}" | \
427 awk '{print $3 }'`
428 rcfile_group=`ls -l "${yule_conf}" | \
429 awk '{print $4 }'`
430
431 if test x"$simulate" = x0
432 then
433 ageFILE "${yule_conf}"
434 if [ $? -ne 0 ]; then
435 rm -rf "${instlock}"
436 printFATAL "Could not backup ${yule_conf}"
437 fi
438
439 rm -f "${yule_conf}" && cp "$tmpF" "${yule_conf}"
440 if [ $? -ne 0 ]; then
441 rm -rf "${instlock}"
442 printFATAL "Could not write new server config. Backup is ${yule_conf}.1"
443 fi
444
445 chown ${rcfile_owner}:${rcfile_group} "${yule_conf}"
446 if [ $? -ne 0 ]; then
447 rm -rf "${instlock}"
448 printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
449 fi
450
451 chmod ${rcfile_perm} "${yule_conf}"
452 if [ $? -ne 0 ]; then
453 rm -rf "${instlock}"
454 printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
455 fi
456 else
457 printINFO "Backup and update ${yule_conf}"
458 fi
459
460 if test "x${local_command}" = x
461 then
462 :
463 else
464 if test x"$simulate" = x0
465 then
466 eval "${local_command}" "${host}" "${arch}" "${basedir}" "${yule_data}" "first"
467 else
468 printINFO "eval ${local_command} ${host} ${arch} ${basedir} ${yule_data} first"
469 fi
470 fi
471
472 yule_name=`basename "${yule_exec}"`
473
474 if test x"$simulate" = x0
475 then
476 if test -f "/etc/init.d/${yule_name}"
477 then
478 eval "/etc/init.d/${yule_name}" reload
479 if test x"$?" != x0
480 then
481 printWARNING "Could not reload server using: /etc/init.d/${yule_name} reload."
482 fi
483 else
484 eval "${yule_exec}" reload
485 if test x"$?" != x0
486 then
487 printWARNING "Could not reload server using: ${yule_exec} reload."
488 fi
489 fi
490 #
491 # wait for the server to pick up the new configuration
492 #
493 sleep 5
494 #
495 rm -rf "${instlock}"
496 else
497 printINFO "Reloading server configuration."
498 fi
499
500 printLOG "Server configuration updated and reloaded."
501
502
503 #---------------------------------------------------------------------
504 # Write/update client database
505 #---------------------------------------------------------------------
506
507 SH_NAME=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config name`; export SH_NAME
508 SH_PREFIX=`/bin/sh ${basedir}/archpkg/${arch}/install-${src_version}.${realformat} --print-config prefix`; export SH_PREFIX
509
510 if test x"$simulate" = x0
511 then
512 updateDB
513 else
514 printINFO "Updating client database."
515 fi
516
517 #---------------------------------------------------------------------
518 # Initialize and fetch database
519 #---------------------------------------------------------------------
520
521 if test "x${is_init}" = xy
522 then
523 if test x"$simulate" = x0
524 then
525 if test x"$silent" != x0
526 then
527 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && chmod +x initscript && ./initscript ${is_nocl} >/dev/null 2>&1 )'\'
528 else
529 ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && chmod +x initscript && ./initscript ${is_nocl} >/dev/null 2>&1 )'\'
530 fi
531 if test x"$?" != x0
532 then
533 printFATAL "Could not initialize database on host ${host}."
534 else
535 printLOG "Database initialized on host ${host}"
536 fi
537 scp -q "root@${host}:${tmpdir}/data" "$tmpD" || \
538 printFATAL "Could not retrieve database file root@${host}:${tmpdir}/data"
539 else
540 printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && chmod +x initscript && ./initscript ${is_nocl})'"
541 printLOG "Database initialized on host ${host}"
542 printINFO "scp -q root@${host}:${tmpdir}/data $tmpD"
543 fi
544
545 mytest_file=`ls -1 "${yule_data}/file*" 2>/dev/null | tail -n 1 2>/dev/null`
546 if test "x$mytest_file" = x; then
547 rcfile_perm=640;
548 rcfile_owner=`ls -ld ${yule_data} | awk '{print $3 }'`
549 rcfile_group=`ls -ld ${yule_data} | awk '{print $4 }'`
550 else
551 mytest_file=`basename $mytest_file`
552 rcfile_perm=`ls -l "${yule_data}/${mytest_file}" | \
553 awk '{ u= substr($1,2,3); g=substr($1,5,3); o=substr($1,8,3); \
554 gsub("-","",u); gsub("-","",g); gsub("-","",o); \
555 print "u=" u ",g=" g ",o=" o; }'`
556 rcfile_perm=`echo ${rcfile_perm} | sed s%g=,%g-rwx,% | sed s%,o=$%,o-rwx%`
557 rcfile_owner=`ls -l "${yule_data}/${mytest_file}" | \
558 awk '{print $3 }'`
559 rcfile_group=`ls -l "${yule_data}/${mytest_file}" | \
560 awk '{print $4 }'`
561 fi
562
563 if test x"$simulate" = x0
564 then
565 if test -f "$tmpD/data"
566 then
567 ageFILE "${yule_data}/file.${host}" || printFATAL "Could not backup ${yule_conf}."
568 mv "$tmpD/data" "${yule_data}/file.${host}" || printFATAL "Could not move database file to ${yule_data}/file.${host}"
569 chown ${rcfile_owner}:${rcfile_group} "${yule_data}/file.${host}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_data}/file.${host}"
570 chmod ${rcfile_perm} "${yule_data}/file.${host}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_data}/file.${host}"
571 else
572 printFATAL "Database file not downloaded from host ${host}"
573 fi
574 else
575 printINFO "Backup and replace ${yule_data}/file.${host}"
576 fi
577 fi
578
579 #---------------------------------------------------------------------
580 # Start up.
581 #---------------------------------------------------------------------
582
583 if test "x${local_command}" = x
584 then
585 :
586 else
587 if test x"$simulate" = x0
588 then
589 eval "${local_command}" "${host}" "${arch}" "${basedir}" "${yule_data}" "second"
590 else
591 printINFO "eval ${local_command} ${host} ${arch} ${basedir} ${yule_data} second"
592 fi
593 fi
594
595 if test "x${is_startup}" = xy
596 then
597 if test x"$simulate" = x0
598 then
599 ssh -x -l "root" "${host}" '(cd "'${tmpdir}'" && chmod +x initscript && eval "'./initscript ${is_nocl} start'")'
600 else
601 printINFO "Starting remote client now."
602 fi
603 if test x"$?" != x0
604 then
605 printFATAL "Could not start client on host ${host}."
606 else
607 printLOG "Client started on host ${host}."
608 fi
609 fi
610
611 #---------------------------------------------------------------------
612 # Clean up.
613 #---------------------------------------------------------------------
614
615 if test x"$simulate" = x0
616 then
617 ssh -x -l "root" "${host}" '(rm -rf "'${tmpdir}'")'
618 else
619 printINFO "ssh -x -l root ${host} (rm -rf ${tmpdir})"
620 fi
621 if test x"$?" != x0
622 then
623 printFATAL "Could not remove temporary directory ${tmpdir} on host ${host}."
624 else
625 printLOG "Directory ${tmpdir} deleted on host ${host}."
626 fi
627
628}
629
Note: See TracBrowser for help on using the repository browser.