diff options
author | Lukasz Woznicki <75632179+makr11st@users.noreply.github.com> | 2021-10-22 13:34:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 13:34:03 +0100 |
commit | 9e02441af533500c9f8d8823894ca753acca7c95 (patch) | |
tree | dcc2a8bee656744d04fb4af1d1599c28ba42dd0d /get-thin-edge_io.sh | |
parent | 8bdccf140251e8b91728d95874dddd868cf9071e (diff) |
[CIT-639] get tedge script installs all components (#517)
* Remove tedge_apt_plugin dependency from tedge_agent deb
* Add options parsing with support for minimal
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'get-thin-edge_io.sh')
-rwxr-xr-x | get-thin-edge_io.sh | 90 |
1 files changed, 72 insertions, 18 deletions
diff --git a/get-thin-edge_io.sh b/get-thin-edge_io.sh index 30a1b3cb..5b1a73fc 100755 --- a/get-thin-edge_io.sh +++ b/get-thin-edge_io.sh @@ -1,6 +1,57 @@ #!/bin/sh set -e +TYPE=${2:-full} + +usage() { + cat <<EOF +USAGE: + get-thin-edge_io [<VERSION>] [--minimal] + +ARGUMENTS: + <VERSION> Install specific version of thin-edge.io - if not provided installs latest minor release + +OPTIONS: + --minimal Install only basic set of components - tedge cli and tedge mappers + +EOF +} + +install_basic_components() { + wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_${VERSION}_${ARCH}.deb -P /tmp/tedge + wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_mapper_${VERSION}_${ARCH}.deb -P /tmp/tedge + + dpkg -i /tmp/tedge/tedge_${VERSION}_${ARCH}.deb + dpkg -i /tmp/tedge/tedge_mapper_${VERSION}_${ARCH}.deb + +} + +install_tedge_agent() { + wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_agent_${VERSION}_${ARCH}.deb -P /tmp/tedge + + dpkg -i /tmp/tedge/tedge_agent_${VERSION}_${ARCH}.deb +} + +install_tedge_plugins() { + wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_apt_plugin_${VERSION}_${ARCH}.deb -P /tmp/tedge + dpkg -i /tmp/tedge/tedge_apt_plugin_${VERSION}_${ARCH}.deb +} + +if [ $# -lt 3 ]; then + while :; do + case $1 in + --minimal) + TYPE="minimal" + shift + ;; + *) break ;; + esac + done +else + usage + exit 0 +fi + VERSION=$1 ARCH=$(dpkg --print-architecture) @@ -15,8 +66,7 @@ fi echo "${BLUE}Thank you for trying thin-edge.io! ${COLORRESET}\n" -if [ -z "$VERSION" ] -then +if [ -z "$VERSION" ]; then VERSION=0.4.0 echo "Version argument has not been provided, installing latest: ${BLUE}$VERSION${COLORRESET}" @@ -24,17 +74,14 @@ then echo "For example: ${BLUE}sudo ./get-thin-edge_io.sh $VERSION${COLORRESET}" fi -if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ] || [ "$ARCH" = "armhf" ] || [ "$ARCH" = "amd64" ] -then +if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ] || [ "$ARCH" = "armhf" ] || [ "$ARCH" = "amd64" ]; then # Some OSes may read architecture type as `aarch64`, `aarch64` and `arm64` are the same architectures types. - if [ "$ARCH" = "aarch64" ] - then + if [ "$ARCH" = "aarch64" ]; then ARCH='arm64' fi # For arm64, only the versions above 0.3.0 are available. - if [ "$ARCH" = "arm64" ] && ! dpkg --compare-versions "$VERSION" ge "0.3.0" - then + if [ "$ARCH" = "arm64" ] && ! dpkg --compare-versions "$VERSION" ge "0.3.0"; then echo "aarch64/arm64 compatible packages are only available for version 0.3.0 or above." exit 1 fi @@ -45,26 +92,33 @@ else exit 0 fi -if [ -d "/tmp/tedge" ] -then +if [ -d "/tmp/tedge" ]; then rm -R /tmp/tedge fi echo "${BLUE}Installing mosquitto as prerequirement for thin-edge.io${COLORRESET}" apt install mosquitto -y -wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_${VERSION}_${ARCH}.deb -P /tmp/tedge -wget https://github.com/thin-edge/thin-edge.io/releases/download/${VERSION}/tedge_mapper_${VERSION}_${ARCH}.deb -P /tmp/tedge - -dpkg -i /tmp/tedge/tedge_${VERSION}_${ARCH}.deb -dpkg -i /tmp/tedge/tedge_mapper_${VERSION}_${ARCH}.deb +case $TYPE in +minimal) install_basic_components ;; +full) + install_basic_components + install_tedge_agent + if apt -v &>/dev/null; then + install_tedge_plugins + fi + ;; +*) + echo "Unsupported argument type." + exit 1 + ;; +esac rm -R /tmp/tedge # Test if tedge command is there and working -tedge help > /dev/null -if [ $? -eq 0 ] -then +tedge help >/dev/null +if [ $? -eq 0 ]; then echo "\n${BLUE}thin-edge.io is now installed on your system!${COLORRESET}" echo "" echo "To administrate your thin-edge.io installation your user has to be part of the group 'tedge-users'." |