forked from industrial-edge/iectl-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone-app.sh
87 lines (69 loc) · 3.29 KB
/
standalone-app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# IEM configuration variables
export IEM_USER="<iem-username>"
export IEM_PASSWORD="<iem-password>"
export IEM_URL="https://<iem-ip>:9443"
# Device Configuration variables
export DEVICE_NAME="<device-name>"
# Application configuration variables
export APP_NAME="<application-name>" # Application name
export APP_REPO="<application-repository>" # Applications repository (unique)
# IECTL environmental variables
export IE_SKIP_CERTIFICATE=true
export EDGE_SKIP_TLS=1
# Project envirinmental variables
export PROJECT_PATH_PREFIX="<project-path-prefix>" # Prefix of the absolute path where the project is inside of your development environment
echo "---------------------------Creating publisher configuration---------------------------"
iectl config add publisher \
--name "publisherdev" \
--dockerurl "http://127.0.0.1:2375" \
--workspace "$PROJECT_PATH_PREFIX/workspace"
echo "---------------------------Initializing workspace---------------------------"
cd workspace
iectl publisher workspace init
echo "---------------------------Creating application---------------------------"
iectl publisher standalone-app create \
--reponame $APP_REPO \
--appdescription "application description" \
--iconpath "$PROJECT_PATH_PREFIX/appicon/icon.png" \
--appname $APP_NAME
echo "---------------------------Creating application version---------------------------"
# Version managment
version=$(iectl publisher standalone-app version list -a $APP_NAME -k "versionNumber" | \
python3 $PROJECT_PATH_PREFIX/script/getAppVersion.py)
version_new=$(echo $version | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
echo 'new Version: '$version_new
iectl publisher standalone-app version create \
--appname $APP_NAME \
--changelogs "initial release" \
--yamlpath "$PROJECT_PATH_PREFIX/app/docker-compose.prod.yml" \
--versionnumber $version_new \
-n '{"hello-edge":[{"name":"hello-edge","protocol":"HTTP","port":"80","headers":"","rewriteTarget":"/"}]}' \
-s "hello-edge" \
-t "FromBoxReverseProxy" \
-u "hello-edge" \
-r "/"
echo "---------------------------Creating IEM configuration---------------------------"
iectl config add iem \
--name "iemdev" \
--url $IEM_URL \
--user $IEM_USER \
--password $IEM_PASSWORD
#iectl publisher edgemanagement login -u $IEM_URL -e $IEM_USER -p $IEM_PASSWORD
echo "---------------------------Uploading app to IEM---------------------------"
iectl publisher app-project upload catalog \
--appname $APP_NAME \
-v $version_new
echo "---------------------------Deploying app to IED---------------------------"
# Get application ID
appID=$(iectl iem catalog list| \
python3 $PROJECT_PATH_PREFIX/script/getAppId.py --app_name $APP_NAME)
echo $appID
# Get edge device ID
deviceID=$(iectl iem device list| \
python3 $PROJECT_PATH_PREFIX/script/getDeviceId.py --device_name $DEVICE_NAME)
echo $deviceID
# SUbmit a batch job to install app to IED
iectl iem job batch-create \
--appid "$appID" \
--operation "installApplication" \
--infoMap {"devices":["$deviceID"]}