From 3a5676cfe0e05ec822be05918336bfdbaddb830f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 7 Oct 2019 16:02:06 +0200 Subject: [PATCH 1/6] Add multimedia folders --- conf/airsonic.properties | 3 +++ scripts/_common.sh | 42 ++++++++++++++++++++++++++++++++++++++++ scripts/backup | 6 ++++++ scripts/install | 27 ++++++++++++++++++++++++++ scripts/restore | 24 +++++++++++++++++++++++ scripts/upgrade | 37 +++++++++++++++++++++++++++++++++++ 6 files changed, 139 insertions(+) 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/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..3b5405a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -71,6 +71,12 @@ 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 #================================================= diff --git a/scripts/install b/scripts/install index 33e7a99..bd685c4 100644 --- a/scripts/install +++ b/scripts/install @@ -98,6 +98,33 @@ 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" + +# Use multimedia folder +echo "INSERT INTO MUSIC_FOLDER VALUES(1,'/home/yunohost.multimedia/share/Music','YunoHost Music',TRUE)" >> $final_path/db/airsonic.script +# Remove the default folder +ynh_replace_string --match_string="0,'/var/music','Music'" --replace_string="" --target_file="$final_path/db/airsonic.script" + #================================================= # ENABLE "TRANSCODE" #================================================= 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..8c710ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,6 +118,43 @@ 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 + +# Use multimedia folder if needed +if ! grep -q "/home/yunohost.multimedia/share/Music" $final_path/db/airsonic.script; then + echo "INSERT INTO MUSIC_FOLDER VALUES(1,'/home/yunohost.multimedia/share/Music','YunoHost Music',TRUE)" >> $final_path/db/airsonic.script + # Remove the default folder + ynh_replace_string --match_string="0,'/var/music','Music'" --replace_string="" --target_file="$final_path/db/airsonic.script" +fi + #================================================= # ENABLE "TRANSCODE" #================================================= From f7cbd10a90f70037c746b803204aaa3d4e9d7477 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 7 Oct 2019 16:05:55 +0200 Subject: [PATCH 2/6] Bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b029efa..bc3787f 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.0~ynh2", "url": "http://airsonic.github.io", "license": "GPL-3.0-or-later", "maintainer": { From 02d20eda6e492d6cc1638bffd8fb247363a97a32 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 7 Oct 2019 16:23:10 +0200 Subject: [PATCH 3/6] fix install --- scripts/install | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index bd685c4..7c27ce8 100644 --- a/scripts/install +++ b/scripts/install @@ -120,11 +120,6 @@ 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" -# Use multimedia folder -echo "INSERT INTO MUSIC_FOLDER VALUES(1,'/home/yunohost.multimedia/share/Music','YunoHost Music',TRUE)" >> $final_path/db/airsonic.script -# Remove the default folder -ynh_replace_string --match_string="0,'/var/music','Music'" --replace_string="" --target_file="$final_path/db/airsonic.script" - #================================================= # ENABLE "TRANSCODE" #================================================= @@ -258,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 #================================================= From b9c2eb6710b7e2380baa4104323861045c8c2b3c Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 7 Oct 2019 16:47:35 +0200 Subject: [PATCH 4/6] fix log_path --- scripts/backup | 7 +++---- scripts/change_url | 2 +- scripts/remove | 3 --- scripts/upgrade | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/backup b/scripts/backup index 3b5405a..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 @@ -82,7 +81,7 @@ ynh_backup --src_path="/home/yunohost.airsonic" --is_big #================================================= 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/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/upgrade b/scripts/upgrade index 8c710ae..c2fe124 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 #================================================= From e00fa3096d04e956eca9a118b2f3f2ab5d2de8ff Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 7 Oct 2019 19:26:15 +0200 Subject: [PATCH 5/6] Fix upgrade --- scripts/upgrade | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c2fe124..bb53d22 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -147,13 +147,6 @@ if ! grep -q "PlaylistFolder" $final_path/airsonic.properties; then echo "PlaylistFolder=/home/yunohost.multimedia/share/Playlists" >> $final_path/airsonic.properties fi -# Use multimedia folder if needed -if ! grep -q "/home/yunohost.multimedia/share/Music" $final_path/db/airsonic.script; then - echo "INSERT INTO MUSIC_FOLDER VALUES(1,'/home/yunohost.multimedia/share/Music','YunoHost Music',TRUE)" >> $final_path/db/airsonic.script - # Remove the default folder - ynh_replace_string --match_string="0,'/var/music','Music'" --replace_string="" --target_file="$final_path/db/airsonic.script" -fi - #================================================= # ENABLE "TRANSCODE" #================================================= @@ -238,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 #================================================= From 41e12f8e98dddd5f284206586c393aa16c73bad7 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sun, 27 Oct 2019 18:39:47 +0900 Subject: [PATCH 6/6] 10.4.1 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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/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 bc3787f..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~ynh2", + "version": "10.4.1~ynh1", "url": "http://airsonic.github.io", "license": "GPL-3.0-or-later", "maintainer": {