41 lines
1.2 KiB
Django/Jinja
41 lines
1.2 KiB
Django/Jinja
#!/bin/bash
|
|
# {{ ansible_managed }}
|
|
|
|
set -eu
|
|
|
|
LSTU_PATH={{ lstu.path }}
|
|
INSTALLED_VERSION=$(cd $LSTU_PATH && git for-each-ref --sort=-taggerdate --count=1 --format '%(tag)' refs/tags)
|
|
LATEST_VERSION=$(curl -s {{ lstu_api_url }} | jq '.[]' | jq -r '.name' | head -1)
|
|
LSTU_CONF_TEMPLATE={{ lstu.path }}/lstu.conf.template
|
|
|
|
if [ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]; then
|
|
echo "Lstu ist bereits aktuell."
|
|
exit 0
|
|
else
|
|
echo "Deaktiviere Monitoring..."
|
|
monit unmonitor {{ lstu_monit_name }}
|
|
|
|
echo "Stoppe Dienst..."
|
|
systemctl stop {{ lstu_service }}
|
|
|
|
echo "Aktualisiere Git-Repository..."
|
|
cd "$LSTU_PATH"
|
|
git pull
|
|
git checkout tags/"$LATEST_VERSION"
|
|
|
|
echo "Starte Dienst..."
|
|
systemctl start {{ lstu_service }}
|
|
sleep 10
|
|
|
|
echo "Aktiviere Monitoring..."
|
|
monit monitor {{ lstu_monit_name }}
|
|
sleep 10
|
|
monit status {{ lstu_monit_name }}
|
|
|
|
if [ "$(md5sum $LSTU_CONF_TEMPLATE)" == "$(cat $LSTU_CONF_TEMPLATE.md5)" ]; then
|
|
echo "Keine Aenderungen am Konfigurationstemplate"
|
|
else
|
|
echo "Es gibt Aenderungen an der lstu.conf.template." | mail -s "Lstu-Update: Nacharbeiten notwendig" lstu@admin.systemausfall.org
|
|
fi
|
|
md5sum "$LSTU_CONF_TEMPLATE" > "$LSTU_CONF_TEMPLATE".md5
|
|
fi
|