File: pkgos-trigger-odrm-hook

package info (click to toggle)
openstack-pkg-tools 140
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: sh: 4,220; makefile: 31
file content (36 lines) | stat: -rwxr-xr-x 1,025 bytes parent folder | download
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
#!/bin/sh

set -e

# Not showing output with set -x for security reasons.
# We dont want shared secret and signatures to leak.

if ! [ -r /etc/pkgos/pkgos.conf ] ; then
	echo "Could not read /etc/pkgos/pkgos.conf."
	exit 1
else
	. /etc/pkgos/pkgos.conf
fi

if [ -z "${OSBPO_DEBIAN_NET_SHARED_SECRET}" ] ; then
	echo "OSBPO_DEBIAN_NET_SHARED_SECRET in /etc/pkgos/pkgos.conf is empty: please configure it."
	exit 1
fi

if [ -z "${OSBPO_DEBIAN_NET_HOOK_URL}" ] ; then
	echo "OSBPO_DEBIAN_NET_HOOK_URL in /etc/pkgos/pkgos.conf is empty: please configure it."
	exit 1
fi

PAYLOAD='{"debian_release":"'${TARGET_DISTRO}'","openstack_release":"'${TARGET_OPENSTACK_REL}'"}'

# Compute HMAC-SHA256
SIG=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$OSBPO_DEBIAN_NET_SHARED_SECRET" | sed 's/^.* //')
SIG="sha256=$SIG"

echo "-> Calling ${OSBPO_DEBIAN_NET_HOOK_URL} with payload: ${PAYLOAD}"
curl -s -X POST \
	-H "Content-Type: application/json" \
	-H "X-Hub-Signature-256: $SIG" \
	-d "$PAYLOAD" \
	"${OSBPO_DEBIAN_NET_HOOK_URL}"