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