Mercurial > trustbridge
annotate 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 |
rev | line source |
---|---|
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 #!/bin/bash |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
3 ME=`basename "$0"` |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
4 DEFAULT_PREFIX=/usr/local |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
5 CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
6 SYSCFGPATH="/etc/TrustBridge" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
7 INSTCFGNAME="installation.cfg" |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
8 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
9 instcfg_file="${CFGPATH}/${INSTCFGNAME}" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
10 declare -A instcfg |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
11 instcfg=( |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
12 [TIMESTMP]=`date -u +%Y%m%d%H%M%S` |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
13 [VERSION]='@PROJECT_VERSION@' |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
14 [PREFIX]='' |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
15 ) |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
16 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
17 version() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
18 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
19 cat <<EOF |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
20 TrustBridge ${instcfg[VERSION]} Installer |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
21 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
22 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
|
23 Software engineering by Intevation GmbH |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
24 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
25 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
|
26 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
|
27 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
|
28 EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
29 exit 0 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
30 } |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
31 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 fatal() |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
33 { |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
34 echo "$1" >&2 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
35 echo "Installation failed." >&2 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
36 exit 1 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
37 } |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
39 usage() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
40 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
41 cat <<EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
42 Usage: $ME [OPTION]... |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
43 Install TrustBridge. |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
44 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
45 Options: |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
46 -p, --prefix=PATH install files in PATH |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
47 --help display this help and exit |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
48 --version output version information and exit |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
49 EOF |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
50 exit $1 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
51 } |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
52 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
53 parse_args() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
54 { |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
55 OPTS=`getopt \ |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
56 -l help,prefix:,version \ |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
57 -o p: -n "$ME" -- "$@"` |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
58 [ $? -eq 0 ] || usage 23 |
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 eval set -- "$OPTS" |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
61 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
62 while true ; do |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
63 case "$1" in |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
64 --prefix|-p) |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
65 instcfg[PREFIX]="$2" |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
66 shift 2 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
67 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
68 --help) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
69 usage 0 |
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 --version) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
72 version |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
73 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
74 --) |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
75 shift |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
76 break |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
77 ;; |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
78 esac |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
79 done |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
80 } |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
81 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
82 write_instcfg() |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
83 { |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
84 install -d `dirname "$instcfg_file"` |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
85 echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
86 for key in "${!instcfg[@]}" ; do |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
87 echo "${key}=${instcfg[$key]}" >>"$instcfg_file" |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
88 done |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
89 } |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
90 |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
91 #====================================================================== |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
92 # main() |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
93 |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
94 parse_args "$@" |
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
95 |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
96 cat <<EOF |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
97 ------------------------------------------------------------------------ |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
98 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
99 TrustBridge - Installer |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
100 Version ${instcfg[VERSION]} |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
101 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
102 ------------------------------------------------------------------------ |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
103 EOF |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
104 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
105 if [ -z "${instcfg[PREFIX]}" ] ; then |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
106 echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: " |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
107 read -e instcfg[PREFIX] |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
108 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
109 [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${DEFAULT_PREFIX}" |
698
b55d49150e36
Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents:
682
diff
changeset
|
110 fi |
682 | 111 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
112 echo "Installing to '${instcfg[PREFIX]}':" |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
113 |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
114 if [ ! -d "${instcfg[PREFIX]}" ] ; then |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
115 echo "creating installation directory ..." |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
116 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
|
117 fi |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
118 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
119 echo "unpacking files ..." |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
120 cd "${instcfg[PREFIX]}" |
680
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
121 |
a5a709c6ce93
Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
122 # ---------------------------------------------------------------------- |
700
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
123 # regular shar archive inserted here: |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
124 ###SHAR### |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
125 # ---------------------------------------------------------------------- |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
126 |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
127 echo "Writing installation configuration to: $instcfg_file ..." |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
128 write_instcfg |
bf87feccb26c
Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents:
698
diff
changeset
|
129 exit 0 |