Upgrade honeynode sim version
[transportpce.git] / tests / install_honeynode.sh
1 #!/bin/sh
2
3 #set -x
4
5 VERSIONS_LIST=${@:-"1.2.1 2.2.1 7.1"}
6
7 #check if curl exists
8 if ! [ -x "$(command -v curl)" ];then
9     echo "curl is not installed." >&2
10     exit 1
11 fi
12 #check if unzip exists
13 if ! [ -x "$(command -v unzip)" ];then
14     echo "unzip is not installed." >&2
15     exit 1
16 fi
17
18 for VERSION in $VERSIONS_LIST
19 do
20     case "$VERSION" in
21         "1.2.1") PLUGIN_VERSION=1.0.8
22         ;;
23         "2.2.1") PLUGIN_VERSION=2.0.8
24         ;;
25         "7.1") PLUGIN_VERSION=7.1.5
26         ;;
27         *) echo "unsupported device version" >&2
28         continue
29         ;;
30     esac
31     TARGET_DIR=$(dirname $0)/honeynode/$VERSION
32     INSTALL_DIR=$TARGET_DIR/honeynode-simulator
33     ARTIFACT_ZIPFILE=$TARGET_DIR/artifact.zip
34     TARGET_URL="https://gitlab.com/api/v4/projects/17518226/jobs/artifacts/honeynode-plugin-aggregator-$PLUGIN_VERSION/download?job=mvn-build"
35
36     #clean honeynode install directory
37
38     if [ -d "$INSTALL_DIR" ];then
39         echo "Removing $INSTALL_DIR directory"
40         rm -rf $INSTALL_DIR
41     fi
42
43     #download honeynode  and install it
44     #complete source code can be found at https://gitlab.com/Orange-OpenSource/lfn/odl/honeynode-simulator.git
45
46     echo "Installing honeynode for $VERSION devices to $INSTALL_DIR directory "
47     curl --retry-delay 10 --retry 3 -sS --location --request GET $TARGET_URL -o $ARTIFACT_ZIPFILE || exit 2
48     unzip -q $ARTIFACT_ZIPFILE -d $TARGET_DIR
49     rm -f $ARTIFACT_ZIPFILE
50
51 done
52 exit