Monitoring for bridgehead startup and update (#22)

This commit is contained in:
Martin Lablans
2022-10-06 10:45:50 +02:00
committed by GitHub
parent 945a862a68
commit 8a62743894
10 changed files with 98 additions and 33 deletions

View File

@ -1,9 +1,11 @@
#!/bin/bash -e
source lib/log.sh
exitIfNotRoot() {
if [ "$EUID" -ne 0 ]; then
log "ERROR" "Please run as root"
exit 1
fail_and_report 1 "Please run as root"
fi
}
@ -16,10 +18,6 @@ checkOwner(){
return 0
}
log() {
echo -e "$(date +'%Y-%m-%d %T')" "$1:" "$2"
}
printUsage() {
echo "Usage: bridgehead start|stop|update|install|uninstall PROJECTNAME"
echo "PROJECTNAME should be one of ccp|nngm|gbn"
@ -28,7 +26,7 @@ printUsage() {
checkRequirements() {
if ! lib/prerequisites.sh; then
log "ERROR" "Validating Prerequisites failed, please fix the error(s) above this line."
exit 1
fail_and_report 1 "Validating prerequisites failed."
else
return 0
fi
@ -97,6 +95,19 @@ assertVarsNotEmpty() {
return 0
}
fixPermissions() {
CHOWN=$(which chown)
sudo $CHOWN -R bridgehead /etc/bridgehead /srv/docker/bridgehead
}
source lib/monitoring.sh
fail_and_report() {
log ERROR "$2"
hc_send $1 "$2"
exit $1
}
##Setting Network properties
export HOSTIP=$(MSYS_NO_PATHCONV=1 docker run --rm --add-host=host.docker.internal:host-gateway ubuntu cat /etc/hosts | grep 'host.docker.internal' | awk '{print $1}');
export HOST=$(hostname)