|
1 | 1 | #!/bin/bash |
| 2 | +## MUST: Always update this whenever a new version is released. Also remember to update download URLs if needed |
| 3 | +APP_VERSION=1.4.0 |
| 4 | +URL_STUB="https://github.com/OpenBangla/OpenBangla-Keyboard/releases/download/${APP_VERSION}" |
2 | 5 |
|
3 | | -# set Download link |
| 6 | +cat <<"EOF" |
| 7 | +|-------------------------------------------------------| |
| 8 | +|-----Welcome to the OpenBangla Keyboard installer------| |
| 9 | +|-------------------------------------------------------| |
4 | 10 |
|
5 | | -ubuntuLink="https://github.com/OpenBangla/OpenBangla-Keyboard/releases/download/1.4.0/OpenBangla-Keyboard_1.4.0-ubuntu18.04.deb" |
6 | | -archLink="https://github.com/OpenBangla/OpenBangla-Keyboard/releases/download/1.4.0/openbangla-keyboard-1.4.0-1-x86_64-archlinux.pkg.tar.xz" |
7 | | -fedoraLink="https://github.com/OpenBangla/OpenBangla-Keyboard/releases/download/1.4.0/OpenBangla-Keyboard_1.4.0-fedora27.rpm" |
| 11 | +This helper script will install/update OpenBangla Keyboard in your system. |
| 12 | +You might need to type your password for the installation to proceed. |
8 | 13 |
|
9 | | -# detect OS |
10 | | -os=$(python -c "exec(\"import platform\\nprint(platform.linux_distribution()[0])\")" ) |
11 | | -echo Downloading $os Binary |
| 14 | +After the installation completes successfully, you would need to configure |
| 15 | +your desktop environment for OpenBangla Keyboard to work. |
| 16 | +Visit https://github.com/OpenBangla/OpenBangla-Keyboard/wiki/Configuring-Environment |
| 17 | +for instructions on how to configure your desktop environment. |
| 18 | +-------------------------------------------------------- |
12 | 19 |
|
13 | | -# get super user access |
| 20 | +EOF |
14 | 21 |
|
15 | | -# start downloading and install |
16 | | -case $os in |
17 | | - |
18 | | -("Ubuntu") |
19 | | - wget -q --show-progress $ubuntuLink -O ./OpenBangla.deb |
20 | | - sudo apt install ./OpenBangla.deb |
21 | | - sudo rm -f ./OpenBangla.deb |
22 | | - ;; |
| 22 | +# detect distro |
| 23 | +function get_distro { |
| 24 | + local distro_name distro_data distro_str |
| 25 | + # try to get distro data from *-release files |
| 26 | + distro_data=$(cat /etc/*-release) |
| 27 | + while read -r line; do |
| 28 | + if [[ $line =~ ^(NAME|DISTRIB_ID)=(.+)$ ]]; then |
| 29 | + distro_str=${BASH_REMATCH[2]} |
| 30 | + if echo "$distro_str" | grep -qP '(?i).*ubuntu.*'; then |
| 31 | + distro_name='ubuntu' |
| 32 | + elif echo "$distro_str" | grep -qP '(?i).*fedora.*'; then |
| 33 | + distro_name='fedora' |
| 34 | + elif echo "$distro_str" | grep -qP '(?i)^[''"]?(arch|manjaro|antergos|chakra|magpie|parabola|anarchy).*'; then |
| 35 | + distro_name='arch' |
| 36 | + fi |
| 37 | + [ $distro_name ] && break |
| 38 | + fi |
| 39 | + done <<< "$distro_data" |
| 40 | + # plain arch installation doesn't guarantee /etc/os-release |
| 41 | + # but the filesystem pkg installs a blank /etc/arch-release |
| 42 | + if [ -z "$distro_name" ]; then |
| 43 | + if [ -e /etc/arch-release ]; then |
| 44 | + distro_name='arch' |
| 45 | + fi |
| 46 | + fi |
| 47 | + # TODO if os not detected, try package-manager detection (not 100% reliable) |
| 48 | + echo "$distro_name" |
| 49 | +} |
23 | 50 |
|
| 51 | +DISTRO_NAME=$(get_distro) |
| 52 | +echo "Downloading installation package for $DISTRO_NAME ..." |
| 53 | +# start downloading and install |
| 54 | +case $DISTRO_NAME in |
| 55 | +("ubuntu") |
| 56 | + # VERSION_ID=$(lsb_release -r | cut -f 2) # lsb_release may be replaced as well with shell script |
| 57 | + # ubuntu is supposed to ensure a /etc/os-release file by default |
| 58 | + # VERSION_ID (and some more vars) are sourced |
| 59 | + # shellcheck disable=SC1091 |
| 60 | + source /etc/os-release |
| 61 | + if [[ $VERSION_ID = "18.04" || $VERSION_ID = "16.04" ]]; then |
| 62 | + wget -q --show-progress "${URL_STUB}/OpenBangla-Keyboard_${APP_VERSION}-ubuntu${VERSION_ID}.deb" -O "$HOME/OpenBangla.deb" |
| 63 | + sudo apt install "$HOME/OpenBangla.deb" |
| 64 | + mv -f "$HOME/OpenBangla.deb" /tmp/ |
| 65 | + else |
| 66 | + echo "Ubuntu version not supported ($VERSION_ID)." |
| 67 | + fi |
| 68 | + ;; |
24 | 69 | ("arch") |
25 | | - wget -q --show-progress $archLink -O /tmp/OpenBangla.pkg.tar.xz |
26 | | - sudo pacman -U /tmp/OpenBangla.pkg.tar.xz |
27 | | - ;; |
28 | | - |
29 | | -("Fedora") |
30 | | - wget -q --show-progress $fedoraLink -O /tmp/OpenBangla.rpm |
31 | | - sudo dnf install /tmp/OpenBangla.rpm |
32 | | - sudo rm -f /tmp/OpenBangla.rpm |
33 | | - ;; |
34 | | - |
| 70 | + # this url should proably be normalized soon |
| 71 | + wget -q --show-progress "${URL_STUB}/openbangla-keyboard-${APP_VERSION}-1-x86_64-archlinux.pkg.tar.xz" -O /tmp/OpenBangla.pkg.tar.xz |
| 72 | + sudo pacman -U /tmp/OpenBangla.pkg.tar.xz |
| 73 | + ;; |
| 74 | +("fedora") |
| 75 | + # fedora version check ? |
| 76 | + wget -q --show-progress "${URL_STUB}/OpenBangla-Keyboard_${APP_VERSION}-fedora27.rpm" -O /tmp/OpenBangla.rpm |
| 77 | + sudo dnf install /tmp/OpenBangla.rpm |
| 78 | + ;; |
35 | 79 | (*) |
36 | | - echo "Could Not Find your distro" |
37 | | - ;; |
38 | | - |
| 80 | + echo |
| 81 | + echo "Sorry, this script was not able to identify your OS distribution." |
| 82 | + echo |
| 83 | + echo "Please consult https://github.com/OpenBangla/OpenBangla-Keyboard/wiki/" |
| 84 | + echo "for distrowise install or build instructions." |
| 85 | + echo |
| 86 | + ;; |
39 | 87 | esac |
0 commit comments