forked from bcgov/dts-endorser-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rajpal Chauhan <[email protected]>
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"auths": { | ||
"ghcr.io": { | ||
"username": "your-github-actor", | ||
"password": "your-github-token", | ||
"email": "[email protected]", | ||
"auth": "base64-encoded-auth-string" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
AUDIT_CONF=${AUDIT_CONF:-./audit.conf} | ||
|
||
function echoBlue (){ | ||
_msg="${@}" | ||
_blue='\e[34m' | ||
_nc='\e[0m' # No Color | ||
echo -e "${_blue}${_msg}${_nc}" | ||
} | ||
|
||
function logInfo(){ | ||
( | ||
infoMsg="${1}" | ||
echo -e "${infoMsg}" | ||
postMsgToWebhook "${ENVIRONMENT_FRIENDLY_NAME}" \ | ||
"${ENVIRONMENT_NAME}" \ | ||
"INFO" \ | ||
"${infoMsg}" | ||
) | ||
} | ||
|
||
function logWarn(){ | ||
( | ||
warnMsg="${1}" | ||
echoYellow "${warnMsg}" | ||
postMsgToWebhook "${ENVIRONMENT_FRIENDLY_NAME}" \ | ||
"${ENVIRONMENT_NAME}" \ | ||
"WARN" \ | ||
"${warnMsg}" | ||
) | ||
} | ||
|
||
function logError(){ | ||
( | ||
errorMsg="${1}" | ||
echoRed "[!!ERROR!!] - ${errorMsg}" >&2 | ||
postMsgToWebhook "${ENVIRONMENT_FRIENDLY_NAME}" \ | ||
"${ENVIRONMENT_NAME}" \ | ||
"ERROR" \ | ||
"${errorMsg}" | ||
) | ||
} | ||
|
||
function postMsgToWebhook(){ | ||
( | ||
if [ -z "${WEBHOOK_URL}" ] && [ -f ${WEBHOOK_TEMPLATE} ]; then | ||
return 0 | ||
fi | ||
|
||
projectFriendlyName=${1} | ||
projectName=${2} | ||
statusCode=${3} | ||
message=$(formatWebhookMsg "${4}") | ||
curl -s -X POST -H 'Content-Type: application/json' --data "$(getWebhookPayload)" "${WEBHOOK_URL}" > /dev/null | ||
) | ||
} | ||
|
||
function shutDown(){ | ||
jobIds=$(jobs | awk -F '[][]' '{print $2}' ) | ||
for jobId in ${jobIds} ; do | ||
echo "Shutting down background job '${jobId}' ..." | ||
kill %${jobId} | ||
done | ||
|
||
if [ ! -z "${jobIds}" ]; then | ||
echo "Waiting for any background jobs to complete ..." | ||
fi | ||
wait | ||
|
||
exit 0 | ||
} | ||
|
||
function startCron(){ | ||
logInfo "Starting audit server in cron mode ..." | ||
echoBlue "Starting go-crond as a background task ...\n" | ||
CRON_CMD="go-crond -v --default-user=${UID} --working-directory=$(pwd) --allow-unprivileged ${AUDIT_CONF}" | ||
exec ${CRON_CMD} & | ||
wait | ||
} | ||
|
||
trap shutDown EXIT TERM | ||
|
||
startCron |