#!/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}"