mirror of
https://github.com/YunoHost-Apps/UMS_ynh.git
synced 2024-10-01 13:35:01 +02:00
117 lines
4.5 KiB
Bash
117 lines
4.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
upstream_version=$(ynh_app_upstream_version)
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
#move home folder from previous /home/app to /home/yunohost.app/$app
|
|
#has to be after backup, otherwise backup will not find home folder and will fail
|
|
if [ ! $(getent passwd $app | cut -d: -f6 | grep yunohost.app) ]
|
|
then
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
usermod -m -d /home/yunohost.app/$app $app
|
|
fi
|
|
|
|
#10.17.0, 10.17.1 & 10.16.0 had a bug that overwrite the media path at startup of the service.
|
|
#https://github.com/UniversalMediaServer/UniversalMediaServer/issues/2864
|
|
#This will reinitialize it to /home/yunohost.multimedia/share
|
|
current_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")
|
|
if [ $current_version == "10.17.0" ] || [ $current_version == "10.16.0" ]
|
|
then
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
ynh_replace_string --match_string="folders =/opt/yunohost/$app,/home/yunohost.app/$app" \
|
|
--replace_string="folders=/home/yunohost.multimedia/share" \
|
|
--target_file="/home/yunohost.app/$app/.config/UMS/UMS.conf"
|
|
ynh_replace_string --match_string="folders_monitored =/opt/yunohost/$app,/home/yunohost.app/$app" \
|
|
--replace_string="folders_monitored=/home/yunohost.multimedia/share" \
|
|
--target_file="/home/yunohost.app/$app/.config/UMS/UMS.conf"
|
|
fi
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=5
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
fi
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R root:$app "$install_dir"
|
|
chown root:$app "$install_dir/UMS.sh"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config "port_web"
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
|
|
#=================================================
|
|
# SETUP LOGROTATE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --non-append
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
|
|
|
|
yunohost service add $app --description="A DLNA, UPnP and HTTP(S) Media Server." --log=/var/log/$app/$app.log --needs_exposed_ports $port_rend
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|