Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
Signed-off-by: Rajpal Chauhan <[email protected]>
  • Loading branch information
rajpalc7 committed Dec 22, 2023
1 parent d2187c8 commit 35142a7
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker/config.json
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"
}
}
}
84 changes: 84 additions & 0 deletions docker/run.sh
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

0 comments on commit 35142a7

Please sign in to comment.