mirror of
https://github.com/YunoHost-Apps/acropolis_ynh.git
synced 2024-09-03 18:06:22 +02:00
110 lines
4.5 KiB
Bash
110 lines
4.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source ynh_add_swap
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="${app}-web" --action="stop" --log_path=systemd
|
|
ynh_systemd_action --service_name="${app}-sidekiq" --action="stop" --log_path=systemd
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
ynh_remove_extra_repo
|
|
ynh_app_setting_delete --app="$app" --key=redis_namespace
|
|
ynh_app_setting_delete --app="$app" --key=secret_key_base
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Updating Ruby..." --weight=1
|
|
|
|
ynh_exec_warn_less ynh_install_ruby --ruby_version="$RUBY_VERSION"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/database.yml config/diaspora.toml"
|
|
|
|
mkdir -p "$install_dir/tmp/pids"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
|
|
|
ynh_add_config --template="database.yml.example" --destination="$install_dir/config/database.yml"
|
|
ynh_add_config --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml"
|
|
|
|
chmod 400 "$install_dir/config/database.yml"
|
|
chmod 400 "$install_dir/config/diaspora.toml"
|
|
chown "$app:$app" "$install_dir/config/database.yml"
|
|
chown "$app:$app" "$install_dir/config/diaspora.toml"
|
|
|
|
#=================================================
|
|
# INSTALLING RUBY AND BUNDLER
|
|
#=================================================
|
|
ynh_script_progression --message="Building $app..."
|
|
|
|
pushd "$install_dir"
|
|
ynh_use_ruby
|
|
ynh_gem install bundler:1.17.3 --no-document
|
|
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config deployment 'true'
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config without 'development test'
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle install --full-index --with postgresql
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:clean
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:precompile
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake db:migrate
|
|
popd
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="$app-web" --template="acropolis-web.service"
|
|
yunohost service add "$app-web" --description="$app web service"
|
|
|
|
ynh_add_systemd_config --service="$app-sidekiq" --template="acropolis-sidekiq.service"
|
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --non-append
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="${app}-web" --action="start" --log_path=systemd --line_match="listening on"
|
|
ynh_systemd_action --service_name="${app}-sidekiq" --action="start" --log_path=systemd --line_match="Booted Rails"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|