wilde@680: #!/bin/bash bernhard@1048: # Um TrustBridge zu installieren: emanuel@1189: # 1. Prüfen Sie, ob Sie dieser Datei genügend vertrauen, um ihr die emanuel@1189: # Kontrolle über diesen Rechner zu übergeben. Beispielsweise emanuel@1189: # durch Vergleich mit einer starken Prüfsumme aus einer zweiten, emanuel@1189: # unabhängigen Quelle. emanuel@1189: # 2. Öffnen Sie eine Kommandozeile (Anwendung "Terminal"). emanuel@1189: # 3. Wechseln Sie in das Verzeichnis, in dem diese Datei gespeichert emanuel@1189: # ist (z.B. per Kommandozeile mit: "cd ~/Schreibtisch"). bernhard@1049: # 4. Starten Sie die Anwendung auf der Kommandozeile, beispielsweise emanuel@1189: # als Installation nur für den aktuellen Nutzer, indem Sie emanuel@1189: # eingeben: emanuel@1189: # bash TrustBridge-1.0.0-amd64.sh bernhard@1048: # Tipp: Die Tab-Taste nach dem "Tr" ergänzt oft den ganzen Namen. bernhard@1048: # emanuel@1189: # Übrigens, wir konnten kein übliches .deb-Paket verwenden, da emanuel@1189: # TrustBridge Ihnen auch die Installation als reiner Nutzer ohne emanuel@1189: # Admin-Rechte ermöglichen soll. emanuel@1189: # bernhard@1048: # bernhard@1048: # To install TrustBridge: emanuel@1189: # 1. Verify that you trust this specific file far enough, that you emanuel@1189: # are willing to hand over the control of your computer to it. For emanuel@1189: # example compare a strong checksum of the file to one from a emanuel@1189: # second, independent source. emanuel@1189: # 2. Open a command line (application "Terminal"). bernhard@1048: # 3. Change your working directory to where this file is stored. emanuel@1189: # (e.g. type "cd ~/Desktop" on your command line). emanuel@1189: # 4. Start the installation on the command line, e.g. for the current emanuel@1189: # user only by typing something like: emanuel@1189: # bash TrustBridge-1.0.0-amd64.sh emanuel@1189: # Hint: If you press the tab-key after "Tr" it may complete the emanuel@1189: # filename. bernhard@1048: # emanuel@1189: # By the way: We could not have used a .deb package, because the emanuel@1189: # installation must also work without without adminstrator emanuel@1189: # priviledges. bernhard@1048: # bernhard@1048: # emanuel@1200: # Copyright (C) 2014 emanuel@1200: # by Bundesamt für Sicherheit in der Informationstechnik (BSI). emanuel@1200: # Software engineering by Intevation GmbH. wilde@1165: # wilde@1165: # This file is Free Software under the GNU GPL (v>=2) wilde@1165: # and comes with ABSOLUTELY NO WARRANTY! bernhard@1229: # For details and the license of TrustBridge bernhard@1229: # see the folder "licenses" after installation bernhard@1229: # check the corresponding revision of it online at bernhard@1229: # https://wald.intevation.org/hg/trustbridge/file/tip/licenses wilde@1165: wilde@707: set -u wilde@680: wilde@1139: ###INCLUDE:linux-installer-common.inc wilde@1150: ###INCLUDE:linux-installer.l10n-de wilde@795: wilde@1139: ###INCLUDE:linux-installer-uninstall.inc wilde@680: wilde@698: usage() wilde@698: { wilde@799: getxt "Usage: %s [OPTION]...\n" "$ME" wilde@799: getxt "Install TrustBridge.\n\n" wilde@799: getxt "Options:\n" wilde@799: getxt " -p, --prefix=PATH install files in PATH\n" wilde@799: getxt " -f, --force install to given prefix, even when a current\n" wilde@799: getxt " installation with different prefix exists.\n" andre@1177: getxt " -u, --uninstall uninstall files from current installation\n" wilde@799: getxt " -s, --system create a system wide (de)installation\n" wilde@799: getxt " --help display this help and exit\n" wilde@799: getxt " --version output version information and exit\n" wilde@698: exit $1 wilde@698: } wilde@698: wilde@698: parse_args() wilde@698: { wilde@698: OPTS=`getopt \ andre@1257: -l uninstall,update,force,help,prefix:,system,version \ andre@1273: -o u,f,p:,s -n "$ME" -- "$@"` wilde@698: [ $? -eq 0 ] || usage 23 wilde@698: wilde@698: eval set -- "$OPTS" wilde@698: wilde@698: while true ; do wilde@698: case "$1" in wilde@698: --prefix|-p) wilde@700: instcfg[PREFIX]="$2" wilde@698: shift 2 wilde@698: ;; wilde@707: --system|-s) wilde@707: SYSINST=1 wilde@707: shift 1 wilde@707: ;; wilde@705: --force|-f) wilde@705: FORCE=1 wilde@705: shift 1 wilde@705: ;; andre@1177: --uninstall|-u) wilde@711: DEINSTALL=1 wilde@711: shift 1 wilde@711: ;; andre@1066: --update) andre@1136: # Update is an internal option that is used when the application calls andre@1136: # the installer to install an update. andre@1066: UPDATE=1 andre@1066: shift 1 andre@1066: ;; wilde@698: --help) wilde@698: usage 0 wilde@698: ;; wilde@698: --version) wilde@698: version wilde@698: ;; wilde@698: --) wilde@698: shift wilde@698: break wilde@698: ;; wilde@698: esac wilde@698: done wilde@698: } wilde@698: andre@1066: finished() andre@1066: { andre@1066: echo emanuel@1189: echo "################################################################################" andre@1066: if [ $SYSINST -eq 1 ]; then andre@1066: getxt "System wide installation successful.\n" andre@1193: UN_RUNCMD="sudo " andre@1066: else andre@1066: getxt "Single user installation successful.\n" andre@1193: UN_RUNCMD="" andre@1066: fi andre@1066: getxt "TrustBridge has been installed to: '%s'\n\n" "${instcfg[PREFIX]}" andre@1066: bernhard@1112: getxt "To remove the application and the root certificates it has inserted,\n" andre@1177: getxt "call the uninstall command:\n" andre@1193: echo " $UN_RUNCMD ${instcfg[PREFIX]}/bin/trustbridge-uninstall.sh" bernhard@1075: emanuel@1189: echo "################################################################################" andre@1289: if [ $UPDATE -eq 0 ]; then andre@1289: if ! [ $(id -u) -eq 0 ]; then andre@1289: getxt "Press enter to launch '%s'\n" "${instcfg[PREFIX]}/bin/trustbridge" andre@1289: getxt "or press Control-C to quit the installer.\n" andre@1289: read andre@1289: "${instcfg[PREFIX]}/bin/trustbridge" & andre@1289: else andre@1289: getxt "You can now launch '%s'\n" "${instcfg[PREFIX]}/bin/trustbridge" andre@1289: fi andre@1066: fi andre@1066: } andre@1066: wilde@873: cleanup() wilde@873: { wilde@935: getxt "Cleaning up temporary stuff ...\n" wilde@1132: wilde@1132: # remove temporary directories: wilde@1132: local -a temp_dirs wilde@1139: if [ "${lock_dir:-}" ]; then wilde@1132: # $lock_dir is generate by the shar wilde@1132: temp_dirs+=("${instcfg[PREFIX]}/$lock_dir") andre@937: fi andre@1258: if [ "${TMPEXTRACT_DIR:-}" ]; then andre@1258: temp_dirs+=("$TMPEXTRACT_DIR") andre@1258: fi andre@1258: wilde@1139: if [ "${lock_dir:-}" ]; then wilde@1139: temp_dirs+=("$extra_bin_path") wilde@1139: fi wilde@1133: wilde@1139: for dir in "${temp_dirs[@]-}" ; do wilde@935: [ -d "$dir" ] && wilde@935: rm -rf "$dir" wilde@935: done wilde@707: } wilde@707: wilde@700: write_instcfg() wilde@700: { wilde@700: install -d `dirname "$instcfg_file"` wilde@700: echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file" wilde@700: for key in "${!instcfg[@]}" ; do wilde@700: echo "${key}=${instcfg[$key]}" >>"$instcfg_file" wilde@700: done wilde@700: } wilde@700: andre@777: write_autostart() andre@777: { andre@777: cat > "$1" << EOF andre@777: [Desktop Entry] andre@777: Type=Application andre@777: Name=TrustBridge andre@777: Exec="${instcfg[PREFIX]}/bin/trustbridge" --tray andre@777: EOF andre@777: chown "${SUDO_USER:-${USER}}" "$1" andre@777: chmod 700 "$1" andre@777: } andre@777: andre@872: write_startmenu() andre@872: { andre@872: cat > "$1" << EOF andre@872: [Desktop Entry] andre@872: Type=Application andre@872: Name=TrustBridge andre@872: Comment=Install and update trusted root certificates andre@872: Comment[de]=Vertrauenswürdige Wurzelzertifikate installieren und aktualisieren andre@872: Exec=${instcfg[PREFIX]}/bin/trustbridge andre@872: Icon=${instcfg[PREFIX]}/share/pixmaps/trustbridge/trustbridge.png andre@872: Terminal=false andre@872: Categories=Network;Qt; andre@872: StartupNotify=false andre@872: EOF andre@872: } andre@872: andre@872: setup_startmenu() andre@872: { andre@872: # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE andre@872: # System wide installation with a nonstandard XDG_DATA_HOME is not andre@872: # respected with regards to autostart. andre@872: if [ ! -d "${startmenu_path}" ]; then andre@872: install -d "${startmenu_path}" || \ andre@872: fatal "Failed to create startmenu directory: '%s'\n" "$startmenu_path" andre@872: fi andre@872: andre@872: write_startmenu "${startmenu_path}/trustbridge.desktop" andre@872: update-desktop-database 2>&1 || true andre@872: } andre@872: andre@777: setup_autostart() andre@777: { andre@777: # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE andre@785: # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not andre@785: # respected with regards to autostart. andre@785: if [ ! -d "${autostart_path}" ]; then andre@785: install -d "${autostart_path}" || \ wilde@795: fatal "Failed to create autostart directory: '%s'\n" "$autostart_path" andre@785: fi andre@777: emanuel@854: write_autostart "${autostart_path}/trustbridge.desktop" andre@777: } wilde@707: wilde@873: provide_uudecode_maybe() wilde@873: { wilde@873: # The shar needs uudecode, which might not be installed. If its not wilde@873: # available we will provide our own python based implementation. wilde@873: if which uudecode >/dev/null 2>&1 ; then wilde@873: getxt "Found system uudecode.\n" wilde@873: else wilde@873: local myuudecode="$extra_bin_path/uudecode" wilde@873: cat >"$myuudecode" < 1: wilde@873: f = open(sys.argv[1], 'r') wilde@873: else: wilde@873: f = sys.stdin wilde@873: uu.decode(f, None, None, 1) wilde@873: EOF wilde@873: chmod 755 "$myuudecode" wilde@873: PATH="${extra_bin_path}:$PATH" wilde@873: getxt "Using python uudecode provided by installer.\n" wilde@873: fi wilde@873: } wilde@873: wilde@698: #====================================================================== wilde@698: # main() wilde@935: trap cleanup EXIT wilde@698: wilde@698: parse_args "$@" andre@1040: check_priv wilde@707: init_vars wilde@705: read_oldinstcfg wilde@698: wilde@680: cat <