diff --git a/lib/functions.sh b/lib/functions.sh index 4f40fd0..4b8ca3e 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -117,6 +117,11 @@ fixPermissions() { source lib/monitoring.sh +log_and_report() { + log INFO "$@" + hc_send 0 "$@" +} + report_error() { CODE=$1 shift diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index fd4806b..f6239a0 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -30,6 +30,19 @@ checkOwner /etc/bridgehead bridgehead || fail_and_report 1 "Update failed: Wrong CREDHELPER="/srv/docker/bridgehead/lib/gitpassword.sh" +# Check if access-token is up-to-date +log INFO "Checking authentication information for git server" +current_configuration_remote="$(git -C /etc/bridgehead remote get-url origin)" + +if [[ ${current_configuration_remote} != "https://$GIT_REMOTE_TOKEN@"* ]];then + new_configuration_remote="https://$GIT_REMOTE_TOKEN@${current_configuration_remote#*@}" + git -C /etc/bridgehead remote set-url origin "${new_configuration_remote}" + log_and_report "Updated the authentication credentials for /etc/bridgehead." + log INFO "Your new authentication url is ${new_configuration_remote}" +else + log_and_report "Authentication credentials in /etc/bridgehead are up-to-date" +fi + CHANGES="" # Check git updates