|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# This script downloads and installs Web eID in .deb based Linux distributions. |
| 4 | +# License: public domain. |
| 5 | +# Based on https://github.com/open-eid/linux-installer/blob/master/install-open-eid.sh |
| 6 | + |
| 7 | +set -eu |
| 8 | + |
| 9 | +test_sudo() { |
| 10 | + if ! command -v sudo>/dev/null; then |
| 11 | + make_fail "You must have sudo and be in sudo group\nAs root do: apt-get install sudo && adduser $USER sudo" |
| 12 | + fi |
| 13 | +} |
| 14 | + |
| 15 | +test_root() { |
| 16 | + if test $(id -u) -eq 0; then |
| 17 | + echo "You run this script as root. DO NOT RUN RANDOM SCRIPTS AS ROOT." |
| 18 | + exit 2 |
| 19 | + fi |
| 20 | +} |
| 21 | + |
| 22 | +make_fail() { |
| 23 | + echo -e "$1" |
| 24 | + exit 3 |
| 25 | +} |
| 26 | + |
| 27 | +make_warn() { |
| 28 | + echo "### $1" |
| 29 | + echo "Press ENTER to continue, CTRL-C to cancel" |
| 30 | + read -r dummy |
| 31 | +} |
| 32 | + |
| 33 | +make_install() { |
| 34 | + echo "Installing Web eID packages for Ubuntu $1" |
| 35 | + TMPDIR=`mktemp -d` |
| 36 | + cd $TMPDIR |
| 37 | + BUILD=`[[ $1 == *0 ]] && echo 555 || echo 552` |
| 38 | + VERSION=${1//./} |
| 39 | + wget "https://installer.id.ee/media/web-eid/Ubuntu/web-eid_2.0.0.${BUILD}-${VERSION}_all.deb" |
| 40 | + wget "https://installer.id.ee/media/web-eid/Ubuntu/web-eid-chrome_2.0.0.${BUILD}-${VERSION}_all.deb" |
| 41 | + wget "https://installer.id.ee/media/web-eid/Ubuntu/web-eid-firefox_2.0.0.${BUILD}-${VERSION}_all.deb" |
| 42 | + wget "https://installer.id.ee/media/web-eid/Ubuntu/web-eid-native_2.0.0.${BUILD}-${VERSION}_amd64.deb" |
| 43 | + sudo apt install ./web-eid*.deb |
| 44 | + cd /tmp |
| 45 | + rm -r $TMPDIR |
| 46 | +} |
| 47 | + |
| 48 | +### main |
| 49 | + |
| 50 | +# Check for Debian derivative. |
| 51 | +if ! command -v lsb_release>/dev/null; then |
| 52 | + make_fail "# Not a Debian Linux derivative, cannot continue." |
| 53 | +fi |
| 54 | + |
| 55 | +# We use sudo. |
| 56 | +test_root |
| 57 | +test_sudo |
| 58 | + |
| 59 | +# version name LTS supported until |
| 60 | +# 18.04 bionic LTS 2023-04 |
| 61 | +# 20.04 focal LTS 2025-04 |
| 62 | +# 21.10 impish - 2022-07 |
| 63 | +LATEST_SUPPORTED_UBUNTU_CODENAME='impish' |
| 64 | +LATEST_SUPPORTED_UBUNTU_VERSION='21.10' |
| 65 | + |
| 66 | +# Check the distro and release. |
| 67 | +distro=$(lsb_release -is | tr '[:upper:]' '[:lower:]') |
| 68 | +release=$(lsb_release -rs) |
| 69 | +codename=$(lsb_release -cs) |
| 70 | + |
| 71 | +case $distro in |
| 72 | + debian) |
| 73 | + make_warn "Debian is not officially supported" |
| 74 | + case "$codename" in |
| 75 | + buster) |
| 76 | + make_warn "Debian $codename is not officially supported" |
| 77 | + make_warn "Installing from ubuntu-bionic repository" |
| 78 | + make_install '18.04' |
| 79 | + ;; |
| 80 | + *) |
| 81 | + make_fail "Debian $codename is not officially supported" |
| 82 | + ;; |
| 83 | + esac |
| 84 | + ;; |
| 85 | + ubuntu|neon) |
| 86 | + case $distro in |
| 87 | + neon) make_warn "Neon is not officially supported; assuming that it is equivalent to Ubuntu" ;; |
| 88 | + *) ;; |
| 89 | + esac |
| 90 | + case $codename in |
| 91 | + utopic|vivid|wily|trusty|artful|cosmic|disco|xenial|eoan|groovy|hirsute) |
| 92 | + make_fail "Ubuntu $codename is not officially supported" |
| 93 | + ;; |
| 94 | + bionic|focal|impish) |
| 95 | + make_install $release |
| 96 | + ;; |
| 97 | + *) |
| 98 | + make_warn "Ubuntu $codename is not officially supported" |
| 99 | + make_warn "Trying to install package for Ubuntu ${LATEST_SUPPORTED_UBUNTU_CODENAME}" |
| 100 | + make_install ${LATEST_SUPPORTED_UBUNTU_VERSION} |
| 101 | + ;; |
| 102 | + esac |
| 103 | + ;; |
| 104 | + linuxmint) |
| 105 | + case $release in |
| 106 | + 20*) |
| 107 | + make_warn "Linuxmint 20 is not officially supported" |
| 108 | + make_install '20.04' |
| 109 | + ;; |
| 110 | + 19*) |
| 111 | + make_warn "LinuxMint 19 is not officially supported" |
| 112 | + make_install '18.04' |
| 113 | + ;; |
| 114 | + *) |
| 115 | + make_fail "LinuxMint $release is not officially supported" |
| 116 | + ;; |
| 117 | + esac |
| 118 | + ;; |
| 119 | + elementary*os|elementary) |
| 120 | + case $release in |
| 121 | + 5.*) |
| 122 | + make_warn "Elementary OS 5 is not officially supported" |
| 123 | + make_install '18.04' |
| 124 | + ;; |
| 125 | + *) |
| 126 | + make_fail "Elementary OS $release is not officially supported" |
| 127 | + ;; |
| 128 | + esac |
| 129 | + ;; |
| 130 | + pop) |
| 131 | + case $codename in |
| 132 | + artful|cosmic|disco|eoan) |
| 133 | + make_fail "Pop!_OS $codename is not officially supported" |
| 134 | + ;; |
| 135 | + bionic|focal) |
| 136 | + make_warn "Pop!_OS $codename is not officially supported" |
| 137 | + make_install $release |
| 138 | + ;; |
| 139 | + *) |
| 140 | + make_warn "Pop!_OS $codename is not officially supported" |
| 141 | + make_warn "Trying to install package for Pop!_OS ${LATEST_SUPPORTED_UBUNTU_CODENAME}" |
| 142 | + make_install ${LATEST_SUPPORTED_UBUNTU_VERSION} |
| 143 | + ;; |
| 144 | + esac |
| 145 | + ;; |
| 146 | + *) |
| 147 | + make_fail "$distro is not supported :(" |
| 148 | + ;; |
| 149 | +esac |
0 commit comments