diff --git a/scripts/_common.sh b/scripts/_common.sh index a24a23d..4a86d89 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -60,3 +60,14 @@ ynh_multimedia_addfolder () { ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" } + +# Grant write access to multimedia directories to a specified user +# +# usage: ynh_multimedia_addaccess user_name +# +# | arg: user_name - User to be granted write access +ynh_multimedia_addaccess () { + local user_name=$1 + groupadd -f multimedia + usermod -a -G multimedia $user_name +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index a528c5c..c5fef64 100644 --- a/scripts/install +++ b/scripts/install @@ -117,6 +117,8 @@ 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" +# Allow airsonic to write into these directories +ynh_multimedia_addaccess $app #================================================= # ENABLE "TRANSCODE" diff --git a/scripts/restore b/scripts/restore index ebe5684..cad5ecb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -153,6 +153,8 @@ 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" +# Allow airsonic to write into these directories +ynh_multimedia_addaccess $app #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index bb53d22..a01bf84 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -138,6 +138,8 @@ 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" +# Allow airsonic to write into these directories +ynh_multimedia_addaccess $app if ! grep -q "PodcastFolder" $final_path/airsonic.properties; then echo "PodcastFolder=/home/yunohost.multimedia/share/Podcasts" >> $final_path/airsonic.properties