1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/airsonic_ynh.git synced 2024-09-03 18:06:14 +02:00

Add multimedia folders

This commit is contained in:
Kay0u 2019-10-07 16:02:06 +02:00
parent 78c81c6e71
commit 3a5676cfe0
No known key found for this signature in database
GPG key ID: 7FF262C033518333
6 changed files with 139 additions and 0 deletions

View file

@ -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

View file

@ -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"
}

View file

@ -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
#=================================================

View file

@ -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"
#=================================================

View file

@ -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
#=================================================

View file

@ -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"
#=================================================