annotate packaging/linux-installer.inc.in @ 863:3f23130b16b2

(Packaging) Added "Testversion" to Ubuntu installer.
author Emanuel Schuetze <emanuel@intevation.de>
date Tue, 05 Aug 2014 12:24:08 +0200
parents 4dfb6f543a05
children 02e357826417
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"
724
d280e2d39d5a Introduced data-directory and fixed config-directory.
Sascha Wilde <wilde@intevation.de>
parents: 723
diff changeset
7 CFGPATH="${XDG_CONFIG_HOME:-$HOME/.config}/BSI"
d280e2d39d5a Introduced data-directory and fixed config-directory.
Sascha Wilde <wilde@intevation.de>
parents: 723
diff changeset
8 DATAPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge"
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
9 SYSCFGPATH="/etc/TrustBridge"
727
feaabee15e72 Preliminary implemented SYSDATAPATH.
Sascha Wilde <wilde@intevation.de>
parents: 725
diff changeset
10 # FIXME:
feaabee15e72 Preliminary implemented SYSDATAPATH.
Sascha Wilde <wilde@intevation.de>
parents: 725
diff changeset
11 # Set the real data path for system wide installation once its known.
feaabee15e72 Preliminary implemented SYSDATAPATH.
Sascha Wilde <wilde@intevation.de>
parents: 725
diff changeset
12 SYSDATAPATH="$DATAPATH"
724
d280e2d39d5a Introduced data-directory and fixed config-directory.
Sascha Wilde <wilde@intevation.de>
parents: 723
diff changeset
13 INSTCFGNAME="TrustBridge-inst.cfg"
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
14 FORCE=0
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
15 SYSINST=0
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
16 DEINSTALL=0
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
17 BINNAMES="###BINNAMES###"
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
18
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
19 declare -A instcfg oldinstcfg
724
d280e2d39d5a Introduced data-directory and fixed config-directory.
Sascha Wilde <wilde@intevation.de>
parents: 723
diff changeset
20 declare inst_default_prefix instdata_path instcfg_path instcfg_file
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
21 instcfg=(
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
22 [TIMESTMP]=`date -u +%Y%m%d%H%M%S`
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
23 [VERSION]='@PROJECT_VERSION@'
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
24 [PREFIX]=''
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
25 )
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
26 oldinstcfg=(
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
27 [TIMESTMP]=''
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
28 [VERSION]=''
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
29 [PREFIX]=''
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
30 )
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
31
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
32 declare -A L10N_DE
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
33 ###L10N_DE###
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
34
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
35 getxt()
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
36 {
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
37 # Poor mans gettext for l10n completely self contained in one shell
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
38 # script.
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
39 MSGID="$1"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
40 shift
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
41 case ${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-$LANG}}} in
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
42 de*)
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
43 if [ "${L10N_DE[$MSGID]}" ] ; then
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
44 MSG="${L10N_DE[$MSGID]}"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
45 else
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
46 MSG="$MSGID"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
47 fi
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
48 ;;
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
49 *)
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
50 MSG="$MSGID"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
51 ;;
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
52 esac
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
53
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
54 printf "$MSG" "$@"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
55 }
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
56
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
57 version()
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
58 {
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
59 cat <<EOF
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
60 TrustBridge ${instcfg[VERSION]} Installer
698
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 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
63 Software engineering by Intevation GmbH
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
64
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
65 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
66 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
67 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
68 EOF
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
69 exit 0
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
70 }
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
71
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
72 fatal()
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
73 {
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
74 getxt "$1" >&2
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
75 if [ $DEINSTALL -eq 1 ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
76 getxt "Deinstallation failed.\n" >&2
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
77 else
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
78 getxt "Installation failed.\n" >&2
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
79 fi
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
80 exit 1
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
81 }
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
82
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
83 usage()
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
84 {
799
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
85 getxt "Usage: %s [OPTION]...\n" "$ME"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
86 getxt "Install TrustBridge.\n\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
87 getxt "Options:\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
88 getxt " -p, --prefix=PATH install files in PATH\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
89 getxt " -f, --force install to given prefix, even when a current\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
90 getxt " installation with different prefix exists.\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
91 getxt " -d, --deinstall deinstall files from current installation\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
92 getxt " -s, --system create a system wide (de)installation\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
93 getxt " --help display this help and exit\n"
933860224d1e l10n for usage text.
Sascha Wilde <wilde@intevation.de>
parents: 795
diff changeset
94 getxt " --version output version information and exit\n"
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
95 exit $1
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
96 }
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
97
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
98 yorn()
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
99 {
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
100 local c
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
101 while true ; do
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
102 read -n 1 c
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
103 echo
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
104 case "$c" in
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
105 y|Y|j|J)
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
106 return 0
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
107 ;;
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
108 n|N)
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
109 return 1
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
110 ;;
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
111 *)
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
112 getxt >&2 "Answer [Y]es or [N]o:\n"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
113 esac
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
114 done
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
115 }
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
116
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
117 parse_args()
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
118 {
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
119 OPTS=`getopt \
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
120 -l deinstall,force,help,prefix:,system,version \
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
121 -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
122 [ $? -eq 0 ] || usage 23
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 eval set -- "$OPTS"
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
125
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
126 while true ; do
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
127 case "$1" in
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
128 --prefix|-p)
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
129 instcfg[PREFIX]="$2"
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
130 shift 2
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 --system|-s)
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
133 SYSINST=1
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
134 shift 1
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
135 ;;
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
136 --force|-f)
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
137 FORCE=1
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
138 shift 1
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
139 ;;
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
140 --deinstall|-d)
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
141 DEINSTALL=1
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
142 shift 1
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
143 ;;
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
144 --help)
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
145 usage 0
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
146 ;;
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
147 --version)
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
148 version
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
149 ;;
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
150 --)
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
151 shift
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
152 break
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
153 ;;
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
154 esac
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
155 done
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
156 }
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
157
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
158 init_vars()
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
159 {
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
160 if [ $SYSINST -eq 1 ] ; then
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
161 inst_default_prefix="$SYSDEFAULT_PREFIX"
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
162 instcfg_path="${SYSCFGPATH}"
727
feaabee15e72 Preliminary implemented SYSDATAPATH.
Sascha Wilde <wilde@intevation.de>
parents: 725
diff changeset
163 instdata_path="${SYSDATAPATH}"
785
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
164 autostart_path="$(getent passwd "${SUDO_USER}" | cut -d ':' -f 6)/.config/autostart"
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
165 else
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
166 inst_default_prefix="$DEFAULT_PREFIX"
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
167 instcfg_path="${CFGPATH}"
724
d280e2d39d5a Introduced data-directory and fixed config-directory.
Sascha Wilde <wilde@intevation.de>
parents: 723
diff changeset
168 instdata_path="${DATAPATH}"
785
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
169 autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart}
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
170 fi
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
171 instcfg_file="${instcfg_path}/${INSTCFGNAME}"
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
172 }
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
173
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
174 write_instcfg()
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
175 {
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
176 install -d `dirname "$instcfg_file"`
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
177 echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file"
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
178 for key in "${!instcfg[@]}" ; do
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
179 echo "${key}=${instcfg[$key]}" >>"$instcfg_file"
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
180 done
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
181 }
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
182
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
183 read_oldinstcfg()
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
184 {
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
185 if [ -r "$instcfg_file" ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
186 getxt "Reading '%s' ...\n" "$instcfg_file"
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
187 for key in "${!oldinstcfg[@]}" ; do
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
188 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
189 done
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
190 fi
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
191 }
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
192
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
193 check_priv()
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
194 {
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
195 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
196 fatal "System wide installation requires root privileges!\n"
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
197 fi
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
198 }
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
199
728
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
200 rm_empty_dirs()
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
201 {
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
202 # Args: $1 - DIRECTORY
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
203 #
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
204 # Recursively remove DIRECTORY and all it _parent_ directories as
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
205 # long as they are empty.
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
206 local directory="$1"
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
207 while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
208 getxt "Deleting empty directory '%s' ...\n" "$directory"
728
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
209 rmdir "$directory"
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
210 directory=`dirname "$directory"`
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
211 done
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
212 }
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
213
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
214 rm_files()
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
215 {
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
216 for file in "$@" ; do
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
217 if [ -e "$file" ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
218 getxt "Deleting '%s' ...\n" "$file"
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
219 rm "$file"
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
220 fi
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
221 done
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
222 }
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
223
749
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
224 setup_cronjob()
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
225 {
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
226 local tmpcrontab=`mktemp`
765
7c3a8a8d3e52 Code cleanup: make variable initialization more obvious.
Sascha Wilde <wilde@intevation.de>
parents: 764
diff changeset
227
764
5b505acbb2d1 Handle system wide installation for crontab.
Sascha Wilde <wilde@intevation.de>
parents: 763
diff changeset
228 if [ $SYSINST -eq 1 -a "${SUDO_USER+X}" ] ; then
765
7c3a8a8d3e52 Code cleanup: make variable initialization more obvious.
Sascha Wilde <wilde@intevation.de>
parents: 764
diff changeset
229 local crontabopt="-u $SUDO_USER"
7c3a8a8d3e52 Code cleanup: make variable initialization more obvious.
Sascha Wilde <wilde@intevation.de>
parents: 764
diff changeset
230 else
7c3a8a8d3e52 Code cleanup: make variable initialization more obvious.
Sascha Wilde <wilde@intevation.de>
parents: 764
diff changeset
231 local crontabopt=''
764
5b505acbb2d1 Handle system wide installation for crontab.
Sascha Wilde <wilde@intevation.de>
parents: 763
diff changeset
232 fi
765
7c3a8a8d3e52 Code cleanup: make variable initialization more obvious.
Sascha Wilde <wilde@intevation.de>
parents: 764
diff changeset
233
766
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
234 if [ "$1" != "deinstall" ] ; then
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
235 local trustbridge_tray_starter="${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh"
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
236 else
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
237 local trustbridge_tray_starter="${oldinstcfg[PREFIX]}/bin/trustbridge-tray-starter.sh"
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
238 fi
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
239
764
5b505acbb2d1 Handle system wide installation for crontab.
Sascha Wilde <wilde@intevation.de>
parents: 763
diff changeset
240 crontab $crontabopt -l | \
766
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
241 grep -vF "$trustbridge_tray_starter" \
764
5b505acbb2d1 Handle system wide installation for crontab.
Sascha Wilde <wilde@intevation.de>
parents: 763
diff changeset
242 >"$tmpcrontab"
750
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
243 if [ "$1" != "deinstall" ] ; then
766
9f0ad4bab175 Fixed crontab setup for system wide (de)installation.
Sascha Wilde <wilde@intevation.de>
parents: 765
diff changeset
244 echo "$(( $RANDOM / 555 )) 12 * * * \"$trustbridge_tray_starter\"" \
750
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
245 >>"$tmpcrontab"
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
246 fi
764
5b505acbb2d1 Handle system wide installation for crontab.
Sascha Wilde <wilde@intevation.de>
parents: 763
diff changeset
247 crontab $crontabopt "$tmpcrontab"
749
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
248 rm "$tmpcrontab"
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
249 }
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
250
750
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
251 remove_cronjob()
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
252 {
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
253 setup_cronjob deinstall
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
254 }
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
255
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
256 deinstall_certs()
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
257 {
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
258 local cinst="${oldinstcfg[PREFIX]}/bin/cinst"
858
4dfb6f543a05 Only uninstall a list if it has been installed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 854
diff changeset
259 local certlist=`ls 2>/dev/null -1 ${instdata_path}/list-installed.txt`
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
260
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
261 getxt "Uninstalling certificates ...\n"
728
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
262
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
263 if [ "$certlist" ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
264 getxt "Using certificate list '%s'.\n" "$certlist"
725
ce3e33e66a17 Fixed cert deinstallation for prefix-paths containing space.
Sascha Wilde <wilde@intevation.de>
parents: 724
diff changeset
265 if [ -x "$cinst" ] ; then
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
266 "$cinst" "list=$certlist" "choices=uninstall"
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
267 else
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
268 getxt >&2 "WARNING: can't execute %s for certificate deinstallation.\n" "$cinst"
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
269 fi
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
270 else
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
271 getxt "No certificate list found. Nothing to do.\n"
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
272 fi
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
273 }
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
274
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
275 deinstall_etc()
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
276 {
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
277 getxt "Removing cron job ...\n"
750
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
278 remove_cronjob
27dd0012288a Remove cron job on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 749
diff changeset
279
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
280 # FIXME: delete all files created by the application.
751
d8c8e14b9953 Remove trustbridge-tray-starter configuration on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 750
diff changeset
281 local tbcfg_files=( "${instcfg_path}/TrustBridge.ini"
d8c8e14b9953 Remove trustbridge-tray-starter configuration on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 750
diff changeset
282 "${instcfg_path}/trustbridge-tray-starter.cfg"
d8c8e14b9953 Remove trustbridge-tray-starter configuration on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 750
diff changeset
283 "$instcfg_file" )
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
284
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
285 getxt "Removing certificate lists from: %s:\n" "$instdata_path"
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
286 rm_files "$instdata_path"/list-*.txt
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
287
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
288 getxt "Removing PID file from: %s:\n" "$instdata_path"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
289 rm_files "$instdata_path"/*.pid
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
290 rm_empty_dirs "$instdata_path"
751
d8c8e14b9953 Remove trustbridge-tray-starter configuration on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 750
diff changeset
291
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
292 getxt "Removing configuration files:\n"
752
96cac71834ba Fixed errors when not all expected files exist on deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 751
diff changeset
293 rm_files "${tbcfg_files[@]}"
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
294 rm_empty_dirs "$instcfg_path"
777
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
295
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
296 getxt "Removing TrustBridge from autostart\n"
854
adf7481291a4 Fixed typo in ubuntu desktop file.
Emanuel Schuetze <emanuel@intevation.de>
parents: 799
diff changeset
297 rm_files "${autostart_path}/trustbridge.desktop"
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
298 }
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
299
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
300 deinstall()
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
301 {
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
302 if [ "${oldinstcfg[PREFIX]}" ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
303 getxt "Really deinstall TrustBridge from '%s'? [y/n]\n" "${oldinstcfg[PREFIX]}"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
304 yorn || exit 0
723
e71c59b16eee Added certificate deinstallation.
Sascha Wilde <wilde@intevation.de>
parents: 711
diff changeset
305 deinstall_certs
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
306 local deinstdir="${oldinstcfg[PREFIX]}/bin"
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
307 getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
308 for file in $BINNAMES ; do
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
309 local path="${deinstdir}/$file"
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
310 getxt "Deleting '%s' ...\n" "$path"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
311 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
312 done
728
2d64ff7e22e8 Factored out recursive deletion of empty dirs.
Sascha Wilde <wilde@intevation.de>
parents: 727
diff changeset
313 rm_empty_dirs "$deinstdir"
729
efc2d16ab514 Remove (more) data files and directories.
Sascha Wilde <wilde@intevation.de>
parents: 728
diff changeset
314 deinstall_etc
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
315 getxt "Deinstallation finished.\n"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
316 else
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
317 getxt "No current installation found! No harm done.\n"
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
318 fi
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
319 }
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
320
777
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
321 write_autostart()
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
322 {
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
323 cat > "$1" << EOF
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
324 [Desktop Entry]
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
325 Type=Application
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
326 Name=TrustBridge
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
327 Exec="${instcfg[PREFIX]}/bin/trustbridge" --tray
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
328 EOF
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
329 chown "${SUDO_USER:-${USER}}" "$1"
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
330 chmod 700 "$1"
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
331 }
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
332
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
333 setup_autostart()
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
334 {
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
335 # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE
785
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
336 # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
337 # respected with regards to autostart.
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
338 if [ ! -d "${autostart_path}" ]; then
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
339 install -d "${autostart_path}" || \
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
340 fatal "Failed to create autostart directory: '%s'\n" "$autostart_path"
785
2fb539d4b1ff Simply autostart creation by initializing the path in init_vars
Andre Heinecke <andre.heinecke@intevation.de>
parents: 777
diff changeset
341 fi
777
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
342
854
adf7481291a4 Fixed typo in ubuntu desktop file.
Emanuel Schuetze <emanuel@intevation.de>
parents: 799
diff changeset
343 write_autostart "${autostart_path}/trustbridge.desktop"
777
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
344 }
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
345
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
346 #======================================================================
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
347 # main()
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
348
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
349 parse_args "$@"
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
350 init_vars
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
351 check_priv
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
352 read_oldinstcfg
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
353
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
354 cat <<EOF
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
355 ------------------------------------------------------------------------
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
356
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
357 TrustBridge - Installer
863
3f23130b16b2 (Packaging) Added "Testversion" to Ubuntu installer.
Emanuel Schuetze <emanuel@intevation.de>
parents: 858
diff changeset
358 Version ${instcfg[VERSION]} (Testversion)
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
359
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
360 ------------------------------------------------------------------------
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
361 EOF
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
362
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
363 if [ $DEINSTALL -eq 1 ] ; then
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
364 deinstall
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
365 # Stop after deinstallation:
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
366 exit 0
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
367 fi
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
368
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
369 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
370
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
371 if [ "${oldinstcfg[PREFIX]}" ] ; then
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
372 inst_default_prefix="${oldinstcfg[PREFIX]}"
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
373 getxt "An existing installation (v%s) was detected!\n" "${oldinstcfg[VERSION]}"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
374 getxt "It is HIGHLY RECOMMENDED to accept the default prefix\n"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
375 getxt "to update the current installation.\n"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
376 getxt "For a new prefix you should deinstall first!\n"
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
377 fi
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
378 getxt "Select installation prefix for TrustBridge [%s]: " "${inst_default_prefix}"
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
379 read -e instcfg[PREFIX]
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
380
707
37899f717fa5 Added system wide installation.
Sascha Wilde <wilde@intevation.de>
parents: 705
diff changeset
381 [ -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
382 else
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
383 # Prefix was given on invocation:
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
384 if [ "${oldinstcfg[PREFIX]}" -a \
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
385 "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
386 $FORCE -ne 1 ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
387 fatal "Prefix differs from current installation (%s). Aborting!\n" "${oldinstcfg[PREFIX]}"
705
ff2efc1cb8fa Use config from old installation for sensible default prefix.
Sascha Wilde <wilde@intevation.de>
parents: 704
diff changeset
388 fi
698
b55d49150e36 Added command line args for unattended installation.
Sascha Wilde <wilde@intevation.de>
parents: 682
diff changeset
389 fi
682
578860edde53 Use default path.
Sascha Wilde <wilde@intevation.de>
parents: 680
diff changeset
390
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
391 getxt "Installing to '%s':\n" "${instcfg[PREFIX]}"
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
392
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
393 if [ ! -d "${instcfg[PREFIX]}" ] ; then
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
394 getxt "creating installation directory ...\n"
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
395 install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}"
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
396 fi
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
397
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
398 getxt "unpacking files ...\n"
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
399 cd "${instcfg[PREFIX]}"
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
400
711
acbe75423283 Added deinstallation functionality.
Sascha Wilde <wilde@intevation.de>
parents: 707
diff changeset
401 set +u
753
7c1f34115ede Force the shar to overwrite existing files.
Sascha Wilde <wilde@intevation.de>
parents: 752
diff changeset
402 set -- '-c'
680
a5a709c6ce93 Added minimal shar based installer for linux.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
403 # ----------------------------------------------------------------------
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
404 # regular shar archive inserted here:
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
405 ###SHAR###
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
406 # ----------------------------------------------------------------------
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
407
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
408 getxt "Preparing trustbridge-tray-starter ...\n"
738
ea8d13590cbd Added trustbridge-tray-starter script for use with cron job.
Sascha Wilde <wilde@intevation.de>
parents: 730
diff changeset
409 sed -i "/^PREFIX=/c\PREFIX='${instcfg[PREFIX]}'" \
ea8d13590cbd Added trustbridge-tray-starter script for use with cron job.
Sascha Wilde <wilde@intevation.de>
parents: 730
diff changeset
410 "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh"
ea8d13590cbd Added trustbridge-tray-starter script for use with cron job.
Sascha Wilde <wilde@intevation.de>
parents: 730
diff changeset
411
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
412 getxt "Setting up cronjob ...\n"
749
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
413 setup_cronjob
778382342802 Added installation of cron job.
Sascha Wilde <wilde@intevation.de>
parents: 738
diff changeset
414
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
415 getxt "Setting up autostart ...\n"
777
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
416 setup_autostart
ca149bad8195 (issue51) Set up autostart on installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 776
diff changeset
417
795
3a9b0c75f5a6 Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents: 785
diff changeset
418 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file"
700
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
419 write_instcfg
bf87feccb26c Write installation configuration file.
Sascha Wilde <wilde@intevation.de>
parents: 698
diff changeset
420 exit 0

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