forked from PacoVK/terraform-aws-functionbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda_loader.sh
executable file
·30 lines (21 loc) · 929 Bytes
/
lambda_loader.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
#!/bin/sh
set -e
eval "$(jq -er '@sh "VERSION=\(.version)
ENABLED_FUNCTION=\(.enabled_function)
CONFIG_FILE=\(.config_file)"')"
SYSTEM="$(uname | awk '{print tolower($0)}')"
FUNCTION_BEAT_URL=https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-"${VERSION}"-"${SYSTEM}"-x86_64.tar.gz
DESTINATION=functionbeat-"${VERSION}"-"${SYSTEM}"-x86_64
export BEAT_STRICT_PERMS=false
export ENABLED_FUNCTION="${ENABLED_FUNCTION}"
if [ ! -d "${DESTINATION}" ]; then
curl -s "${FUNCTION_BEAT_URL}" > "${DESTINATION}".tar.gz
tar xzvf "${DESTINATION}".tar.gz > /dev/null
rm -rf "${DESTINATION}".tar.gz
fi
cp -f "${CONFIG_FILE}" "${DESTINATION}"/functionbeat.yml
cd "${DESTINATION}"
./functionbeat -v -e package --output ./../"${DESTINATION}-release".zip
cd ..
rm -rf "${DESTINATION}"
jq -M -c -n --arg destination "${DESTINATION}-release.zip" '{"filename": $destination}'