[PATCH 1 of 2] Added command line args for unattended installation

Wald Commits scm-commit at wald.intevation.org
Tue Jul 1 17:23:04 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404228081 -7200
# Node ID b55d49150e3698a87b7801e3a29cf3a0ec326c7a
# Parent  25a73bfec35925e64165846b3c90de839163d5b4
Added command line args for unattended installation.

diff -r 25a73bfec359 -r b55d49150e36 packaging/linux-installer.inc.in
--- a/packaging/linux-installer.inc.in	Tue Jul 01 16:53:31 2014 +0200
+++ b/packaging/linux-installer.inc.in	Tue Jul 01 17:21:21 2014 +0200
@@ -1,6 +1,25 @@
 #!/bin/bash
 
-PREFIX=/usr/local
+ME=`basename "$0"`
+VERSION='@PROJECT_VERSION@'
+DEFAULT_PREFIX=/usr/local
+
+path=""
+
+version()
+{
+  cat <<EOF
+TrustBridge $VERSION Installer
+
+Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+Software engineering by Intevation GmbH
+
+This is free software.  You may redistribute copies of it under the terms of
+the GNU GPL (v>=2).   See LICENSE.txt for details.
+There is NO WARRANTY, to the extent permitted by law.
+EOF
+  exit 0
+}
 
 fatal()
 {
@@ -9,19 +28,69 @@
   exit 1
 }
 
+usage()
+{
+  cat <<EOF
+Usage: $ME [OPTION]...
+Install TrustBridge.
+
+Options:
+  -p, --prefix=PATH  install files in PATH
+      --help         display this help and exit
+      --version      output version information and exit
+EOF
+  exit $1
+}
+
+parse_args()
+{
+  OPTS=`getopt \
+      -l help,prefix:,version \
+      -o p: -n "$ME" -- "$@"`
+  [ $? -eq 0 ] || usage 23
+
+  eval set -- "$OPTS"
+
+  while true ; do
+    case "$1" in
+      --prefix|-p)
+        path="$2"
+        shift 2
+        ;;
+      --help)
+        usage 0
+        ;;
+      --version)
+        version
+        ;;
+      --)
+        shift
+        break
+        ;;
+    esac
+  done
+}
+
+#======================================================================
+# main()
+
+parse_args "$@"
+
 cat <<EOF
 ------------------------------------------------------------------------
 
    TrustBridge - Installer
-   Version @PROJECT_VERSION@
+   Version $VERSION
 
 ------------------------------------------------------------------------
 EOF
 
-echo -n "Select installation prefix for TrustBridge [${PREFIX}]: "
-read -e path
+if [ -z "$path" ] ; then
+    echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: "
+    read -e path
 
-[ -z "$path" ] && path="${PREFIX}"
+    [ -z "$path" ] && path="${DEFAULT_PREFIX}"
+fi
 
 echo "Installing to '$path':"
 


More information about the Trustbridge-commits mailing list