source: trunk/deploy.sh.in@ 277

Last change on this file since 277 was 38, checked in by rainer, 18 years ago

Added option to specify a group in deploy.sh install

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