Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
699:f12b102b33ca | 700:bf87feccb26c |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 ME=`basename "$0"` | 3 ME=`basename "$0"` |
4 VERSION='@PROJECT_VERSION@' | |
5 DEFAULT_PREFIX=/usr/local | 4 DEFAULT_PREFIX=/usr/local |
5 CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge" | |
6 SYSCFGPATH="/etc/TrustBridge" | |
7 INSTCFGNAME="installation.cfg" | |
6 | 8 |
7 path="" | 9 instcfg_file="${CFGPATH}/${INSTCFGNAME}" |
10 declare -A instcfg | |
11 instcfg=( | |
12 [TIMESTMP]=`date -u +%Y%m%d%H%M%S` | |
13 [VERSION]='@PROJECT_VERSION@' | |
14 [PREFIX]='' | |
15 ) | |
8 | 16 |
9 version() | 17 version() |
10 { | 18 { |
11 cat <<EOF | 19 cat <<EOF |
12 TrustBridge $VERSION Installer | 20 TrustBridge ${instcfg[VERSION]} Installer |
13 | 21 |
14 Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik | 22 Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
15 Software engineering by Intevation GmbH | 23 Software engineering by Intevation GmbH |
16 | 24 |
17 This is free software. You may redistribute copies of it under the terms of | 25 This is free software. You may redistribute copies of it under the terms of |
52 eval set -- "$OPTS" | 60 eval set -- "$OPTS" |
53 | 61 |
54 while true ; do | 62 while true ; do |
55 case "$1" in | 63 case "$1" in |
56 --prefix|-p) | 64 --prefix|-p) |
57 path="$2" | 65 instcfg[PREFIX]="$2" |
58 shift 2 | 66 shift 2 |
59 ;; | 67 ;; |
60 --help) | 68 --help) |
61 usage 0 | 69 usage 0 |
62 ;; | 70 ;; |
69 ;; | 77 ;; |
70 esac | 78 esac |
71 done | 79 done |
72 } | 80 } |
73 | 81 |
82 write_instcfg() | |
83 { | |
84 install -d `dirname "$instcfg_file"` | |
85 echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file" | |
86 for key in "${!instcfg[@]}" ; do | |
87 echo "${key}=${instcfg[$key]}" >>"$instcfg_file" | |
88 done | |
89 } | |
90 | |
74 #====================================================================== | 91 #====================================================================== |
75 # main() | 92 # main() |
76 | 93 |
77 parse_args "$@" | 94 parse_args "$@" |
78 | 95 |
79 cat <<EOF | 96 cat <<EOF |
80 ------------------------------------------------------------------------ | 97 ------------------------------------------------------------------------ |
81 | 98 |
82 TrustBridge - Installer | 99 TrustBridge - Installer |
83 Version $VERSION | 100 Version ${instcfg[VERSION]} |
84 | 101 |
85 ------------------------------------------------------------------------ | 102 ------------------------------------------------------------------------ |
86 EOF | 103 EOF |
87 | 104 |
88 if [ -z "$path" ] ; then | 105 if [ -z "${instcfg[PREFIX]}" ] ; then |
89 echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: " | 106 echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: " |
90 read -e path | 107 read -e instcfg[PREFIX] |
91 | 108 |
92 [ -z "$path" ] && path="${DEFAULT_PREFIX}" | 109 [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${DEFAULT_PREFIX}" |
93 fi | 110 fi |
94 | 111 |
95 echo "Installing to '$path':" | 112 echo "Installing to '${instcfg[PREFIX]}':" |
96 | 113 |
97 if [ ! -d "$path" ] ; then | 114 if [ ! -d "${instcfg[PREFIX]}" ] ; then |
98 echo "creating installation directory ..." | 115 echo "creating installation directory ..." |
99 install -d "$path" || fatal "Could not create '$path'!" | 116 install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!" |
100 fi | 117 fi |
101 | 118 |
102 echo "unpacking files ..." | 119 echo "unpacking files ..." |
103 cd "$path" | 120 cd "${instcfg[PREFIX]}" |
104 | 121 |
105 # ---------------------------------------------------------------------- | 122 # ---------------------------------------------------------------------- |
106 # regular shar archive appended here: | 123 # regular shar archive inserted here: |
124 ###SHAR### | |
125 # ---------------------------------------------------------------------- | |
126 | |
127 echo "Writing installation configuration to: $instcfg_file ..." | |
128 write_instcfg | |
129 exit 0 |