diff --git a/install-bridgehead.sh b/install-bridgehead.sh index 54f4568..bd9afea 100755 --- a/install-bridgehead.sh +++ b/install-bridgehead.sh @@ -11,38 +11,27 @@ if ! ./lib/prerequisites.sh; then fi source site.conf -echo "Installing bridgehead" - _systemd_path=/etc/systemd/system/ -echo "Installing systemd units ..." +echo -e "\nInstalling systemd units ..." cp -v \ - convenience/bridgehead\@.service \ - convenience/bridgehead-update\@.service \ - convenience/bridgehead-update\@.timer \ - $_systemd_path + convenience/bridgehead\@.service \ + convenience/bridgehead-update\@.service \ + convenience/bridgehead-update\@.timer \ + $_systemd_path -echo "Loading the bridgehead definitions in systemd" systemctl daemon-reload +echo -echo "Starting Project ${project} " - if [ ! -f "/etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf" ]; then - echo "Can't find local configuration file for bridgehead@${project} service. Please ensure that the file /etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf exists" - exit - fi - - systemctl is-active --quiet bridgehead@"${project}" - if [ ! $? -eq 0 ]; then - echo "Starting bridgehead@${project} service ..." - systemctl start bridgehead@"${project}" +if ! systemctl is-active --quiet bridgehead@"${project}"; then echo "Enabling autostart of bridgehead@${project}.service" systemctl enable bridgehead@"${project}" echo "Enabling nightly updates for bridgehead@${project}.service ..." systemctl enable --now bridgehead-update@"${project}".timer - fi +fi + +echo -e "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${project}.service\nor by rebooting your machine." -# Switch back to execution directory; -cd - # TODO: Configuration of the different modules diff --git a/start-bridgehead.sh b/start-bridgehead.sh index 6634dd6..3d4f2ef 100755 --- a/start-bridgehead.sh +++ b/start-bridgehead.sh @@ -1,13 +1,15 @@ #!/bin/bash ### Note: Currently not complete, needs some features before useable for production +source lib/functions.sh + if ! ./prerequisites.sh; then - echo "Prerequisites failed, exiting" + log "Prerequisites failed, exiting" exit fi source site.conf -echo "Starting bridgehead" +log "Starting bridgehead" cd ${project} @@ -15,4 +17,4 @@ docker-compose --env-file ../site-config/${project}.env up -d cd .. -echo "The bridgehead should be in online in a few seconds" +log "The bridgehead should be in online in a few seconds" diff --git a/stop-bridgehead.sh b/stop-bridgehead.sh index 8ab4eff..1d6798e 100755 --- a/stop-bridgehead.sh +++ b/stop-bridgehead.sh @@ -1,7 +1,10 @@ -echo "Stoping bridgehead" +#!/bin/bash -e +source lib/functions.sh source site.conf +log "Stopping bridgehead" + cd ${project} docker-compose --env-file ../site-config/${project}.env down diff --git a/uninstall-bridgehead.sh b/uninstall-bridgehead.sh index a8f7b78..d56cb1a 100755 --- a/uninstall-bridgehead.sh +++ b/uninstall-bridgehead.sh @@ -1,14 +1,11 @@ -echo "Stoping systemd services and removing bridgehead" +#!/bin/bash -e source site.conf +source lib/functions.sh -systemctl stop bridgehead@"${project}".service -systemctl stop bridgehead-update@"${project}".timer -systemctl stop bridgehead-update@"${project}".service +echo "Stopping systemd services and removing bridgehead ..." -cd /etc/systemd/system/ -rm bridgehead\@.service -rm bridgehead-update\@.timer -rm bridgehead-update\@.service - -cd - +for i in bridgehead\@.service bridgehead-update\@.timer bridgehead-update\@.service; do + systemctl disable $i --now + rm -v /etc/systemd/system/$i +done diff --git a/update-bridgehead.sh b/update-bridgehead.sh index 9c3290b..2af6156 100755 --- a/update-bridgehead.sh +++ b/update-bridgehead.sh @@ -1,9 +1,7 @@ #!/bin/bash service="bridgehead" -# Creates logs -log() { - echo "$(date +'%Y-%m-%d %T')" "$1:" "$2" -} + +source lib/functions.sh log "INFO" "Checking for updates of $service" # check prerequisites