Fixed naming
Update the git config repo
This commit is contained in:
@ -45,14 +45,14 @@ source /etc/bridgehead/site.conf
|
||||
|
||||
# TODO: Check all required variables here in a generic loop
|
||||
|
||||
if [ -z "$site_name" ]; then
|
||||
if [ -z "$SITE_NAME" ]; then
|
||||
log ERROR "Please set site_name."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#check if project env is present
|
||||
if [ -d "/etc/bridgehead/${project}.env" ]; then
|
||||
log ERROR "Project config not found. Please copy the template from ${project} and put it under /etc/bridgehead-config/${project}.env."
|
||||
if [ -d "/etc/bridgehead/${PROJECT}.env" ]; then
|
||||
log ERROR "Project config not found. Please copy the template from ${PROJECT} and put it under /etc/bridgehead-config/${PROJECT}.env."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -12,12 +12,12 @@ if [ $1 != "ccp" ] && [ $1 != "nngm" ] && [ $1 != "gbn" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export project=$1
|
||||
export PROJECT=$1
|
||||
|
||||
#checkRequirements // not needed when uninstalling
|
||||
|
||||
log "Stopping systemd services and removing bridgehead ..."
|
||||
|
||||
systemctl disable --now bridgehead@${project}.service bridgehead-update@${project}.timer bridgehead-update@${project}.service
|
||||
systemctl disable --now bridgehead@${PROJECT}.service bridgehead-update@${PROJECT}.timer bridgehead-update@${PROJECT}.service
|
||||
|
||||
rm -v /etc/systemd/system/{bridgehead\@.service,bridgehead-update\@.timer,bridgehead-update\@.service}
|
||||
|
@ -14,7 +14,7 @@ if [ $1 != "ccp" ] && [ $1 != "nngm" ] && [ $1 != "gbn" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export project=$1
|
||||
export PROJECT=$1
|
||||
|
||||
checkRequirements
|
||||
|
||||
@ -29,11 +29,11 @@ systemctl daemon-reload
|
||||
|
||||
echo
|
||||
|
||||
if ! systemctl is-active --quiet bridgehead@"${project}"; then
|
||||
log "Enabling autostart of bridgehead@${project}.service"
|
||||
systemctl enable bridgehead@"${project}"
|
||||
log "Enabling nightly updates for bridgehead@${project}.service ..."
|
||||
systemctl enable --now bridgehead-update@"${project}".timer
|
||||
if ! systemctl is-active --quiet bridgehead@"${PROJECT}"; then
|
||||
log "Enabling autostart of bridgehead@${PROJECT}.service"
|
||||
systemctl enable bridgehead@"${PROJECT}"
|
||||
log "Enabling nightly updates for bridgehead@${PROJECT}.service ..."
|
||||
systemctl enable --now bridgehead-update@"${PROJECT}".timer
|
||||
fi
|
||||
|
||||
echo -e "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${project}.service\nor by rebooting your machine."
|
||||
echo -e "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${PROJECT}.service\nor by rebooting your machine."
|
||||
|
@ -1,34 +1,35 @@
|
||||
#!/bin/bash
|
||||
service="bridgehead"
|
||||
|
||||
source lib/functions.sh
|
||||
|
||||
#checkRequirements // not required for mere update
|
||||
log "INFO" "Checking for updates of services"
|
||||
|
||||
log "INFO" "Checking for updates of $service"
|
||||
# check prerequisites
|
||||
# Check git updates
|
||||
for DIR in /etc/bridgehead $(pwd); do
|
||||
old_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
|
||||
git -C $DIR fetch 2>&1
|
||||
git -C $DIR pull 2>&1
|
||||
new_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
|
||||
git_updated="false"
|
||||
if [ "$old_git_hash" != "$new_git_hash" ]; then
|
||||
log "INFO" "Pulled new changes from origin"
|
||||
git_updated="true"
|
||||
fi
|
||||
done
|
||||
|
||||
# check if updates are available
|
||||
old_git_hash="$(git rev-parse --verify HEAD)"
|
||||
git fetch 2>&1
|
||||
git pull 2>&1
|
||||
new_git_hash="$(git rev-parse --verify HEAD)"
|
||||
git_updated="false"
|
||||
if [ "$old_git_hash" != "$new_git_hash" ]; then
|
||||
log "INFO" "Pulled new changes from origin"
|
||||
git_updated="true"
|
||||
fi
|
||||
# Check docker updates
|
||||
docker_updated="false"
|
||||
for image in $(docker ps --filter "name=$service" --format {{.Image}}); do
|
||||
log "INFO" "Checking for Updates of Image: $image"
|
||||
if docker pull $image | grep "Downloaded newer image"; then
|
||||
log "INFO" "$image updated."
|
||||
for IMAGE in $(docker ps --filter "name=bridgehead" --format {{.Image}}); do
|
||||
log "INFO" "Checking for Updates of Image: $IMAGE"
|
||||
if docker pull $IMAGE | grep "Downloaded newer image"; then
|
||||
log "INFO" "$IMAGE updated."
|
||||
docker_updated="true"
|
||||
fi
|
||||
done
|
||||
|
||||
# If anything is updated, restart service
|
||||
if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then
|
||||
log "INFO" "Due to previous updates now restarting $service@$1"
|
||||
systemctl restart "$service@$1.service"
|
||||
log "INFO" "Due to previous updates now restarting bridgehead"
|
||||
systemctl restart 'bridgehead@*'
|
||||
fi
|
||||
log "INFO" "checking updates finished"
|
||||
exit 0
|
||||
exit 0
|
Reference in New Issue
Block a user