feature: Added Access Token for Git to Configuration

This commit is contained in:
Torben Brenner 2022-12-01 09:50:43 +01:00
parent b147420aae
commit 8138df1de3
2 changed files with 18 additions and 0 deletions

View File

@ -117,6 +117,11 @@ fixPermissions() {
source lib/monitoring.sh source lib/monitoring.sh
log_and_report() {
log INFO "$@"
hc_send 0 "$@"
}
report_error() { report_error() {
CODE=$1 CODE=$1
shift shift

View File

@ -30,6 +30,19 @@ checkOwner /etc/bridgehead bridgehead || fail_and_report 1 "Update failed: Wrong
CREDHELPER="/srv/docker/bridgehead/lib/gitpassword.sh" 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="" CHANGES=""
# Check git updates # Check git updates