Mercurial > trustbridge
comparison packaging/linux-installer.inc.in @ 795:3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 13:24:26 +0200 |
parents | 2fb539d4b1ff |
children | 933860224d1e |
comparison
equal
deleted
inserted
replaced
794:fdc15f0cfdd8 | 795:3a9b0c75f5a6 |
---|---|
27 [TIMESTMP]='' | 27 [TIMESTMP]='' |
28 [VERSION]='' | 28 [VERSION]='' |
29 [PREFIX]='' | 29 [PREFIX]='' |
30 ) | 30 ) |
31 | 31 |
32 declare -A L10N_DE | |
33 ###L10N_DE### | |
34 | |
35 getxt() | |
36 { | |
37 # Poor mans gettext for l10n completely self contained in one shell | |
38 # script. | |
39 MSGID="$1" | |
40 shift | |
41 case ${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-$LANG}}} in | |
42 de*) | |
43 if [ "${L10N_DE[$MSGID]}" ] ; then | |
44 MSG="${L10N_DE[$MSGID]}" | |
45 else | |
46 MSG="$MSGID" | |
47 fi | |
48 ;; | |
49 *) | |
50 MSG="$MSGID" | |
51 ;; | |
52 esac | |
53 | |
54 printf "$MSG" "$@" | |
55 } | |
56 | |
32 version() | 57 version() |
33 { | 58 { |
34 cat <<EOF | 59 cat <<EOF |
35 TrustBridge ${instcfg[VERSION]} Installer | 60 TrustBridge ${instcfg[VERSION]} Installer |
36 | 61 |
44 exit 0 | 69 exit 0 |
45 } | 70 } |
46 | 71 |
47 fatal() | 72 fatal() |
48 { | 73 { |
49 echo "$1" >&2 | 74 getxt "$1" >&2 |
50 if [ $DEINSTALL -eq 1 ] ; then | 75 if [ $DEINSTALL -eq 1 ] ; then |
51 echo "Deinstallation failed." >&2 | 76 getxt "Deinstallation failed.\n" >&2 |
52 else | 77 else |
53 echo "Installation failed." >&2 | 78 getxt "Installation failed.\n" >&2 |
54 fi | 79 fi |
55 exit 1 | 80 exit 1 |
56 } | 81 } |
57 | 82 |
58 usage() | 83 usage() |
85 ;; | 110 ;; |
86 n|N) | 111 n|N) |
87 return 1 | 112 return 1 |
88 ;; | 113 ;; |
89 *) | 114 *) |
90 echo >&2 "Answer [Y]es or [N]o: " | 115 getxt >&2 "Answer [Y]es or [N]o:\n" |
91 esac | 116 esac |
92 done | 117 done |
93 } | 118 } |
94 | 119 |
95 parse_args() | 120 parse_args() |
159 } | 184 } |
160 | 185 |
161 read_oldinstcfg() | 186 read_oldinstcfg() |
162 { | 187 { |
163 if [ -r "$instcfg_file" ] ; then | 188 if [ -r "$instcfg_file" ] ; then |
164 echo "Reading '$instcfg_file' ..." | 189 getxt "Reading '%s' ...\n" "$instcfg_file" |
165 for key in "${!oldinstcfg[@]}" ; do | 190 for key in "${!oldinstcfg[@]}" ; do |
166 oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` | 191 oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` |
167 done | 192 done |
168 fi | 193 fi |
169 } | 194 } |
170 | 195 |
171 check_priv() | 196 check_priv() |
172 { | 197 { |
173 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then | 198 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then |
174 fatal "System wide installation requires root privileges!" | 199 fatal "System wide installation requires root privileges!\n" |
175 fi | 200 fi |
176 } | 201 } |
177 | 202 |
178 rm_empty_dirs() | 203 rm_empty_dirs() |
179 { | 204 { |
181 # | 206 # |
182 # Recursively remove DIRECTORY and all it _parent_ directories as | 207 # Recursively remove DIRECTORY and all it _parent_ directories as |
183 # long as they are empty. | 208 # long as they are empty. |
184 local directory="$1" | 209 local directory="$1" |
185 while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do | 210 while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do |
186 echo "Deleting empty directory '$directory' ..." | 211 getxt "Deleting empty directory '%s' ...\n" "$directory" |
187 rmdir "$directory" | 212 rmdir "$directory" |
188 directory=`dirname "$directory"` | 213 directory=`dirname "$directory"` |
189 done | 214 done |
190 } | 215 } |
191 | 216 |
192 rm_files() | 217 rm_files() |
193 { | 218 { |
194 for file in "$@" ; do | 219 for file in "$@" ; do |
195 if [ -e "$file" ] ; then | 220 if [ -e "$file" ] ; then |
196 echo "Deleting $file ..." | 221 getxt "Deleting '%s' ...\n" "$file" |
197 rm "$file" | 222 rm "$file" |
198 fi | 223 fi |
199 done | 224 done |
200 } | 225 } |
201 | 226 |
234 deinstall_certs() | 259 deinstall_certs() |
235 { | 260 { |
236 local cinst="${oldinstcfg[PREFIX]}/bin/cinst" | 261 local cinst="${oldinstcfg[PREFIX]}/bin/cinst" |
237 local certlist=`ls 2>/dev/null -1 ${instdata_path}/list-*.txt | sort -nr | head -n 1` | 262 local certlist=`ls 2>/dev/null -1 ${instdata_path}/list-*.txt | sort -nr | head -n 1` |
238 | 263 |
239 echo "Uninstalling certificates ..." | 264 getxt "Uninstalling certificates ...\n" |
240 | 265 |
241 if [ "$certlist" ] ; then | 266 if [ "$certlist" ] ; then |
242 echo "Using certificate list '$certlist'." | 267 getxt "Using certificate list '%s'.\n" "$certlist" |
243 if [ -x "$cinst" ] ; then | 268 if [ -x "$cinst" ] ; then |
244 "$cinst" "list=$certlist" "choices=uninstall" | 269 "$cinst" "list=$certlist" "choices=uninstall" |
245 else | 270 else |
246 echo >&2 "WARNING: can't execute $cinst for certificate deinstallation." | 271 getxt >&2 "WARNING: can't execute %s for certificate deinstallation.\n" "$cinst" |
247 fi | 272 fi |
248 else | 273 else |
249 echo "No certificate list found. Nothing to do." | 274 getxt "No certificate list found. Nothing to do.\n" |
250 fi | 275 fi |
251 } | 276 } |
252 | 277 |
253 deinstall_etc() | 278 deinstall_etc() |
254 { | 279 { |
255 echo "Removing cron job ..." | 280 getxt "Removing cron job ...\n" |
256 remove_cronjob | 281 remove_cronjob |
257 | 282 |
258 # FIXME: delete all files created by the application. | 283 # FIXME: delete all files created by the application. |
259 local tbcfg_files=( "${instcfg_path}/TrustBridge.ini" | 284 local tbcfg_files=( "${instcfg_path}/TrustBridge.ini" |
260 "${instcfg_path}/trustbridge-tray-starter.cfg" | 285 "${instcfg_path}/trustbridge-tray-starter.cfg" |
261 "$instcfg_file" ) | 286 "$instcfg_file" ) |
262 | 287 |
263 echo "Removing certificate lists from: ${instdata_path}:" | 288 getxt "Removing certificate lists from: %s:\n" "$instdata_path" |
264 rm_files "$instdata_path"/list-*.txt | 289 rm_files "$instdata_path"/list-*.txt |
290 | |
291 getxt "Removing PID file from: %s:\n" "$instdata_path" | |
292 rm_files "$instdata_path"/*.pid | |
265 rm_empty_dirs "$instdata_path" | 293 rm_empty_dirs "$instdata_path" |
266 | 294 |
267 echo "Removing configuration files:" | 295 getxt "Removing configuration files:\n" |
268 rm_files "${tbcfg_files[@]}" | 296 rm_files "${tbcfg_files[@]}" |
269 rm_empty_dirs "$instcfg_path" | 297 rm_empty_dirs "$instcfg_path" |
270 | 298 |
271 echo "Removing TrustBridge from autostart" | 299 getxt "Removing TrustBridge from autostart\n" |
272 rm_files "${autostart_path}/tustbridge.desktop" | 300 rm_files "${autostart_path}/tustbridge.desktop" |
273 } | 301 } |
274 | 302 |
275 deinstall() | 303 deinstall() |
276 { | 304 { |
277 if [ "${oldinstcfg[PREFIX]}" ] ; then | 305 if [ "${oldinstcfg[PREFIX]}" ] ; then |
278 echo "Really deinstall TrustBridge from '${oldinstcfg[PREFIX]}'? [y/n]" | 306 getxt "Really deinstall TrustBridge from '%s'? [y/n]\n" "${oldinstcfg[PREFIX]}" |
279 yorn || exit 0 | 307 yorn || exit 0 |
280 deinstall_certs | 308 deinstall_certs |
281 local deinstdir="${oldinstcfg[PREFIX]}/bin" | 309 local deinstdir="${oldinstcfg[PREFIX]}/bin" |
282 echo "Deinstalling from '${oldinstcfg[PREFIX]}'." | 310 getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}" |
283 for file in $BINNAMES ; do | 311 for file in $BINNAMES ; do |
284 local path="${deinstdir}/$file" | 312 local path="${deinstdir}/$file" |
285 echo "Deleting '$path' ..." | 313 getxt "Deleting '%s' ...\n" "$path" |
286 rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!" | 314 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" |
287 done | 315 done |
288 rm_empty_dirs "$deinstdir" | 316 rm_empty_dirs "$deinstdir" |
289 deinstall_etc | 317 deinstall_etc |
290 echo "Deinstallation finished." | 318 getxt "Deinstallation finished.\n" |
291 else | 319 else |
292 echo "No current installation found! No harm done." | 320 getxt "No current installation found! No harm done.\n" |
293 fi | 321 fi |
294 } | 322 } |
295 | 323 |
296 write_autostart() | 324 write_autostart() |
297 { | 325 { |
310 # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE | 338 # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE |
311 # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not | 339 # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not |
312 # respected with regards to autostart. | 340 # respected with regards to autostart. |
313 if [ ! -d "${autostart_path}" ]; then | 341 if [ ! -d "${autostart_path}" ]; then |
314 install -d "${autostart_path}" || \ | 342 install -d "${autostart_path}" || \ |
315 fatal "Failed to create autostart directory: '${autostart_path}'" | 343 fatal "Failed to create autostart directory: '%s'\n" "$autostart_path" |
316 fi | 344 fi |
317 | 345 |
318 write_autostart "${autostart_path}/tustbridge.desktop" | 346 write_autostart "${autostart_path}/tustbridge.desktop" |
319 } | 347 } |
320 | 348 |
343 | 371 |
344 if [ -z "${instcfg[PREFIX]}" ] ; then | 372 if [ -z "${instcfg[PREFIX]}" ] ; then |
345 | 373 |
346 if [ "${oldinstcfg[PREFIX]}" ] ; then | 374 if [ "${oldinstcfg[PREFIX]}" ] ; then |
347 inst_default_prefix="${oldinstcfg[PREFIX]}" | 375 inst_default_prefix="${oldinstcfg[PREFIX]}" |
348 echo "An existing installation (v${oldinstcfg[VERSION]}) was detected!" | 376 getxt "An existing installation (v%s) was detected!\n" "${oldinstcfg[VERSION]}" |
349 echo "It is HIGHLY RECOMMENDED to accept the default prefix" | 377 getxt "It is HIGHLY RECOMMENDED to accept the default prefix\n" |
350 echo "to update the current installation." | 378 getxt "to update the current installation.\n" |
351 echo "For a new prefix you should deinstall first!" | 379 getxt "For a new prefix you should deinstall first!\n" |
352 fi | 380 fi |
353 echo -n "Select installation prefix for TrustBridge [${inst_default_prefix}]: " | 381 getxt "Select installation prefix for TrustBridge [%s]: " "${inst_default_prefix}" |
354 read -e instcfg[PREFIX] | 382 read -e instcfg[PREFIX] |
355 | 383 |
356 [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${inst_default_prefix}" | 384 [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${inst_default_prefix}" |
357 else | 385 else |
358 # Prefix was given on invocation: | 386 # Prefix was given on invocation: |
359 if [ "${oldinstcfg[PREFIX]}" -a \ | 387 if [ "${oldinstcfg[PREFIX]}" -a \ |
360 "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \ | 388 "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \ |
361 $FORCE -ne 1 ] ; then | 389 $FORCE -ne 1 ] ; then |
362 fatal "Prefix differs from current installation (${oldinstcfg[PREFIX]}). Aborting!" | 390 fatal "Prefix differs from current installation (%s). Aborting!\n" "${oldinstcfg[PREFIX]}" |
363 fi | 391 fi |
364 fi | 392 fi |
365 | 393 |
366 echo "Installing to '${instcfg[PREFIX]}':" | 394 getxt "Installing to '%s':\n" "${instcfg[PREFIX]}" |
367 | 395 |
368 if [ ! -d "${instcfg[PREFIX]}" ] ; then | 396 if [ ! -d "${instcfg[PREFIX]}" ] ; then |
369 echo "creating installation directory ..." | 397 getxt "creating installation directory ...\n" |
370 install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!" | 398 install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}" |
371 fi | 399 fi |
372 | 400 |
373 echo "unpacking files ..." | 401 getxt "unpacking files ...\n" |
374 cd "${instcfg[PREFIX]}" | 402 cd "${instcfg[PREFIX]}" |
375 | 403 |
376 set +u | 404 set +u |
377 set -- '-c' | 405 set -- '-c' |
378 # ---------------------------------------------------------------------- | 406 # ---------------------------------------------------------------------- |
379 # regular shar archive inserted here: | 407 # regular shar archive inserted here: |
380 ###SHAR### | 408 ###SHAR### |
381 # ---------------------------------------------------------------------- | 409 # ---------------------------------------------------------------------- |
382 | 410 |
383 echo "Preparing trustbridge-tray-starter ..." | 411 getxt "Preparing trustbridge-tray-starter ...\n" |
384 sed -i "/^PREFIX=/c\PREFIX='${instcfg[PREFIX]}'" \ | 412 sed -i "/^PREFIX=/c\PREFIX='${instcfg[PREFIX]}'" \ |
385 "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh" | 413 "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh" |
386 | 414 |
387 echo "Setting up cronjob ..." | 415 getxt "Setting up cronjob ...\n" |
388 setup_cronjob | 416 setup_cronjob |
389 | 417 |
390 echo "Setting up autostart ..." | 418 getxt "Setting up autostart ...\n" |
391 setup_autostart | 419 setup_autostart |
392 | 420 |
393 echo "Writing installation configuration to: $instcfg_file ..." | 421 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file" |
394 write_instcfg | 422 write_instcfg |
395 exit 0 | 423 exit 0 |