mirror of
https://github.com/YunoHost-Apps/mopidy_ynh.git
synced 2024-09-03 19:46:21 +02:00
110 lines
3.5 KiB
Bash
110 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
ynh_secure_remove "$install_dir/env"
|
|
|
|
# Legacy settings
|
|
if [ -n "${mpd_port:-}" ]; then
|
|
if [ "$mpd_port" -eq 0 ]; then
|
|
mpd_ext=0
|
|
else
|
|
mpd_ext=1
|
|
fi
|
|
ynh_app_setting_set --app="$app" --key=mpd_ext --value="$mpd_ext"
|
|
ynh_app_setting_delete --app="$app" --key=mpd_port
|
|
fi
|
|
|
|
if [ -z "${mpd_state:-}" ]; then
|
|
mpd_state="${boolstr[mpd_ext]}"
|
|
ynh_app_setting_set --app="$app" --key=mpd_state --value="$mpd_state"
|
|
fi
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="stop"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
_mopidy_install
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..."
|
|
|
|
ynh_add_config --template="../conf/app.conf" --destination="$install_dir/$app.conf"
|
|
|
|
chmod 400 "$install_dir/$app.conf"
|
|
chown "$app:$app" "$install_dir/$app.conf"
|
|
|
|
#=================================================
|
|
# PROVIDE ADDITIONAL SHELL COMMAND
|
|
#=================================================
|
|
ynh_script_progression --message="Provide additional shell comand..."
|
|
|
|
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
|
|
chmod +x "$cmd_file"
|
|
|
|
#=================================================
|
|
# 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
|
|
if [ "$mpd_ext" -eq 1 ]; then
|
|
yunohost service add "$app" --description="Mopidy music server" --needs_exposed_ports="$port_mpd"
|
|
else
|
|
yunohost service add "$app" --description="Mopidy music server"
|
|
fi
|
|
|
|
#=================================================
|
|
# OPEN PORT
|
|
#=================================================
|
|
if [ "$mpd_ext" -eq 1 ]; then
|
|
ynh_script_progression --message="Opening MPD-port $port_mpd..." --weight=1
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP "$port_mpd"
|
|
fi
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="start"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|