diff packaging/linux-installer.inc.in @ 700:bf87feccb26c

Write installation configuration file.
author Sascha Wilde <wilde@intevation.de>
date Wed, 02 Jul 2014 10:53:43 +0200
parents b55d49150e36
children 480bc550d2ad
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Tue Jul 01 17:22:31 2014 +0200
+++ b/packaging/linux-installer.inc.in	Wed Jul 02 10:53:43 2014 +0200
@@ -1,15 +1,23 @@
 #!/bin/bash
 
 ME=`basename "$0"`
-VERSION='@PROJECT_VERSION@'
 DEFAULT_PREFIX=/usr/local
+CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge"
+SYSCFGPATH="/etc/TrustBridge"
+INSTCFGNAME="installation.cfg"
 
-path=""
+instcfg_file="${CFGPATH}/${INSTCFGNAME}"
+declare -A instcfg
+instcfg=(
+  [TIMESTMP]=`date -u +%Y%m%d%H%M%S`
+  [VERSION]='@PROJECT_VERSION@'
+  [PREFIX]=''
+)
 
 version()
 {
   cat <<EOF
-TrustBridge $VERSION Installer
+TrustBridge ${instcfg[VERSION]} Installer
 
 Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 Software engineering by Intevation GmbH
@@ -54,7 +62,7 @@
   while true ; do
     case "$1" in
       --prefix|-p)
-        path="$2"
+        instcfg[PREFIX]="$2"
         shift 2
         ;;
       --help)
@@ -71,6 +79,15 @@
   done
 }
 
+write_instcfg()
+{
+  install -d `dirname "$instcfg_file"`
+  echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file"
+  for key in "${!instcfg[@]}" ; do
+    echo "${key}=${instcfg[$key]}" >>"$instcfg_file"
+  done
+}
+
 #======================================================================
 # main()
 
@@ -80,27 +97,33 @@
 ------------------------------------------------------------------------
 
    TrustBridge - Installer
-   Version $VERSION
+   Version ${instcfg[VERSION]}
 
 ------------------------------------------------------------------------
 EOF
 
-if [ -z "$path" ] ; then
+if [ -z "${instcfg[PREFIX]}" ] ; then
     echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: "
-    read -e path
+    read -e instcfg[PREFIX]
 
-    [ -z "$path" ] && path="${DEFAULT_PREFIX}"
+    [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${DEFAULT_PREFIX}"
 fi
 
-echo "Installing to '$path':"
+echo "Installing to '${instcfg[PREFIX]}':"
 
-if [ ! -d "$path" ] ; then
+if [ ! -d "${instcfg[PREFIX]}" ] ; then
     echo "creating installation directory ..."
-    install -d "$path" || fatal "Could not create '$path'!"
+    install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!"
 fi
 
 echo "unpacking files ..."
-cd "$path"
+cd "${instcfg[PREFIX]}"
 
 # ----------------------------------------------------------------------
-# regular shar archive appended here:
+# regular shar archive inserted here:
+###SHAR###
+# ----------------------------------------------------------------------
+
+echo "Writing installation configuration to: $instcfg_file ..."
+write_instcfg
+exit 0

http://wald.intevation.org/projects/trustbridge/