source: trunk/deploy.sh.in@ 33

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

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

File size: 29.3 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
248# action; no default
249#
250action=
251export action
252
253# the 'log.lastrun' logfile
254#
255logOpen=0
256export logOpen
257
258
259# source version; default = current
260#
261src_version=""
262export src_version
263
264# checksrc; do you want to delete if PGP signature check fails ?
265#
266cs_delete=0
267export cs_delete
268
269# build; do you want to pack the executable ?
270#
271bd_packed=''
272export bd_packed
273
274bd_user='root'
275export bd_user
276
277# addpath
278#
279bd_addpath=""
280export bd_addpath
281
282# Install; do you want to initialize the database ?
283#
284is_init=y
285export is_init
286
287# Install; do you want to replace the rc.host file ?
288#
289is_rcfile=y
290export is_rcfile
291
292# Install; do you want to start the client ?
293#
294is_startup=y
295export is_startup
296
297# Install; optional local command ?
298#
299local_command=""; export local_command
300
301# Info on packages ?
302#
303showpkg=n
304export showpkg
305
306#########################################################################
307#
308# Help Subroutines
309#
310#########################################################################
311
312# -----------------------------------------------------------------------
313# We cannot source these, because we don't know yet the base directory
314# -----------------------------------------------------------------------
315
316showUNINSTALL() {
317 echo "deploy.sh $version"
318 echo "USAGE: deploy.sh [options] uninstall"
319 echo
320 echo "Uninstall the samhain client from the specified host. Can only be"
321 echo "used if the client has been installed with deploy.sh version 2."
322 echo
323 echo "Options:"
324 echo
325 echo " --host=<hostname> The host where you want to uninstall."
326 echo
327 { (exit 0); exit 0; }
328}
329
330showINFO() {
331 echo "deploy.sh $version"
332 echo "USAGE: deploy.sh [options] info"
333 echo
334 echo "Show info for hosts in client database (default), or for available"
335 echo "binary installer packages."
336 echo
337 echo "Options:"
338 echo
339 echo " --packages Show info on packages."
340 echo
341 { (exit 0); exit 0; }
342}
343
344showCLEAN() {
345 echo "deploy.sh $version"
346 echo "USAGE: deploy.sh [options] clean"
347 echo
348 echo "Remove all files that are no longer needed:"
349 echo " - Source tarballs in ${basedir}/source"
350 echo " - Unused installer packages in ${basedir}/archpkg"
351 echo
352 { (exit 0); exit 0; }
353}
354
355showCHECKSRC() {
356 echo "deploy.sh $version"
357 echo "USAGE: deploy.sh [options] checksrc"
358 echo
359 echo "Check PGP signatures of source tarballs in the source/ subdirectory"
360 echo "of the deploy system."
361 echo "You must have gpg (GnuPG) in your PATH, and you should have imported"
362 echo "the samhain release PGP key (Key ID 0F571F6C, Rainer Wichmann)."
363 echo "To import the key, simply execute the command"
364 echo "\"gpg --keyserver blackhole.pca.dfn.de --recv-keys 0F571F6C\""
365 echo
366 echo "Options:"
367 echo
368 echo " --delete Delete source tarballs if PGP signature"
369 echo " cannot be verified."
370 echo
371 { (exit 0); exit 0; }
372}
373
374showDOWNLOAD() {
375 echo "deploy.sh $version"
376 echo "USAGE: deploy.sh [options] download"
377 echo
378 echo "Download a samhain source tarball from http://www.la-samhna.de,"
379 echo "check its PGP signature, and install it into the source/ subdirectory"
380 echo "of the deploy system."
381 echo "You must have gpg (GnuPG) in your PATH, and you should have imported"
382 echo "the samhain release PGP key (Key ID 0F571F6C, Rainer Wichmann)."
383 echo "To import the key, simply execute the command"
384 echo "\"gpg --keyserver blackhole.pca.dfn.de --recv-keys 0F571F6C\""
385 echo
386 echo "Options:"
387 echo
388 echo " --version=<version> Version of samhain to download. The"
389 echo " default is \"current\" to download the current version."
390 echo
391 { (exit 0); exit 0; }
392}
393
394showBUILD() {
395 echo "deploy.sh $version"
396 echo "USAGE: deploy.sh [options] build"
397 echo
398 echo "Copy a source tarball to a build machine, build a binary package, and fetch"
399 echo "the package. Will bail out if not running under ssh-agent. If you are sure"
400 echo "that you don't need ssh-agent, set the environment variable SSH_AGENT_PID"
401 echo "to some arbitrary string before launching the deploy.sh command."
402 echo
403 echo "Options:"
404 echo
405 echo " --host=<hostname> The build host."
406 echo " --arch=<arch> The architecture/operating system to build for."
407 echo " This is used to get the \"./configure\" options from the file"
408 echo " \${basedir}/configs/\${arch}.configure."
409 echo " --version=<version> The version of samhain you want to build."
410 echo " --format=<run|rpm|deb|tbz2|solaris-pkg|depot>"
411 echo " The format of the package. \"run\" is a portable tar"
412 echo " package, \"deb\" is for Debian, \"tbz2\" for Gentoo,"
413 echo " \"rpm\" for any RPM-based Linux, \"solaris-pkg\""
414 echo " for Sun Solaris, and \"depot\" for HP-UX"
415 echo " --packed=<password> The client password, if you want to"
416 echo " create a packed executable. Defaults to empty (don't pack)"
417 echo " --user=<username> Login as <username> to the build host (root)."
418 echo " --add-path=<path> Append 'path' to the PATH variable on the build host."
419 { (exit 0); exit 0; }
420}
421
422showINSTALL() {
423 echo "deploy.sh $version"
424 echo "USAGE: deploy.sh [options] install"
425 echo
426 echo "Copy a pre-built binary installer package to a remote host, stop the client"
427 echo "running there (if any), install the (new) client, optionally initialize"
428 echo "the file signature database and fetch it from the remote host, update"
429 echo "the server configuration file and reload the server."
430 echo
431 echo "Options:"
432 echo
433 echo " --host=<FQDN> The host where you want to install."
434 echo " --arch=<arch> The architecture/operating system of this host."
435 echo " This is used to get the correct binary package."
436 echo " --version=<version> The version of samhain you want to install."
437 echo " --format=<run|rpm|deb|tbz2|solaris-pkg|depot>"
438 echo " The format of the binary package."
439 echo " --yule_exec=<path> The path to the 'yule' executable."
440 echo " --yule_conf=<path> The path to the 'yule' configuration file."
441 echo " --yule_data=<path> The path to the 'yule' data directory."
442 echo " --no-init Do not initialize the file signature database."
443 echo " --no-rcfile Do not replace the rc.host file on server."
444 echo " --no-start Do not start the client after installation."
445 echo " --local=<path> Local command (executed twice: "
446 echo " after config installation and before client startup)."
447 { (exit 0); exit 0; }
448}
449
450showUSAGE() {
451 echo "deploy.sh $version"
452 echo "USAGE: deploy.sh [options] command"
453 echo
454 echo "Commands: info | clean | download | checksrc | build | install | uninstall"
455 echo
456 echo "Options:"
457 echo " -h | --help Print general usage information."
458 echo " -h | --help <command> Print usage information for \"command\"."
459 echo " --basedir=<directory> Set the basedir for the deployment system."
460 echo " The default is ${defbasedir}."
461 echo " -q | --quiet Produce output suitable for logging."
462 echo " You can also use -q=# to set the quiet level up to"
463 echo " a maximum of 2. Note that -q=2 implies --yes (see below)."
464 echo " -s | --simulate Perform a simulation of events that"
465 echo " would occur but do not actually change the system."
466 echo " -y | --yes Assume "yes" as answer to"
467 echo " all prompts and run non-interactively."
468 echo " -o <file> | --logfile=<file>"
469 echo " Specify an output file for messages that would go to stdout"
470 echo " otherwise. Has no effect on stderr (error messages)."
471 echo " -d <dialog> | --dialog=<dialog> Specify your preferred \"dialog\""
472 echo " clone (e.g. Xdialog). Use \"no\" to force plain text."
473 if test x"$1" = x
474 then
475 { (exit 0); exit 0; }
476 else
477 { (exit $1); exit $1; }
478 fi
479}
480
481#########################################################################
482#
483# Command line
484#
485#########################################################################
486
487for option
488do
489
490 # If the previous option needs an argument, assign it.
491 #
492 if test -n "$opt_prev"; then
493 eval "$opt_prev=\$option"
494 eval export "$opt_prev"
495 opt_prev=
496 continue
497 fi
498
499 case "$option" in
500 -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
501 *) optarg= ;;
502 esac
503
504 case "$option" in
505
506 # Info
507
508 --packages | -packages)
509 showpkg=y; export showpkg;
510 ;;
511
512 # Install
513
514 --yule_exec | -yule_exec | --yule-exec | -yule-exec)
515 opt_prev=yule_exec
516 ;;
517
518 --yule_exec=* | -yule_exec=* | --yule-exec=* | -yule-exec=*)
519 yule_exec="$optarg"; export yule_exec
520 ;;
521
522 --yule_conf | -yule_conf | --yule-conf | -yule-conf)
523 opt_prev=yule_conf
524 ;;
525
526 --yule_conf=* | -yule_conf=* | --yule-conf=* | -yule-conf=*)
527 yule_conf="$optarg"; export yule_conf
528 ;;
529
530 --yule_data | -yule_data | --yule-data | -yule-data)
531 opt_prev=yule_data
532 ;;
533
534 --yule_data=* | -yule_data=* | --yule-data=* | -yule-data=*)
535 yule_data="$optarg"; export yule_data
536 ;;
537
538 --no-init | -no-init)
539 is_init=n; export is_init
540 ;;
541
542 --no-rcfile | -no-rcfile)
543 is_rcfile=n; export is_rcfile
544 ;;
545
546 --no-start | -no-start)
547 is_startup=n; export is_startup
548 ;;
549
550 --local | -local)
551 opt_prev=local_command
552 ;;
553
554 --local=* | -local=*)
555 local_command="$optarg"; export local_command
556 ;;
557
558 # Build
559
560 --format | -format)
561 opt_prev=format
562 ;;
563
564 --format=* | -format=*)
565 format="$optarg"; export format
566 ;;
567
568 --packed | --pack | -packed | -pack)
569 opt_prev=bd_packed
570 ;;
571
572 --packed=* | -packed=*)
573 bd_packed="$optarg"; export bd_packed
574 ;;
575
576 --user | -user)
577 opt_prev=bd_user
578 ;;
579
580 --user=* | -user=*)
581 bd_user="$optarg"; export bd_user
582 ;;
583
584 --add-path | -add-path | --addpath | -addpath)
585 opt_prev=bd_addpath
586 ;;
587
588 --add-path=* | -add-path=* | --addpath=* | -addpath=*)
589 bd_addpath="$optarg"; export bd_addpath
590 ;;
591
592 # Checksource
593
594 --delete | -delete)
595 cs_delete=1; export cs_delete
596 ;;
597
598 # Download
599
600 --version | -version)
601 opt_prev=src_version
602 ;;
603 --version=* | -version=*)
604 src_version="$optarg"; export src_version
605 ;;
606
607 # Generic
608
609 --basedir | -basedir)
610 opt_prev=basedir
611 ;;
612 --basedir=* | -basedir=*)
613 basedir="$optarg"; export basedir
614 ;;
615
616 --host | -host)
617 opt_prev=host
618 ;;
619 --host=* | -host=*)
620 host="$optarg"; export host
621 ;;
622
623 --arch | -arch)
624 opt_prev=arch
625 ;;
626 --arch=* | -arch=*)
627 arch="$optarg"; export arch
628 ;;
629
630 -o | --logfile | -logfile)
631 opt_prev=logfile
632 ;;
633 -o=* | --logfile=* | -logfile=*)
634 logfile="$optarg"; export logfile
635 ;;
636
637 -h | --h | --help | -help | help)
638 if test $# -gt 1
639 then
640 if test x"$2" = xdownload
641 then
642 showDOWNLOAD
643 elif test x"$2" = xinfo
644 then
645 showINFO
646 elif test x"$2" = xchecksrc
647 then
648 showCHECKSRC
649 elif test x"$2" = xclean
650 then
651 showCLEAN
652 elif test x"$2" = xbuild
653 then
654 showBUILD
655 elif test x"$2" = xinstall
656 then
657 showINSTALL
658 elif test x"$2" = xuninstall
659 then
660 showUNINSTALL
661 else
662 showUSAGE 1
663 fi
664 fi
665 showUSAGE
666 ;;
667
668 -q | --quiet | -quiet | --silent | -silent)
669 if test x"$silent" = x0
670 then
671 silent=1; export silent
672 else
673 silent=2; export silent
674 fi
675 ;;
676 -q=* | --quiet=* | --silent=* | -silent=*)
677 silent="$optarg"; export silent
678 ;;
679
680 -s | --simulate | -simulate | --dry-run | -dry-run | --recon | -recon | --just-print | -just-print | --no-act | -no-act)
681 simulate=1; export simulate
682 ;;
683
684 -y | --yes | -yes)
685 assumeyes=1; export assumeyes
686 ;;
687
688 -d | --dialog | -dialog)
689 opt_prev=DIALOG
690 ;;
691 -d=* | --dialog=* | -dialog=*)
692 DIALOG="$optarg"; export DIALOG
693 ;;
694
695 -*)
696 showUSAGE 1
697 ;;
698
699 clean | download | checksrc | build | install | info | uninstall)
700 action="$option"; export action
701 break ;;
702 esac
703
704done
705
706#########################################################################
707#
708# Subroutines
709#
710#########################################################################
711
712# -----------------------------------------------------------------------
713# Printing/logging Subroutines
714# -----------------------------------------------------------------------
715. ${basedir}/libexec/funcPRINT
716
717# -----------------------------------------------------------------------
718# Interaction Subroutines
719# -----------------------------------------------------------------------
720. ${basedir}/libexec/funcDIALOG
721
722# -----------------------------------------------------------------------
723# Setup test Subroutines
724# -----------------------------------------------------------------------
725. ${basedir}/libexec/funcSETUP
726
727# -----------------------------------------------------------------------
728# Subroutines for determining existence of / path to executables
729# -----------------------------------------------------------------------
730. ${basedir}/libexec/funcEXE
731
732# -----------------------------------------------------------------------
733# Subroutines for building
734# -----------------------------------------------------------------------
735. ${basedir}/libexec/funcBUILD
736
737# -----------------------------------------------------------------------
738# Subroutines for installing
739# -----------------------------------------------------------------------
740. ${basedir}/libexec/funcINSTALL
741
742# -----------------------------------------------------------------------
743# Subroutines for client database
744# -----------------------------------------------------------------------
745. ${basedir}/libexec/funcDB
746
747# -----------------------------------------------------------------------
748# Subroutine for the 'download' command
749# -----------------------------------------------------------------------
750. ${basedir}/libexec/comDOWNLOAD
751
752# -----------------------------------------------------------------------
753# Subroutine for the 'checksrc' command
754# -----------------------------------------------------------------------
755. ${basedir}/libexec/comCHECKSRC
756
757# -----------------------------------------------------------------------
758# Subroutine for the 'clean' command
759# -----------------------------------------------------------------------
760. ${basedir}/libexec/comCLEAN
761
762# -----------------------------------------------------------------------
763# Subroutine for the 'build' command
764# -----------------------------------------------------------------------
765. ${basedir}/libexec/comBUILD
766
767# -----------------------------------------------------------------------
768# Subroutine for the 'install' command
769# -----------------------------------------------------------------------
770. ${basedir}/libexec/comINSTALL
771
772# -----------------------------------------------------------------------
773# Subroutine for the 'install' command
774# -----------------------------------------------------------------------
775. ${basedir}/libexec/comUNINSTALL
776
777
778#########################################################################
779#
780# Main
781#
782#########################################################################
783
784main_exit_status=0
785
786tmpdir=
787
788# Find a dialog clone
789#
790findDIALOG
791
792# Check for basedir and tmpdir
793#
794testSETUP1
795
796# Logfile setup
797#
798exec 5>${basedir}/tmp/logfile.lastrun
799now=`date`
800echo "$now: $0 " ${1+"$@"} >&5
801lastlog="${basedir}/tmp/logfile.lastrun"; export lastlog
802logOpen=1
803
804# Temporary directory/file setup
805#
806tmpD="$tmpdir/build.gui.$$"
807mkdir "$tmpD" || printFATAL "Cannot create temporary directory $tmpD"
808export tmpD
809tmpF="$tmpD/tmpF.$$"
810touch $tmpF || printFATAL "Cannot create temporary file $tmpF"
811export tmpF
812tmpERR="$tmpD/tmpERR.$$"
813echo '0' > $tmpERR || printFATAL "Cannot create temporary file $tmpERR"
814export tmpERR
815
816# Trap exit and cleanup
817#
818trap "exit_status=$?; rm -rf $tmpD; exit ${exit_status};" 0
819trap "(exit 1); exit 1;" 1 2 13 15
820
821# Check for action to perform, and host, if required
822#
823testSETUP2
824
825if test x"$action" = xdownload
826then
827 if test x"$src_version" = x
828 then
829 src_version="current"; export src_version
830 fi
831 #---------------------------------------------------------------------
832 # Vodoo code to tee both stdout and stderr, but keep them seperate.
833 #---------------------------------------------------------------------
834 if test x"$DIALOG" = x
835 then
836 ((commandDOWNLOAD | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
837 tee -a "$lastlog") 6>&1 1>&2 2>&6
838 else
839 commandDOWNLOAD 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
840 --title "deploy.sh $version DOWNLOAD logfile" \
841 --backtitle "Logfile: $lastlog" \
842 --tailbox "$lastlog" 19 75
843 fi
844elif test x"$action" = xinfo
845then
846 if test x"${showpkg}" = xn
847 then
848 if test x"$DIALOG" = x
849 then
850 ((dbSHOWHOSTS "${host}" | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
851 tee -a "$lastlog") 6>&1 1>&2 2>&6
852 else
853 dbSHOWHOSTS "${host}" 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
854 --title "deploy.sh $version INFO logfile" \
855 --backtitle "Logfile: $lastlog" \
856 --tailbox "$lastlog" 19 75
857 fi
858 else
859 if test x"$DIALOG" = x
860 then
861 ((dbSHOWPKG show | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
862 tee -a "$lastlog") 6>&1 1>&2 2>&6
863 else
864 dbSHOWPKG show 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
865 --title "deploy.sh $version INFO logfile" \
866 --backtitle "Logfile: $lastlog" \
867 --tailbox "$lastlog" 19 75
868 fi
869 fi
870elif test x"$action" = xchecksrc
871then
872 if test x"$DIALOG" = x
873 then
874 ((commandCHECKSRC | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
875 tee -a "$lastlog") 6>&1 1>&2 2>&6
876 else
877 commandCHECKSRC 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
878 --title "deploy.sh $version CHECKSRC logfile" \
879 --backtitle "Logfile: $lastlog" \
880 --tailbox "$lastlog" 19 75
881 fi
882elif test x"$action" = xclean
883then
884 if test x"$DIALOG" = x
885 then
886 ((commandCLEAN | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
887 tee -a "$lastlog") 6>&1 1>&2 2>&6
888 else
889 commandCLEAN 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
890 --title "deploy.sh $version CLEAN logfile" \
891 --backtitle "Logfile: $lastlog" \
892 --tailbox "$lastlog" 19 75
893 fi
894elif test x"$action" = xbuild
895then
896
897 #---------------------------------------------------------------------
898 # Make sure we are running under ssh-agent.
899 #---------------------------------------------------------------------
900 if test x"$SSH_AGENT_PID" = x
901 then
902 if test x"$assumeyes" = x1
903 then
904 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
905 else
906 promptYESNO "Not running under ssh-agent, continue anyway" "no"
907 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
908 fi
909 fi
910
911 #---------------------------------------------------------------------
912 # Setup.
913 #---------------------------------------------------------------------
914 selBVERSION
915 selBARCH
916 selBFORMAT
917
918 if test x"$DIALOG" = x
919 then
920 ((commandBUILD | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
921 tee -a "$lastlog") 6>&1 1>&2 2>&6
922 else
923 commandBUILD 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
924 --title "deploy.sh $version BUILD logfile" \
925 --backtitle "Logfile: $lastlog" \
926 --tailbox "$lastlog" 19 75
927 fi
928
929elif test x"$action" = xinstall
930then
931
932 needEXE ssh scp ssh-agent
933
934 #---------------------------------------------------------------------
935 # Make sure we are running under ssh-agent.
936 #---------------------------------------------------------------------
937 if test x"$SSH_AGENT_PID" = x
938 then
939 if test x"$assumeyes" = x1
940 then
941 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
942 else
943 promptYESNO "Not running under ssh-agent, continue anyway" "no"
944 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
945 fi
946 fi
947
948 #---------------------------------------------------------------------
949 # Setup.
950 #---------------------------------------------------------------------
951 is_root=`id -u 2>/dev/null`
952 if test "x$?" = x0 && test "x${is_root}" != x0
953 then
954 promptYESNO "You are not root, continue anyway" "no"
955 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
956 else
957 is_root=0
958 fi
959 pathYULE
960 pathYDATA
961 selbinARCH
962 selbinVERSION
963 if test "x${is_init}" = xy
964 then
965 promptYESNO "Initialize database" "yes"
966 is_init=$YESNO
967 fi
968 if test "x${is_rcfile}" = xy
969 then
970 promptYESNO "Replace rc.host file on server" "yes"
971 is_rcfile=$YESNO
972 fi
973 if test "x${is_startup}" = xy
974 then
975 promptYESNO "Start client after installation" "yes"
976 is_startup=$YESNO
977 fi
978 if test -f "${yule_conf}"
979 then
980 :
981 else
982 promptINPUT "Please enter the path to the yule configuration file"
983 yule_conf="$INPUT"; export yule_conf
984 if test -f "${yule_conf}"
985 then
986 :
987 else
988 printFATAL "Cannot find ${yule_conf}"
989 fi
990 fi
991
992 if test x"$DIALOG" = x
993 then
994 ((commandINSTALL | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
995 tee -a "$lastlog") 6>&1 1>&2 2>&6
996 else
997 commandINSTALL 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
998 --title "deploy.sh $version INSTALL logfile" \
999 --backtitle "Logfile: $lastlog" \
1000 --tailbox "$lastlog" 19 75
1001 fi
1002
1003elif test x"$action" = xuninstall
1004then
1005
1006 needEXE ssh scp ssh-agent
1007
1008 #---------------------------------------------------------------------
1009 # Make sure we are running under ssh-agent.
1010 #---------------------------------------------------------------------
1011 if test x"$SSH_AGENT_PID" = x
1012 then
1013 if test x"$assumeyes" = x1
1014 then
1015 printFATAL "Not running under ssh-agent, and not running interactive: cannot continue."
1016 else
1017 promptYESNO "Not running under ssh-agent, continue anyway" "no"
1018 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
1019 fi
1020 fi
1021
1022 #---------------------------------------------------------------------
1023 # Setup.
1024 #---------------------------------------------------------------------
1025
1026 dbINFO "$host"
1027
1028 if test x"$?" = x0
1029 then
1030 if test x"${DB_status}" = "xD2_installed"
1031 then
1032 :
1033 else
1034 if test x"${DB_status}" = "xD2_removed"
1035 then
1036 promptYESNO "Already uninstalled on host $host, continue" "no"
1037 test "x$YESNO" = xn && { (exit 0; ); exit 0; }
1038 else
1039 printFATAL "No deploy version 2 installation on host $host: ${DB_status}"
1040 fi
1041 fi
1042 else
1043 printFATAL "Cannot uninstall on host $host"
1044 fi
1045
1046 if test x"$DIALOG" = x
1047 then
1048 ((commandUNINSTALL | tee -a "$lastlog") 6>&1 1>&2 2>&6 | \
1049 tee -a "$lastlog") 6>&1 1>&2 2>&6
1050 else
1051 commandUNINSTALL 2>&1 | tee -a "$lastlog" >/dev/null | $DIALOG \
1052 --title "deploy.sh $version UNINSTALL logfile" \
1053 --backtitle "Logfile: $lastlog" \
1054 --tailbox "$lastlog" 19 75
1055 fi
1056
1057fi
1058
1059if test x"${main_exit_status}" = x0
1060then
1061 test -f "$tmpERR" && main_exit_status=`cat "$tmpERR" | tr -d '\n'`
1062fi
1063
1064(exit ${main_exit_status}); exit ${main_exit_status};
Note: See TracBrowser for help on using the repository browser.