mirror of
https://github.com/YunoHost-Apps/redmine_ynh.git
synced 2024-09-03 20:16:16 +02:00
89 lines
3.3 KiB
Bash
89 lines
3.3 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# UPGRADE DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading 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/configuration.yml config/initializers/secret_token.rb"
|
|
|
|
mkdir -p "$install_dir/files" "$install_dir/log" "$install_dir/tmp" "$install_dir/public/plugin_assets"
|
|
|
|
chmod 750 "$install_dir/files" "$install_dir/log" "$install_dir/tmp" "$install_dir/public/plugin_assets"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# BUILD APP
|
|
#=================================================
|
|
ynh_script_progression --message="Building app..." --weight=1
|
|
|
|
_redmine_ruby_install
|
|
pushd "$install_dir"
|
|
ynh_exec_warn_less bundle exec rake db:migrate RAILS_ENV=production
|
|
popd
|
|
|
|
# Setting up LDAP authentification
|
|
ynh_add_config --template="db-ldap.sql" --destination="$install_dir/config/db-ldap.sql"
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/config/db-ldap.sql"
|
|
ynh_secure_remove --file="$install_dir/config/db-ldap.sql"
|
|
|
|
chmod 750 "$install_dir/public"
|
|
chmod -R o-rwx "$install_dir/public"
|
|
chown -R "$app:www-data" "$install_dir/public"
|
|
|
|
#=================================================
|
|
# 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
|
|
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
|
|
|
# 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" --action="start" --log_path="/var/log/$app/$app.log" --line_match="WEBrick::HTTPServer#start"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|