mirror of
https://github.com/YunoHost-Apps/minidlna_ynh.git
synced 2024-09-03 19:36:34 +02:00
108 lines
4.2 KiB
Bash
108 lines
4.2 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)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# If overwrite_settings doesn't exist, create it
|
|
if [ -z "${overwrite_settings:-}" ]; then
|
|
overwrite_settings=1
|
|
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
|
|
fi
|
|
|
|
# If root_container doesn't exist, create it
|
|
if [ -z "${root_container:-}" ]; then
|
|
root_container="B"
|
|
ynh_app_setting_set --app=$app --key=root_container --value=$root_container
|
|
fi
|
|
|
|
# If friendly_name doesn't exist, create it
|
|
if [ -z "${friendly_name:-}" ]; then
|
|
friendly_name="YunoHost DLNA"
|
|
ynh_app_setting_set --app=$app --key=friendly_name --value=$friendly_name
|
|
fi
|
|
|
|
# If version exists, remove the backport source list, as it's no longer used.
|
|
if [ -n "${version:-}" ]; then
|
|
ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list"
|
|
ynh_app_setting_delete --app=$app --key=version
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# UPGRADE THE YUNOHOST.MULTIMEDIA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading the yunohost.multimedia directory..." --weight=3
|
|
|
|
ynh_multimedia_build_main_dir
|
|
|
|
#=================================================
|
|
# INCREASE INOTIFY'S LIMITS
|
|
#=================================================
|
|
ynh_script_progression --message="Increasing inotify's limits..." --weight=2
|
|
|
|
# Increase the maximum number of files inotify can monitor.
|
|
cp -a ../conf/90-inotify_minidlna.conf /etc/sysctl.d/
|
|
# Then, reload the kernel configuration.
|
|
if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options.
|
|
then
|
|
sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf
|
|
fi
|
|
|
|
#=================================================
|
|
# CONFIGURE MINIDLNA
|
|
#=================================================
|
|
ynh_script_progression --message="Reconfiguring MiniDLNA..." --weight=2
|
|
|
|
# Overwrite the settings config file only if it's allowed
|
|
if [ $overwrite_settings -eq 1 ]
|
|
then
|
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
|
ynh_backup_if_checksum_is_different --file="/etc/minidlna.conf"
|
|
|
|
ynh_replace_string --match_string="^#*media_dir=.*" --replace_string="media_dir=/home/yunohost.multimedia/share" --target_file=/etc/minidlna.conf
|
|
ynh_replace_string --match_string="^#*port=.*" --replace_string="port=$port" --target_file=/etc/minidlna.conf
|
|
ynh_replace_string --match_string="^#*friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file=/etc/minidlna.conf
|
|
ynh_replace_string --match_string="^#*root_container=.*" --replace_string="root_container=$root_container" --target_file=/etc/minidlna.conf
|
|
ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links=yes" --target_file=/etc/minidlna.conf
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
ynh_store_file_checksum --file="/etc/minidlna.conf"
|
|
fi
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add $app --log="/var/log/$app.log" --needs_exposed_ports="1900"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=7
|
|
|
|
ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|