1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/tube_ynh.git synced 2024-09-04 01:46:11 +02:00
tube_ynh/scripts/upgrade
Éric Gaspar fb7fcd981c fix
2023-04-02 22:43:33 +02:00

113 lines
3.6 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If max_upload_size doesn't exist, create it
if [ -z "${max_upload_size:-}" ]; then
max_upload_size=100
ynh_app_setting_set --app=$app --key=max_upload_size --value=$max_upload_size
fi
# If feed_title doesn't exist, create it
if [ -z "${feed_title:-}" ]; then
feed_title="Feed title"
ynh_app_setting_set --app=$app --key=feed_title --value=$feed_title
fi
# If feed_description doesn't exist, create it
if [ -z "${feed_description:-}" ]; then
feed_description="Feed description"
ynh_app_setting_set --app=$app --key=feed_description --value=$feed_description
fi
# If author_name doesn't exist, create it
if [ -z "${author_name:-}" ]; then
author_name="Author Name"
ynh_app_setting_set --app=$app --key=author_name --value=$author_name
fi
# If author_email doesn't exist, create it
if [ -z "${author_email:-}" ]; then
author_email="author@somewhere.example"
ynh_app_setting_set --app=$app --key=author_email --value=$author_email
fi
# If copyright_text doesn't exist, create it
if [ -z "${copyright_text:-}" ]; then
copyright_text="Copyright Text"
ynh_app_setting_set --app=$app --key=copyright_text --value=$copyright_text
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
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" --keep="config.json"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x "$install_dir/tube"
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS, ...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
yunohost service add $app --description="Video Sharing App" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last