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

56 lines
1.6 KiB
Django/Jinja

#!/bin/bash
# {{ ansible_managed }}
set -eu
RUBY_VERSION=$(cat {{ zammad_home }}/.ruby-version)
RUBY_INSTALLED_VERSIONS=$(rbenv version | grep $RUBY_VERSION | cut -d ' ' -f2)
echo "Stoppe Monit-Monitoring..."
monit unmonitor zammad-websocket
monit unmonitor zammad-rails
monit unmonitor zammad-scheduler
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
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
echo "Aktualisiere Ruby-Pakete..."
sudo -u {{ zammad_user }} RAILS_ENV=production rbenv exec bundle install --without test development mysql
echo "Stoppe Zammad..."
systemctl stop zammad.service
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"
echo "Starte Zammad..."
systemctl start zammad.service
sleep 20
echo "Starte Monit-Monitoring..."
monit monitor zammad-websocket
monit monitor zammad-rails
monit monitor zammad-scheduler
echo "Alles erledigt."