diff --git a/README.md b/README.md index 937bc1a..a7f2da8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you have constrained bandwidth, you may set an upper limit for the bit rate o In addition to being a streaming media server, Airsonic works very well as a local jukebox. The intuitive web interface, as well as search and index facilities, are optimized for efficient browsing through large media libraries. Airsonic also comes with an integrated Podcast receiver, with many of the same features as you find in iTunes. -**Shipped version:** 10.4.0 +**Shipped version:** 10.4.1 ## Screenshots diff --git a/conf/airsonic.properties b/conf/airsonic.properties index 53917f7..c2eeb96 100644 --- a/conf/airsonic.properties +++ b/conf/airsonic.properties @@ -7,3 +7,6 @@ LdapSearchFilter=(uid={0}) #LdapManagerPassword= # Automatically create users comming from Yunohost in Airsonic LdapAutoShadowing=true +GettingStartedEnabled=false +PodcastFolder=/home/yunohost.multimedia/share/Podcasts +PlaylistFolder=/home/yunohost.multimedia/share/Playlists diff --git a/conf/app.src b/conf/app.src index 7d900aa..860cccd 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/airsonic/airsonic/releases/download/v10.4.0/airsonic.war -SOURCE_SUM=0842a1fc4380cbe75e40dcb94e40332222b816514bd8ad250501d472210894d4 +SOURCE_URL=https://github.com/airsonic/airsonic/releases/download/v10.4.1/airsonic.war +SOURCE_SUM=1d3ee9811ecbabbf9e2cfb63bd936bc238fe75dbcd223a87f3fab18b7a2a75a3 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=false SOURCE_IN_SUBDIR=false diff --git a/manifest.json b/manifest.json index b029efa..6a4ff09 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Airsonic is an open source, web-based media server.", "fr": "Airsonic est un server multimedia open-source." }, - "version": "10.4.0~ynh1", + "version": "10.4.1~ynh1", "url": "http://airsonic.github.io", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index ad0b3bd..1b0b660 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,3 +18,45 @@ pkg_dependencies="openjdk-8-jre ffmpeg" #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Install or update the main directory yunohost.multimedia +# +# usage: ynh_multimedia_build_main_dir +ynh_multimedia_build_main_dir () { + local ynh_media_release="v1.2" + local checksum="806a827ba1902d6911095602a9221181" + + # Download yunohost.multimedia scripts + wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + + # Check the control sum + echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ + || ynh_die "Corrupt source" + + # Check if the package acl is installed. Or install it. + ynh_package_is_installed 'acl' \ + || ynh_package_install acl + + # Extract + mkdir yunohost.multimedia-master + tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 + ./yunohost.multimedia-master/script/ynh_media_build.sh +} + +# Add a directory in yunohost.multimedia +# This "directory" will be a symbolic link to a existing directory. +# +# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" +# +# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. +# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" +ynh_multimedia_addfolder () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) + local source_dir + local dest_dir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" +} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 603cdd5..b640dd7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -38,7 +37,7 @@ service_config=$(ynh_app_setting_get --app=$app --key=service_config) #================================================= 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" +ynh_systemd_action --service_name=$app --action="stop" #================================================= # BACKUP THE APP MAIN DIR @@ -71,12 +70,18 @@ ynh_script_progression --message="Backing up systemd configuration..." --weight= ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="$service_config" +#================================================= +# BACKUP DATA +#================================================= + +ynh_backup --src_path="/home/yunohost.airsonic" --is_big + #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=12 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 53254ea..88db807 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -54,7 +54,7 @@ fi #================================================= 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" +ynh_systemd_action --service_name=$app --action="stop" #================================================= # MODIFY URL IN NGINX CONF diff --git a/scripts/install b/scripts/install index 33e7a99..7c27ce8 100644 --- a/scripts/install +++ b/scripts/install @@ -98,6 +98,28 @@ ynh_system_user_create --username=$app #================================================= # SPECIFIC SETUP +#================================================= +# CREATE DIRECTORIES +#================================================= + +mkdir -p /home/yunohost.airsonic/{Podcasts,Playlists} + +#================================================= +# SECURING FILES AND DIRECTORIES +#================================================= + +chown -R $app:www-data /home/yunohost.airsonic/ +chmod -R 764 /home/yunohost.airsonic + +#================================================= +# YUNOHOST MULTIMEDIA INTEGRATION +#================================================= +ynh_script_progression --message="Adding multimedia directories..." --weight=3 + +ynh_multimedia_build_main_dir +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Podcasts" --dest_dir="share/Podcasts" +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Playlists" --dest_dir="share/Playlists" + #================================================= # ENABLE "TRANSCODE" #================================================= @@ -231,6 +253,19 @@ then ynh_app_setting_delete --app=$app --key=skipped_uris fi +#================================================= +# USE MULTIMEDIA +#================================================= +ynh_systemd_action --service_name=$app --action="stop" + +# Use multimedia folder +ynh_replace_string --match_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/var/music','Music'" --replace_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/home/yunohost.multimedia/share/Music','YunoHost Music'" --target_file="$final_path/db/airsonic.script" + +ynh_script_progression --message="Restarting a systemd service..." --weight=12 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 79a50bc..78f741b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -90,9 +90,6 @@ fi # REMOVE FILES #================================================= -# Remove the log files -ynh_secure_remove --file="/var/log/$app/" - ynh_secure_remove --file="$service_config" #================================================= diff --git a/scripts/restore b/scripts/restore index 61a9ed8..ebe5684 100644 --- a/scripts/restore +++ b/scripts/restore @@ -130,6 +130,30 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/ ynh_restore_file --origin_path="/etc/logrotate.d/$app" +#================================================= +# RESTORE DATA +#================================================= + +# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. +ynh_restore_file --origin_path="/home/yunohost.airsonic" --not_mandatory + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +mkdir -p /home/yunohost.airsonic/{Podcasts,Playlists} +chown -R $app:www-data /home/yunohost.airsonic/ +chmod -R 764 /home/yunohost.airsonic + +#================================================= +# YUNOHOST MULTIMEDIA INTEGRATION +#================================================= +ynh_script_progression --message="Adding multimedia directories..." --weight=3 + +ynh_multimedia_build_main_dir +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Podcasts" --dest_dir="share/Podcasts" +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Playlists" --dest_dir="share/Playlists" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 84ece31..bb53d22 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,8 +79,7 @@ ynh_abort_if_errors #================================================= 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" - +ynh_systemd_action --service_name=$app --action="stop" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -118,6 +117,36 @@ ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE +#================================================= +# CREATE DIRECTORIES +#================================================= + +mkdir -p /home/yunohost.airsonic/{Podcasts,Playlists} + +#================================================= +# SECURING FILES AND DIRECTORIES +#================================================= + +chown -R $app:www-data /home/yunohost.airsonic/ +chmod -R 764 /home/yunohost.airsonic + +#================================================= +# YUNOHOST MULTIMEDIA INTEGRATION +#================================================= +ynh_script_progression --message="Adding multimedia directories..." --weight=3 + +ynh_multimedia_build_main_dir +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Podcasts" --dest_dir="share/Podcasts" +ynh_multimedia_addfolder --source_dir="/home/yunohost.airsonic/Playlists" --dest_dir="share/Playlists" + +if ! grep -q "PodcastFolder" $final_path/airsonic.properties; then + echo "PodcastFolder=/home/yunohost.multimedia/share/Podcasts" >> $final_path/airsonic.properties +fi + +if ! grep -q "PlaylistFolder" $final_path/airsonic.properties; then + echo "PlaylistFolder=/home/yunohost.multimedia/share/Playlists" >> $final_path/airsonic.properties +fi + #================================================= # ENABLE "TRANSCODE" #================================================= @@ -202,6 +231,19 @@ ynh_script_progression --message="Starting a systemd service..." --weight=12 ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in" +# Use multimedia folder if needed +if ! grep -q "/home/yunohost.multimedia/share/Music" $final_path/db/airsonic.script; then + ynh_systemd_action --service_name=$app --action="stop" + + # Use multimedia folder + ynh_replace_string --match_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/var/music','Music'" --replace_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/home/yunohost.multimedia/share/Music','YunoHost Music'" --target_file="$final_path/db/airsonic.script" + + ynh_script_progression --message="Restarting a systemd service..." --weight=12 + + # Start a systemd service + ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in" +fi + #================================================= # RELOAD NGINX #=================================================