Mercurial > trustbridge
annotate packaging/linux-installer.inc.in @ 722:b0929968562a
(Issue31) Add textoverlaybutton to show a text in the button.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 18:35:30 +0200 |
parents | acbe75423283 |
children | e71c59b16eee |
rev | line source |
---|---|
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 #!/bin/bash |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
2 set -u |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
4 ME=`basename "$0"` |
704
480bc550d2ad
Better default prefix for local installation.
Sascha Wilde <wilde@intevation.de>
parents:
700
diff
changeset
|
5 DEFAULT_PREFIX="$HOME/TrustBridge" |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
6 SYSDEFAULT_PREFIX="/usr/local" |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
7 CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
8 SYSCFGPATH="/etc/TrustBridge" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
9 INSTCFGNAME="installation.cfg" |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
10 FORCE=0 |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
11 SYSINST=0 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
12 DEINSTALL=0 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
13 BINNAMES="###BINNAMES###" |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
14 |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
15 declare -A instcfg oldinstcfg |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
16 declare inst_default_prefix instcfg_file |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
17 instcfg=( |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
18 [TIMESTMP]=`date -u +%Y%m%d%H%M%S` |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
19 [VERSION]='@PROJECT_VERSION@' |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
20 [PREFIX]='' |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
21 ) |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
22 oldinstcfg=( |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
23 [TIMESTMP]='' |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
24 [VERSION]='' |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
25 [PREFIX]='' |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
26 ) |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
27 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
28 version() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
29 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
30 cat <<EOF |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
31 TrustBridge ${instcfg[VERSION]} Installer |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
32 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
33 Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
34 Software engineering by Intevation GmbH |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
35 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
36 This is free software. You may redistribute copies of it under the terms of |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
37 the GNU GPL (v>=2). See LICENSE.txt for details. |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
38 There is NO WARRANTY, to the extent permitted by law. |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
39 EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
40 exit 0 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
41 } |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
43 fatal() |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 { |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 echo "$1" >&2 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
46 if [ $DEINSTALL -eq 1 ] ; then |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
47 echo "Deinstallation failed." >&2 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
48 else |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
49 echo "Installation failed." >&2 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
50 fi |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
51 exit 1 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
52 } |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
53 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
54 usage() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
55 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
56 cat <<EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
57 Usage: $ME [OPTION]... |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
58 Install TrustBridge. |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
59 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
60 Options: |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
61 -p, --prefix=PATH install files in PATH |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
62 -f, --force install to given prefix, even when a current |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
63 installation with different prefix exists. |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
64 -d, --deinstall deinstall files from current installation |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
65 -s, --system=PATH make an system wide (de)installation |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
66 --help display this help and exit |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
67 --version output version information and exit |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
68 EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
69 exit $1 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
70 } |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
71 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
72 yorn() |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
73 { |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
74 local c |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
75 while true ; do |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
76 read -n 1 c |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
77 echo |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
78 case "$c" in |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
79 y|Y|j|J) |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
80 return 0 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
81 ;; |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
82 n|N) |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
83 return 1 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
84 ;; |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
85 *) |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
86 echo >&2 "Answer [Y]es or [N]o: " |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
87 esac |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
88 done |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
89 } |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
90 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
91 parse_args() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
92 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
93 OPTS=`getopt \ |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
94 -l deinstall,force,help,prefix:,system,version \ |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
95 -o d,f,p:,s -n "$ME" -- "$@"` |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
96 [ $? -eq 0 ] || usage 23 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
97 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
98 eval set -- "$OPTS" |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
99 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
100 while true ; do |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
101 case "$1" in |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
102 --prefix|-p) |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
103 instcfg[PREFIX]="$2" |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
104 shift 2 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
105 ;; |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
106 --system|-s) |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
107 SYSINST=1 |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
108 shift 1 |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
109 ;; |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
110 --force|-f) |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
111 FORCE=1 |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
112 shift 1 |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
113 ;; |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
114 --deinstall|-d) |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
115 DEINSTALL=1 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
116 shift 1 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
117 ;; |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
118 --help) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
119 usage 0 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
120 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
121 --version) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
122 version |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
123 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
124 --) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
125 shift |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
126 break |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
127 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
128 esac |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
129 done |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
130 } |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
131 |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
132 init_vars() |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
133 { |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
134 if [ $SYSINST -eq 1 ] ; then |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
135 inst_default_prefix="$SYSDEFAULT_PREFIX" |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
136 instcfg_file="${SYSCFGPATH}/${INSTCFGNAME}" |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
137 else |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
138 inst_default_prefix="$DEFAULT_PREFIX" |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
139 instcfg_file="${CFGPATH}/${INSTCFGNAME}" |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
140 fi |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
141 } |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
142 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
143 write_instcfg() |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
144 { |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
145 install -d `dirname "$instcfg_file"` |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
146 echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
147 for key in "${!instcfg[@]}" ; do |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
148 echo "${key}=${instcfg[$key]}" >>"$instcfg_file" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
149 done |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
150 } |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
151 |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
152 read_oldinstcfg() |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
153 { |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
154 if [ -r "$instcfg_file" ] ; then |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
155 echo "Reading '$instcfg_file' ..." |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
156 for key in "${!oldinstcfg[@]}" ; do |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
157 oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
158 done |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
159 fi |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
160 } |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
161 |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
162 check_priv() |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
163 { |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
164 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
165 fatal "System wide installation requires root privileges!" |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
166 fi |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
167 } |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
168 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
169 deinstall() |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
170 { |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
171 if [ "${oldinstcfg[PREFIX]}" ] ; then |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
172 echo "Really deinstall TrustBridge from '${oldinstcfg[PREFIX]}'?" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
173 yorn || exit 0 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
174 local deinstdir="${oldinstcfg[PREFIX]}/bin" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
175 echo "Deinstalling from '${oldinstcfg[PREFIX]}'." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
176 for file in $BINNAMES ; do |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
177 local path="${deinstdir}/$file" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
178 echo "Deleting '$path' ..." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
179 rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
180 done |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
181 while [ "$deinstdir" -a -z "$(ls -A "$deinstdir")" ] ; do |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
182 echo "Deleting empty directory '$deinstdir' ..." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
183 rmdir "$deinstdir" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
184 deinstdir=`dirname "$deinstdir"` |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
185 done |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
186 echo "Removing installation configuration from: $instcfg_file ..." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
187 rm "$instcfg_file" |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
188 echo "Deinstallation finished." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
189 else |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
190 echo "No current installation found! No harm done." |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
191 fi |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
192 } |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
193 |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
194 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
195 #====================================================================== |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
196 # main() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
197 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
198 parse_args "$@" |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
199 init_vars |
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
200 check_priv |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
201 read_oldinstcfg |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
202 |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
203 cat <<EOF |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
204 ------------------------------------------------------------------------ |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
205 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
206 TrustBridge - Installer |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
207 Version ${instcfg[VERSION]} |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
208 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
209 ------------------------------------------------------------------------ |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
210 EOF |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
211 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
212 if [ $DEINSTALL -eq 1 ] ; then |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
213 deinstall |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
214 # Stop after deinstallation: |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
215 exit 0 |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
216 fi |
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
217 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
218 if [ -z "${instcfg[PREFIX]}" ] ; then |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
219 |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
220 if [ "${oldinstcfg[PREFIX]}" ] ; then |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
221 inst_default_prefix="${oldinstcfg[PREFIX]}" |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
222 echo "An existing installation (v${oldinstcfg[VERSION]}) was detected!" |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
223 echo "It is HIGHLY RECOMMENDED to accept the default prefix" |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
224 echo "to update the current installation." |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
225 echo "For a new prefix you should deinstall first!" |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
226 fi |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
227 echo -n "Select installation prefix for TrustBridge [${inst_default_prefix}]: " |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
228 read -e instcfg[PREFIX] |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
229 |
707
37899f717fa5
Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents:
705
diff
changeset
|
230 [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${inst_default_prefix}" |
705
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
231 else |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
232 # Prefix was given on invocation: |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
233 if [ "${oldinstcfg[PREFIX]}" -a \ |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
234 "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \ |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
235 $FORCE -ne 1 ] ; then |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
236 fatal "Prefix differs from current installation (${oldinstcfg[PREFIX]}). Aborting!" |
ff2efc1cb8fa
Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents:
704
diff
changeset
|
237 fi |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
238 fi |
682 | 239 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
240 echo "Installing to '${instcfg[PREFIX]}':" |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
241 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
242 if [ ! -d "${instcfg[PREFIX]}" ] ; then |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
243 echo "creating installation directory ..." |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
244 install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!" |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
245 fi |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
246 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
247 echo "unpacking files ..." |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
248 cd "${instcfg[PREFIX]}" |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
249 |
711
acbe75423283
Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents:
707
diff
changeset
|
250 set +u |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
251 # ---------------------------------------------------------------------- |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
252 # regular shar archive inserted here: |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
253 ###SHAR### |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
254 # ---------------------------------------------------------------------- |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
255 |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
256 echo "Writing installation configuration to: $instcfg_file ..." |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
257 write_instcfg |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
258 exit 0 |