ansible-role-zammad/templates/zammad-updater.j2

57 lines
1.8 KiB
Text
Raw Normal View History

2021-10-30 01:35:25 +02:00
#!/bin/bash
# {{ ansible_managed }}
2021-10-30 01:35:25 +02:00
set -eu
RUBY_VERSION=$(cat {{ zammad_home }}/.ruby-version)
RUBY_INSTALLED_VERSIONS=$(rbenv version | grep $RUBY_VERSION | cut -d ' ' -f2)
2021-10-30 01:35:25 +02:00
echo "Stoppe Monit-Monitoring..."
2023-05-19 11:59:02 +02:00
monit unmonitor {{ zammad_websocket_service | splitext | first }}
monit unmonitor {{ zammad_rails_service | splitext | first }}
monit unmonitor {{ zammad_worker_service | splitext | first }}
2021-10-30 01:35:25 +02:00
echo "Wechsle Verzeichnis..."
cd {{ zammad_home }}
echo "Leere Rails Cache..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Cache.clear"
echo "Aktualisiere Git-Repository..."
git pull
2022-06-28 20:37:26 +02:00
if [ -n "$RUBY_INSTALLED_VERSIONS" ]; then
echo "Aktualisiere Ruby-Version..."
sudo -u {{ zammad_user }} rbenv install "$RUBY_VERSION"
fi
echo "Aktualisiere bundler..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec gem install bundler
2021-10-30 01:35:25 +02:00
echo "Aktualisiere Ruby-Pakete..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle install --without test development mysql
echo "Stoppe Zammad..."
2023-05-19 11:59:02 +02:00
systemctl stop {{ zammad_service }}
2021-10-30 01:35:25 +02:00
echo "Migriere Datenbank..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle exec rake db:migrate
echo "Assets vorkompilieren..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle exec rake assets:precompile
echo "Synchronisiere Translation-Dateien..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Locale.sync"
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec rails r "Translation.sync"
2021-10-30 01:35:25 +02:00
echo "Starte Zammad..."
2023-05-19 11:59:02 +02:00
systemctl start {{ zammad_service }}
2021-10-30 01:35:25 +02:00
sleep 20
echo "Starte Monit-Monitoring..."
2023-05-19 11:59:02 +02:00
monit monitor {{ zammad_websocket_service | splitext | first }}
monit monitor {{ zammad_rails_service | splitext | first }}
monit monitor {{ zammad_worker_service | splitext | first }}
2021-10-30 01:35:25 +02:00
echo "Alles erledigt."