This repository has been archived by the owner on Jan 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstallCatalog.sh
executable file
·109 lines (83 loc) · 4.15 KB
/
installCatalog.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# use the command line interface to install standard actions deployed
# automatically
#
# To run this command
# ./installCatalog.sh <authkey> <edgehost> <dburl> <dbprefix> <apihost> <workers>
set -e
set -x
: ${OPENWHISK_HOME:?"OPENWHISK_HOME must be set and non-empty"}
WSK_CLI="$OPENWHISK_HOME/bin/wsk"
if [ $# -eq 0 ]; then
echo "Usage: ./installCatalog.sh <authkey> <edgehost> <dburl> <dbprefix> <apihost> <workers>"
fi
AUTH="$1"
EDGEHOST="$2"
DB_URL="$3"
DB_NAME="${4}cloudanttrigger"
APIHOST="$5"
WORKERS="$6"
ACTION_RUNTIME_VERSION=${ACTION_RUNTIME_VERSION:="nodejs:20"}
# If the auth key file exists, read the key in the file. Otherwise, take the
# first argument as the key itself.
if [ -f "$AUTH" ]; then
AUTH=`cat $AUTH`
fi
# Make sure that the EDGEHOST is not empty.
: ${EDGEHOST:?"EDGEHOST must be set and non-empty"}
# Make sure that the DB_URL is not empty.
: ${DB_URL:?"DB_URL must be set and non-empty"}
# Make sure that the DB_NAME is not empty.
: ${DB_NAME:?"DB_NAME must be set and non-empty"}
# Make sure that the APIHOST is not empty.
: ${APIHOST:?"APIHOST must be set and non-empty"}
PACKAGE_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export WSK_CONFIG_FILE= # override local property file to avoid namespace clashes
echo Installing Cloudant package.
$WSK_CLI -i --apihost "$EDGEHOST" package update --auth "$AUTH" --shared yes cloudant \
-a description "Cloudant database service" \
-a parameters '[ {"name":"bluemixServiceName", "required":false, "bindTime":true}, {"name":"username", "required":false, "bindTime":true, "description": "Your Cloudant username"}, {"name":"password", "required":false, "type":"password", "bindTime":true, "description": "Your Cloudant password"}, {"name":"host", "required":true, "bindTime":true, "description": "This is usually your username.cloudant.com"}, {"name":"iamApiKey", "required":false}, {"name":"iamUrl", "required":false}, {"name":"dbname", "required":false, "description": "The name of your Cloudant database"}, {"name":"overwrite", "required":false, "type": "boolean"} ]' \
-p bluemixServiceName 'cloudantNoSQLDB' \
-p apihost "$APIHOST"
# make changesFeed.zip
cd action
if [ -e changesFeed.zip ]; then
rm -rf changesFeed.zip
fi
cp -f changesFeed_package.json package.json
zip -r changesFeed.zip lib package.json changes.js
$WSK_CLI -i --apihost "$EDGEHOST" action update --kind "$ACTION_RUNTIME_VERSION" --auth "$AUTH" cloudant/changes "$PACKAGE_HOME/action/changesFeed.zip" \
-t 90000 \
-a feed true \
-a provide-api-key true \
-a description 'Database change feed' \
-a parameters '[ {"name":"dbname", "required":true, "updatable":false}, {"name":"iamApiKey", "required":false, "updatable":false}, {"name":"iamUrl", "required":false, "updatable":false}, {"name": "filter", "required":false, "updatable":true, "type": "string", "description": "The name of your Cloudant database filter"}, {"name": "query_params", "required":false, "updatable":true, "description": "JSON Object containing query parameters that are passed to the filter"} ]' \
-a sampleInput '{ "dbname": "mydb", "filter": "mailbox/by_status", "query_params": {"status": "new"} }'
COMMAND=" -i --apihost $EDGEHOST package update --auth $AUTH --shared no cloudantWeb \
-p DB_URL $DB_URL \
-p DB_NAME $DB_NAME \
-p CRYPT_VERSION $CRYPT_VERSION \
-p apihost $APIHOST"
if [ -n "$WORKERS" ]; then
COMMAND+=" -p workers $WORKERS"
fi
if [ -n "$CRYPT_KEKI" ]; then
COMMAND+=" -p CRYPT_KEKI $CRYPT_KEKI"
COMMAND+=" -p CRYPT_KEK $CRYPT_KEK"
fi
if [ -n "$CRYPT_KEKIF" ]; then
COMMAND+=" -p CRYPT_KEKIF $CRYPT_KEKIF"
COMMAND+=" -p CRYPT_KEKF $CRYPT_KEKF"
fi
$WSK_CLI $COMMAND
# make changesWebAction.zip
cp -f changesWeb_package.json package.json
npm install
if [ -e changesWebAction.zip ]; then
rm -rf changesWebAction.zip
fi
zip -r changesWebAction.zip lib package.json changesWebAction.js node_modules
$WSK_CLI -i --apihost "$EDGEHOST" action update --kind "$ACTION_RUNTIME_VERSION" --auth "$AUTH" cloudantWeb/changesWebAction "$PACKAGE_HOME/action/changesWebAction.zip" \
-a description 'Create/Delete a trigger in cloudant provider Database' \
--web true