source: trunk/deploy.sh.in@ 14

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

Initial import

File size: 28.6 KB
Line 
1#! /bin/sh
2
3#VERSION2.0
4
5# -----------------------------------------------------------------------
6# Be Bourne compatible
7# -----------------------------------------------------------------------
8
9if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
10 emulate sh
11 NULLCMD=:
12elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
13 set -o posix
14fi
15
16# -----------------------------------------------------------------------
17# Make sure we support functions (from the autoconf manual)
18# -----------------------------------------------------------------------
19
20SHELL="${SHELL-/bin/sh}"
21if test x"$1" = "x--re-executed"
22then
23 shift
24elif "$SHELL" -c 'foo () { (exit 0); exit 0; }; foo' 2>/dev/null
25then
26 :
27else
28 for cmd in sh bash ash bsh ksh zsh sh5; do
29 X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb";
30 OLD_IFS=${IFS}
31 IFS=':'; export IFS
32 for dir in $X; do
33 shell="$dir/$cmd"
34 if (test -f "$shell" || test -f "$shell.exe")
35 then
36 if "$shell" -c 'foo () { (exit 0); exit 0; }; foo' 2>/dev/null
37 then
38 SHELL="$shell"; export SHELL
39 IFS=${OLD_IFS}; export IFS
40 exec "$shell" "$0" --re-executed ${1+"$@"}
41 fi
42 fi
43 done
44 IFS=${OLD_IFS}; export IFS
45 done
46 echo "-----------------------------------------------------------------"
47 echo "ERROR: Unable to locate a shell interpreter with function support" >&2
48 echo "-----------------------------------------------------------------"
49 { (exit 1); exit 1; }
50fi
51
52# -----------------------------------------------------------------------
53# Test for 'echo -n'
54# -----------------------------------------------------------------------
55
56case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
57 *c*,* ) ECHO_N=-n ECHO_C= ;;
58 *) ECHO_N= ECHO_C='\c' ;;
59esac
60
61as_cr_letters='abcdefghijklmnopqrstuvwxyz'
62as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
63as_cr_Letters=$as_cr_letters$as_cr_LETTERS
64as_cr_digits='0123456789'
65as_cr_alnum=$as_cr_Letters$as_cr_digits
66
67
68#########################################################################
69#
70# Configuration section
71#
72#########################################################################
73
74# -----------------------------------------------------------------------
75# The following part will be cut and saved to ~/.deploy.conf
76# -----------------------------------------------------------------------
77
78#__BEGIN_CUT__
79
80#########################################################################
81#
82# This file is sourced by a Bourne shell script.
83# Thus you need to take care of proper shell syntax.
84#
85#########################################################################
86
87# if you need, you can expand your PATH environment variable here
88# just uncomment and replace /opt/contrib/bin with whatever you need
89#
90# PATH="/opt/contrib/bin:${PATH}"; export PATH
91
92# the base directory of the deployment system
93# CLI option: --basedir=...
94#
95defbasedir="@mydataroot@/profiles"
96
97# the name of the database of installed clients
98# no CLI option
99#
100defdatabase="yulerc.install.db"
101
102# be quiet; 0 = false, 1 = true, 2 = very quiet
103# CLI option: --quiet | --quiet=2
104#
105silent=0;
106
107# assume yes as answer to all prompts and run non-interactively
108# 0 = false, 1 = true
109# CLI option: --yes
110#
111assumeyes=0;
112
113# which 'dialog' to use (e.g. "Xdialog")
114# "no" for plain text; empty ("") lets the program search for dialog
115# CLI option: --dialog=...
116#
117prefdialog=""
118
119# operating system; no default
120# CLI option: --arch=...
121#
122arch=""
123
124# Format for binary packages (run | deb | rpm | tbz2 | solaris-pkg | depot)
125# CLI option: --format=...
126#
127format=""
128
129# logfile; default is none
130# CLI option: --logfile=...
131#
132logfile=""
133
134# The path to the yule (samhain server) executable.
135# CLI option: --yule_exec=...
136#
137yule_exec="@sbindir@/yule"
138
139# The path to the yule (samhain server) configuration file.
140# CLI option: --yule_conf=...
141#
142yule_conf="@sysconfdir@/yulerc"
143
144# The path to the data directory of yule (samhain server).
145# This is the directory where client configuration/database files
146# are stored.
147# CLI option: --yule_data=...
148#
149yule_data="@mydataroot@"
150
151#__END_CUT__
152
153# -----------------------------------------------------------------------
154# Write configuration file to user home directory/Read configuration file
155# -----------------------------------------------------------------------
156
157if test -f ~/.deploy.conf
158then
159 . ~/.deploy.conf
160else
161 #
162 # From the autoconf configure script - search ourselves
163 #
164 case $0 in
165 *[\\/]* ) as_myself=$0 ;;
166 *) old_IFS=$IFS; IFS=:
167 for as_dir in $PATH
168 do
169 IFS=$old_IFS
170 test -z "$as_dir" && as_dir=.
171 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
172 done
173 ;;
174 esac
175 # We did not find ourselves, most probably we were run as `sh COMMAND'
176 # in which case we are not to be found in the path.
177 if test "x$as_myself" = x; then
178 as_myself=$0
179 fi
180 if test ! -f "$as_myself"; then
181 { echo "ERROR: cannot find myself; rerun with an absolute path" >&2
182 { (exit 1); exit 1; }; }
183 fi
184 cat "$as_myself" | sed -n -e '/^#__BEGIN_CUT__/,/^#__END_CUT__/ p ' >~/.deploy.conf && {
185 echo
186 echo "-----------------------------------------------------"
187 echo " Configuration file ~/.deploy.conf created"
188 echo " You may want to edit it to adapt it to your needs"
189 echo "-----------------------------------------------------"
190 echo
191 }
192fi
193
194export silent
195export assumeyes
196export arch
197export logfile
198export format
199export yule_exec
200export yule_conf
201export yule_data
202
203# dialog
204#
205DIALOG="${prefdialog}";
206export DIALOG
207
208# base directory
209#
210basedir="$defbasedir";
211export basedir
212
213# simulate only; 0 = false, 1 = true
214#
215simulate=0;
216export simulate
217
218# version
219#
220version=2.0;
221export version
222
223# host; no default
224#
225host=
226export host
227
228
229# action; no default
230#
231action=
232export action
233
234# the 'log.lastrun' logfile
235#
236logOpen=0
237export logOpen
238
239
240# source version; default = current
241#
242src_version=""
243export src_version
244
245# checksrc; do you want to delete if PGP signature check fails ?
246#
247cs_delete=0
248export cs_delete
249
250# build; do you want to pack the executable ?
251#
252bd_packed=''
253export bd_packed
254
255bd_user='root'
256export bd_user
257
258# addpath
259#
260bd_addpath=""
261export bd_addpath
262
263# Install; do you want to initialize the database ?
264#
265is_init=y
266export is_init
267
268# Install; do you want to replace the rc.host file ?
269#
270is_rcfile=y
271export is_rcfile
272
273# Install; do you want to start the client ?
274#
275is_startup=y
276export is_startup
277
278# Install; optional local command ?
279#
280local_command=""; export local_command
281
282# Info on packages ?
283#
284showpkg=n
285export showpkg
286
287#########################################################################
288#
289# Help Subroutines
290#
291#########################################################################
292
293# -----------------------------------------------------------------------
294# We cannot source these, because we don't know yet the base directory
295# -----------------------------------------------------------------------
296
297showUNINSTALL() {
298 echo "deploy.sh $version"
299 echo "USAGE: deploy.sh [options] uninstall"
300 echo
301 echo "Uninstall the samhain client from the specified host. Can only be"
302 echo "used if the client has been installed with deploy.sh version 2."
303 echo
304 echo "Options:"
305 echo
306 echo " --host=<hostname> The host where you want to uninstall."
307 echo
308 { (exit 0); exit 0; }
309}
310
311showINFO() {
312 echo "deploy.sh $version"
313 echo "USAGE: deploy.sh [options] info"
314 echo
315 echo "Show info for hosts in client database (default), or for available"
316 echo "binary installer packages."
317 echo
318 echo "Options:"
319 echo
320 echo " --packages Show info on packages."
321 echo
322 { (exit 0); exit 0; }
323}
324
325showCLEAN() {
326 echo "deploy.sh $version"
327 echo "USAGE: deploy.sh [options] clean"
328 echo
329 echo "Remove all files that are no longer needed:"
330 echo " - Source tarballs in ${basedir}/source"
331 echo " - Unused installer packages in ${basedir}/archpkg"
332 echo
333 { (exit 0); exit 0; }
334}
335
336showCHECKSRC() {
337 echo "deploy.sh $version"
338 echo "USAGE: deploy.sh [options] checksrc"
339 echo
340 echo "Check PGP signatures of source tarballs in the source/ subdirectory"
341 echo "of the deploy system."
342 echo "You must have gpg (GnuPG) in your PATH, and you should have imported"
343 echo "the samhain release PGP key (Key ID 0F571F6C, Rainer Wichmann)."
344 echo "To import the key, simply execute the command"
345 echo "\"gpg --keyserver blackhole.pca.dfn.de --recv-keys 0F571F6C\""
346 echo
347 echo "Options:"
348 echo
349 echo " --delete Delete source tarballs if PGP signature"
350 echo " cannot be verified."
351 echo
352 { (exit 0); exit 0; }
353}
354
355showDOWNLOAD() {
356 echo "deploy.sh $version"
357 echo "USAGE: deploy.sh [options] download"
358 echo
359 echo "Download a samhain source tarball from http://www.la-samhna.de,"
360 echo "check its PGP signature, and install it into the source/ subdirectory"
361 echo "of the deploy system."
362 echo "You must have gpg (GnuPG) in your PATH, and you should have imported"
363 echo "the samhain release PGP key (Key ID 0F571F6C, Rainer Wichmann)."
364 echo "To import the key, simply execute the command"
365 echo "\"gpg --keyserver blackhole.pca.dfn.de --recv-keys 0F571F6C\""
366 echo
367 echo "Options:"
368 echo
369 echo " --version=<version> Version of samhain to download. The"
370 echo " default is \"current\" to download the current version."
371 echo
372 { (exit 0); exit 0; }
373}
374
375showBUILD() {
376 echo "deploy.sh $version"
377 echo "USAGE: deploy.sh [options] build"
378 echo
379 echo "Copy a source tarball to a build machine, build a binary package, and fetch"
380 echo "the package. Will bail out if not running under ssh-agent. If you are sure"
381 echo "that you don't need ssh-agent, set the environment variable SSH_AGENT_PID"
382 echo "to some arbitrary string before launching the deploy.sh command."
383 echo
384 echo "Options:"
385 echo
386 echo " --host=<hostname> The build host."
387 echo " --arch=<arch> The architecture/operating system to build for."
388 echo " This is used to get the \"./configure\" options from the file"
389 echo " \${basedir}/configs/\${arch}.configure."
390 echo " --version=<version> The version of samhain you want to build."
391 echo " --format=<run|rpm|deb|tbz2|solaris-pkg|depot>"
392 echo " The format of the package. \"run\" is a portable tar"
393 echo " package, \"deb\" is for Debian, \"tbz2\" for Gentoo,"
394 echo " \"rpm\" for any RPM-based Linux, \"solaris-pkg\""
395 echo " for Sun Solaris, and \"depot\" for HP-UX"
396 echo " --packed=<password> The client password, if you want to"
397 echo " create a packed executable. Defaults to empty (don't pack)"
398 echo " --user=<username> Login as <username> to the build host (root)."
399 echo " --add-path=<path> Append 'path' to the PATH variable on the build host."
400 { (exit 0); exit 0; }
401}
402
403showINSTALL() {
404 echo "deploy.sh $version"
405 echo "USAGE: deploy.sh [options] install"
406 echo
407 echo "Copy a pre-built binary installer package to a remote host, stop the client"
408 echo "running there (if any), install the (new) client, optionally initialize"
409 echo "the file signature database and fetch it from the remote host, update"
410 echo "the server configuration file and reload the server."
411 echo
412 echo "Options:"
413 echo
414 echo " --host=<FQDN> The host where you want to install."
415 echo " --arch=<arch> The architecture/operating system of this host."
416 echo " This is used to get the correct binary package."
417 echo " --version=<version> The version of samhain you want to install."
418 echo " --format=<run|rpm|deb|tbz2|solaris-pkg|depot>"
419 echo " The format of the binary package."
420 echo " --yule_exec=<path> The path to the 'yule' executable."
421 echo " --yule_conf=<path> The path to the 'yule' configuration file."
422 echo " --yule_data=<path> The path to the 'yule' data directory."
423 echo " --no-init Do not initialize the file signature database."
424 echo " --no-rcfile Do not replace the rc.host file on server."
425 echo " --no-start Do not start the client after installation."
426 echo " --local=<path> Local command (executed twice: "
427 echo " after config installation and before client startup)."
428 { (exit 0); exit 0; }
429}
430
431showUSAGE() {
432 echo "deploy.sh $version"
433 echo "USAGE: deploy.sh [options] command"
434 echo
435 echo "Commands: info | clean | download | checksrc | build | install | uninstall"
436 echo
437 echo "Options:"
438 echo " -h | --help Print general usage information."
439 echo " -h | --help <command> Print usage information for \"command\"."
440 echo " --basedir=<directory> Set the basedir for the deployment system."
441 echo " The default is ${defbasedir}."
442 echo " -q | --quiet Produce output suitable for logging."
443 echo " You can also use -q=# to set the quiet level up to"
444 echo " a maximum of 2. Note that -q=2 implies --yes (see below)."
445 echo " -s | --simulate Perform a simulation of events that"
446 echo " would occur but do not actually change the system."
447 echo " -y | --yes Assume "yes" as answer to"
448 echo " all prompts and run non-interactively."
449 echo " -o <file> | --logfile=<file>"
450 echo " Specify an output file for messages that would go to stdout"
451 echo " otherwise. Has no effect on stderr (error messages)."
452 echo " -d <dialog> | --dialog=<dialog> Specify your preferred \"dialog\""
453 echo " clone (e.g. Xdialog). Use \"no\" to force plain text."
454 if test x"$1" = x
455 then
456 { (exit 0); exit 0; }
457 else
458 { (exit $1); exit $1; }
459 fi
460}
461
462#########################################################################
463#
464# Command line
465#
466#########################################################################
467
468for option
469do
470
471 # If the previous option needs an argument, assign it.
472 #
473 if test -n "$opt_prev"; then
474 eval "$opt_prev=\$option"
475 eval export "$opt_prev"
476 opt_prev=
477 continue
478 fi
479
480 case "$option" in
481 -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
482 *) optarg= ;;
483 esac
484
485 case "$option" in
486
487 # Info
488
489 --packages | -packages)
490 showpkg=y; export showpkg;
491 ;;
492
493 # Install
494
495 --yule_exec | -yule_exec | --yule-exec | -yule-exec)
496 opt_prev=yule_exec
497 ;;
498
499 --yule_exec=* | -yule_exec=* | --yule-exec=* | -yule-exec=*)
500 yule_exec="$optarg"; export yule_exec
501 ;;
502
503 --yule_conf | -yule_conf | --yule-conf | -yule-conf)
504 opt_prev=yule_conf
505 ;;
506
507 --yule_conf=* | -yule_conf=* | --yule-conf=* | -yule-conf=*)
508 yule_conf="$optarg"; export yule_conf
509 ;;
510
511 --yule_data | -yule_data | --yule-data | -yule-data)
512 opt_prev=yule_data
513 ;;
514
515 --yule_data=* | -yule_data=* | --yule-data=* | -yule-data=*)
516 yule_data="$optarg"; export yule_data
517 ;;
518
519 --no-init | -no-init)
520 is_init=n; export is_init
521 ;;
522
523 --no-rcfile | -no-rcfile)
524 is_rcfile=n; export is_rcfile
525 ;;
526
527 --no-start | -no-start)
528 is_startup=n; export is_startup
529 ;;
530
531 --local | -local)
532 opt_prev=local_command
533 ;;
534
535 --local=* | -local=*)
536 local_command="$optarg"; export local_command
537 ;;
538
539 # Build
540
541 --format | -format)
542 opt_prev=format
543 ;;
544
545 --format=* | -format=*)
546 format="$optarg"; export format
547 ;;
548
549 --packed | --pack | -packed | -pack)
550 opt_prev=bd_packed
551 ;;
552
553 --packed=* | -packed=*)
554 bd_packed="$optarg"; export bd_packed
555 ;;
556
557 --user | -user)
558 opt_prev=bd_user
559 ;;
560
561 --user=* | -user=*)
562 bd_user="$optarg"; export bd_user
563 ;;
564
565 --add-path | -add-path | --addpath | -addpath)
566 opt_prev=bd_addpath
567 ;;
568
569 --add-path=* | -add-path=* | --addpath=* | -addpath=*)
570 bd_addpath="$optarg"; export bd_addpath
571 ;;
572
573 # Checksource
574
575 --delete | -delete)
576 cs_delete=1; export cs_delete
577 ;;
578
579 # Download
580
581 --version | -version)
582 opt_prev=src_version
583 ;;
584 --version=* | -version=*)
585 src_version="$optarg"; export src_version
586 ;;
587
588 # Generic
589
590 --basedir | -basedir)
591 opt_prev=basedir
592 ;;
593 --basedir=* | -basedir=*)
594 basedir="$optarg"; export basedir
595 ;;
596
597 --host | -host)
598 opt_prev=host
599 ;;
600 --host=* | -host=*)
601 host="$optarg"; export host
602 ;;
603
604 --arch | -arch)
605 opt_prev=arch
606 ;;
607 --arch=* | -arch=*)
608 arch="$optarg"; export arch
609 ;;
610
611 -o | --logfile | -logfile)
612 opt_prev=logfile
613 ;;
614 -o=* | --logfile=* | -logfile=*)
615 logfile="$optarg"; export logfile
616 ;;
617
618 -h | --h | --help | -help | help)
619 if test $# -gt 1
620 then
621 if test x"$2" = xdownload
622 then
623 showDOWNLOAD
624 elif test x"$2" = xinfo
625 then
626 showINFO
627 elif test x"$2" = xchecksrc
628 then
629 showCHECKSRC
630 elif test x"$2" = xclean
631 then
632 showCLEAN
633 elif test x"$2" = xbuild
634 then
635 showBUILD
636 elif test x"$2" = xinstall
637 then
638 showINSTALL
639 elif test x"$2" = xuninstall
640 then
641 showUNINSTALL
642 else
643 showUSAGE 1
644 fi
645 fi
646 showUSAGE
647 ;;
648
649 -q | --quiet | -quiet | --silent | -silent)
650 if test x"$silent" = x0
651 then
652 silent=1; export silent
653 else
654 silent=2; export silent
655 fi
656 ;;
657 -q=* | --quiet=* | --silent=* | -silent=*)
658 silent="$optarg"; export silent
659 ;;
660
661 -s | --simulate | -simulate | --dry-run | -dry-run | --recon | -recon | --just-print | -just-print | --no-act | -no-act)
662 simulate=1; export simulate
663 ;;
664
665 -y | --yes | -yes)
666 assumeyes=1; export assumeyes
667 ;;
668
669 -d | --dialog | -dialog)
670 opt_prev=DIALOG
671 ;;
672 -d=* | --dialog=* | -dialog=*)
673 DIALOG="$optarg"; export DIALOG
674 ;;
675
676 -*)
677 showUSAGE 1
678 ;;
679
680 clean | download | checksrc | build | install | info | uninstall)
681 action="$option"; export action
682 break ;;
683 esac
684
685done
686
687#########################################################################
688#
689# Subroutines
690#
691#########################################################################
692
693# -----------------------------------------------------------------------
694# Printing/logging Subroutines
695# -----------------------------------------------------------------------
696. ${basedir}/libexec/funcPRINT
697
698# -----------------------------------------------------------------------
699# Interaction Subroutines
700# -----------------------------------------------------------------------
701. ${basedir}/libexec/funcDIALOG
702
703# -----------------------------------------------------------------------
704# Setup test Subroutines
705# -----------------------------------------------------------------------
706. ${basedir}/libexec/funcSETUP
707
708# -----------------------------------------------------------------------
709# Subroutines for determining existence of / path to executables
710# -----------------------------------------------------------------------
711. ${basedir}/libexec/funcEXE
712
713# -----------------------------------------------------------------------
714# Subroutines for building
715# -----------------------------------------------------------------------
716. ${basedir}/libexec/funcBUILD
717
718# -----------------------------------------------------------------------
719# Subroutines for installing
720# -----------------------------------------------------------------------
721. ${basedir}/libexec/funcINSTALL
722
723# -----------------------------------------------------------------------
724# Subroutines for client database
725# -----------------------------------------------------------------------
726. ${basedir}/libexec/funcDB
727
728# -----------------------------------------------------------------------
729# Subroutine for the 'download' command
730# -----------------------------------------------------------------------
731. ${basedir}/libexec/comDOWNLOAD
732
733# -----------------------------------------------------------------------
734# Subroutine for the 'checksrc' command
735# -----------------------------------------------------------------------
736. ${basedir}/libexec/comCHECKSRC
737
738# -----------------------------------------------------------------------
739# Subroutine for the 'clean' command
740# -----------------------------------------------------------------------
741. ${basedir}/libexec/comCLEAN
742
743# -----------------------------------------------------------------------
744# Subroutine for the 'build' command
745# -----------------------------------------------------------------------
746. ${basedir}/libexec/comBUILD
747
748# -----------------------------------------------------------------------
749# Subroutine for the 'install' command
750# -----------------------------------------------------------------------
751. ${basedir}/libexec/comINSTALL
752
753# -----------------------------------------------------------------------
754# Subroutine for the 'install' command
755# -----------------------------------------------------------------------
756. ${basedir}/libexec/comUNINSTALL
757
758
759#########################################################################
760#
761# Main
762#
763#########################################################################
764
765main_exit_status=0
766
767tmpdir=
768
769# Find a dialog clone
770#
771findDIALOG
772
773# Check for basedir and tmpdir
774#
775testSETUP1
776
777# Logfile setup
778#
779exec 5>${basedir}/tmp/logfile.lastrun
780now=`date`
781echo "$now: $0 " ${1+"$@"} >&5
782lastlog="${basedir}/tmp/logfile.lastrun"; export lastlog
783logOpen=1
784
785# Temporary directory/file setup
786#
787tmpD="$tmpdir/build.gui.$$"
788mkdir "$tmpD" || printFATAL "Cannot create temporary directory $tmpD"
789export tmpD
790tmpF="$tmpD/tmpF.$$"
791touch $tmpF || printFATAL "Cannot create temporary file $tmpF"
792export tmpF
793tmpERR="$tmpD/tmpERR.$$"
794echo '0' > $tmpERR || printFATAL "Cannot create temporary file $tmpERR"
795export tmpERR
796
797# Trap exit and cleanup
798#
799trap "exit_status=$?; rm -rf $tmpD; exit ${exit_status};" 0
800trap "(exit 1); exit 1;" 1 2 13 15
801
802# Check for action to perform, and host, if required
803#
804testSETUP2
805
806if test x"$action" = xdownload
807then
808 if test x"$src_version" = x
809 then
810 src_version="current"; export src_version
811 fi
812 #---------------------------------------------------------------------
813 # Vodoo code to tee both stdout and stderr, but keep them seperate.
814 #---------------------------------------------------------------------
815 if test x"$DIALOG" = x
816 then
817 ((commandDOWNLOAD | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
818 tee -a "$lastlog") 6>&1 1>&2 2>&6
819 else
820 commandDOWNLOAD 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
821 --title "deploy.sh $version DOWNLOAD logfile" \
822 --backtitle "Logfile: $lastlog" \
823 --tailbox "$lastlog" 19 75
824 fi
825elif test x"$action" = xinfo
826then
827 if test x"${showpkg}" = xn
828 then
829 if test x"$DIALOG" = x
830 then
831 ((dbSHOWHOSTS "${host}" | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
832 tee -a "$lastlog") 6>&1 1>&2 2>&6
833 else
834 dbSHOWHOSTS "${host}" 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
835 --title "deploy.sh $version INFO logfile" \
836 --backtitle "Logfile: $lastlog" \
837 --tailbox "$lastlog" 19 75
838 fi
839 else
840 if test x"$DIALOG" = x
841 then
842 ((dbSHOWPKG show | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
843 tee -a "$lastlog") 6>&1 1>&2 2>&6
844 else
845 dbSHOWPKG show 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
846 --title "deploy.sh $version INFO logfile" \
847 --backtitle "Logfile: $lastlog" \
848 --tailbox "$lastlog" 19 75
849 fi
850 fi
851elif test x"$action" = xchecksrc
852then
853 if test x"$DIALOG" = x
854 then
855 ((commandCHECKSRC | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
856 tee -a "$lastlog") 6>&1 1>&2 2>&6
857 else
858 commandCHECKSRC 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
859 --title "deploy.sh $version CHECKSRC logfile" \
860 --backtitle "Logfile: $lastlog" \
861 --tailbox "$lastlog" 19 75
862 fi
863elif test x"$action" = xclean
864then
865 if test x"$DIALOG" = x
866 then
867 ((commandCLEAN | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
868 tee -a "$lastlog") 6>&1 1>&2 2>&6
869 else
870 commandCLEAN 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
871 --title "deploy.sh $version CLEAN logfile" \
872 --backtitle "Logfile: $lastlog" \
873 --tailbox "$lastlog" 19 75
874 fi
875elif test x"$action" = xbuild
876then
877
878 #---------------------------------------------------------------------
879 # Make sure we are running under ssh-agent.
880 #---------------------------------------------------------------------
881 if test x"$SSH_AGENT_PID" = x
882 then
883 if test x"$assumeyes" = x1
884 then
885 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
886 else
887 promptYESNO "Not running under ssh-agent, continue anyway" "no"
888 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
889 fi
890 fi
891
892 #---------------------------------------------------------------------
893 # Setup.
894 #---------------------------------------------------------------------
895 selBVERSION
896 selBARCH
897 selBFORMAT
898
899 if test x"$DIALOG" = x
900 then
901 ((commandBUILD | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
902 tee -a "$lastlog") 6>&1 1>&2 2>&6
903 else
904 commandBUILD 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
905 --title "deploy.sh $version BUILD logfile" \
906 --backtitle "Logfile: $lastlog" \
907 --tailbox "$lastlog" 19 75
908 fi
909
910elif test x"$action" = xinstall
911then
912
913 needEXE ssh scp ssh-agent
914
915 #---------------------------------------------------------------------
916 # Make sure we are running under ssh-agent.
917 #---------------------------------------------------------------------
918 if test x"$SSH_AGENT_PID" = x
919 then
920 if test x"$assumeyes" = x1
921 then
922 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
923 else
924 promptYESNO "Not running under ssh-agent, continue anyway" "no"
925 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
926 fi
927 fi
928
929 #---------------------------------------------------------------------
930 # Setup.
931 #---------------------------------------------------------------------
932 is_root=`id -u 2>/dev/null`
933 if test "x$?" = x0 && test "x${is_root}" != x0
934 then
935 promptYESNO "You are not root, continue anyway" "no"
936 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
937 else
938 is_root=0
939 fi
940 pathYULE
941 pathYDATA
942 selbinARCH
943 selbinVERSION
944 if test "x${is_init}" = xy
945 then
946 promptYESNO "Initialize database" "yes"
947 is_init=$YESNO
948 fi
949 if test "x${is_rcfile}" = xy
950 then
951 promptYESNO "Replace rc.host file on server" "yes"
952 is_rcfile=$YESNO
953 fi
954 if test "x${is_startup}" = xy
955 then
956 promptYESNO "Start client after installation" "yes"
957 is_startup=$YESNO
958 fi
959 if test -f "${yule_conf}"
960 then
961 :
962 else
963 promptINPUT "Please enter the path to the yule configuration file"
964 yule_conf="$INPUT"; export yule_conf
965 if test -f "${yule_conf}"
966 then
967 :
968 else
969 printFATAL "Cannot find ${yule_conf}"
970 fi
971 fi
972
973 if test x"$DIALOG" = x
974 then
975 ((commandINSTALL | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
976 tee -a "$lastlog") 6>&1 1>&2 2>&6
977 else
978 commandINSTALL 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
979 --title "deploy.sh $version INSTALL logfile" \
980 --backtitle "Logfile: $lastlog" \
981 --tailbox "$lastlog" 19 75
982 fi
983
984elif test x"$action" = xuninstall
985then
986
987 needEXE ssh scp ssh-agent
988
989 #---------------------------------------------------------------------
990 # Make sure we are running under ssh-agent.
991 #---------------------------------------------------------------------
992 if test x"$SSH_AGENT_PID" = x
993 then
994 if test x"$assumeyes" = x1
995 then
996 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
997 else
998 promptYESNO "Not running under ssh-agent, continue anyway" "no"
999 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
1000 fi
1001 fi
1002
1003 #---------------------------------------------------------------------
1004 # Setup.
1005 #---------------------------------------------------------------------
1006
1007 dbINFO "$host"
1008
1009 if test x"$?" = x0
1010 then
1011 if test x"${DB_status}" = "xD2_installed"
1012 then
1013 :
1014 else
1015 if test x"${DB_status}" = "xD2_removed"
1016 then
1017 promptYESNO "Already uninstalled on host $host, continue" "no"
1018 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
1019 else
1020 printFATAL "No deploy version 2 installation on host $host: ${DB_status}"
1021 fi
1022 fi
1023 else
1024 printFATAL "Cannot uninstall on host $host"
1025 fi
1026
1027 if test x"$DIALOG" = x
1028 then
1029 ((commandUNINSTALL | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
1030 tee -a "$lastlog") 6>&1 1>&2 2>&6
1031 else
1032 commandUNINSTALL 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
1033 --title "deploy.sh $version UNINSTALL logfile" \
1034 --backtitle "Logfile: $lastlog" \
1035 --tailbox "$lastlog" 19 75
1036 fi
1037
1038fi
1039
1040if test x"${main_exit_status}" = x0
1041then
1042 test -f "$tmpERR" && main_exit_status=`cat "$tmpERR" | tr -d '\n'`
1043fi
1044
1045(exit ${main_exit_status}); exit ${main_exit_status};
Note: See TracBrowser for help on using the repository browser.