wilde@680: #!/bin/bash wilde@707: set -u wilde@680: wilde@698: ME=`basename "$0"` wilde@704: DEFAULT_PREFIX="$HOME/TrustBridge" wilde@707: SYSDEFAULT_PREFIX="/usr/local" wilde@700: CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge" wilde@700: SYSCFGPATH="/etc/TrustBridge" wilde@700: INSTCFGNAME="installation.cfg" wilde@705: FORCE=0 wilde@707: SYSINST=0 wilde@698: wilde@705: declare -A instcfg oldinstcfg wilde@707: declare inst_default_prefix instcfg_file wilde@700: instcfg=( wilde@700: [TIMESTMP]=`date -u +%Y%m%d%H%M%S` wilde@700: [VERSION]='@PROJECT_VERSION@' wilde@700: [PREFIX]='' wilde@700: ) wilde@705: oldinstcfg=( wilde@705: [TIMESTMP]='' wilde@705: [VERSION]='' wilde@705: [PREFIX]='' wilde@705: ) wilde@698: wilde@698: version() wilde@698: { wilde@698: cat <=2). See LICENSE.txt for details. wilde@698: There is NO WARRANTY, to the extent permitted by law. wilde@698: EOF wilde@698: exit 0 wilde@698: } wilde@680: wilde@680: fatal() wilde@680: { wilde@680: echo "$1" >&2 wilde@680: echo "Installation failed." >&2 wilde@680: exit 1 wilde@680: } wilde@680: wilde@698: usage() wilde@698: { wilde@698: cat <"$instcfg_file" wilde@700: for key in "${!instcfg[@]}" ; do wilde@700: echo "${key}=${instcfg[$key]}" >>"$instcfg_file" wilde@700: done wilde@700: } wilde@700: wilde@705: read_oldinstcfg() wilde@705: { wilde@705: if [ -r "$instcfg_file" ] ; then wilde@705: echo "Reading '$instcfg_file' ..." wilde@705: for key in "${!oldinstcfg[@]}" ; do wilde@705: oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` wilde@705: done wilde@707: fi wilde@705: } wilde@705: wilde@707: check_priv() wilde@707: { wilde@707: if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then wilde@707: fatal "System wide installation requires root privileges!" wilde@707: fi wilde@707: } wilde@707: wilde@707: wilde@698: #====================================================================== wilde@698: # main() wilde@698: wilde@698: parse_args "$@" wilde@707: init_vars wilde@707: check_priv wilde@705: read_oldinstcfg wilde@698: wilde@680: cat <