From 1c59da75a6c9c9b9ea8856aca8f4cb6a006f4493 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Fri, 28 Dec 2018 16:08:42 +0100 Subject: [PATCH 1/4] Add ynh_multimedia integration - Initial --- scripts/_common.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 4 +++ 2 files changed, 90 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index e578830..12deedc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -87,3 +87,89 @@ ynh_systemd_action() { ynh_clean_check_starting fi } + + +#================================================= +#YNH_MULTIMEDIA +#================================================= + + +# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args + +# Install or update the main directory yunohost.multimedia +# +# usage: ynh_multimedia_build_main_dir +ynh_multimedia_build_main_dir () { + local ynh_media_release="v1.1" + local checksum="9ec4321a92aa2c388af4ee0072735e3e" + + # 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" +} + +# Move a directory in yunohost.multimedia, and replace by a symbolic link +# +# usage: ynh_multimedia_movefolder "Source directory" "Destination directory" +# +# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. +# It will be moved to "Destination directory" +# A symbolic link will replace it. +# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia" +ynh_multimedia_movefolder () { + # 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 --inv --source="$source_dir" --dest="$dest_dir" +} + +# Allow an user to have an write authorisation in multimedia directories +# +# usage: ynh_multimedia_addaccess user_name +# +# | arg: -u, --user_name= - The name of the user which gain this access. +ynh_multimedia_addaccess () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [u]=user_name=) + local user_name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + groupadd -f multimedia + usermod -a -G multimedia $user_name +} + diff --git a/scripts/install b/scripts/install index 90853c0..73a7f1b 100755 --- a/scripts/install +++ b/scripts/install @@ -120,6 +120,7 @@ ynh_add_systemd_config # CREATE FILES AND DIRECTORIES #================================================= + #Check if library folder exists. If not create it if [ ! -e "$calibre_dir" ]; then ynh_print_info "Create calibre library folder $calibre_dir" @@ -134,6 +135,9 @@ if [ ! -e "$calibre_dir"/metadata.db ]; then fi +ynh_multimedia_build_main_dir +ynh_multimedia_addfolder "eBook" "$calibre_dir" + #================================================= # SETUP LOGROTATE From c15a2e1c8858d7591c47ea7f6c0fe078f2d89d59 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Fri, 28 Dec 2018 18:43:25 +0100 Subject: [PATCH 2/4] Activate multi-instance --- README.md | 4 ++-- manifest.json | 2 +- scripts/install | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b6ec921..02ce026 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Alternatively, you may use [COPS](https://github.com/YunoHost-Apps/cops_ynh) whi ## Backup library -By default, backup process will not backup Calibre library (backup_core_only logic). +By default, backup process will not backup Calibre library ([backup_core_only logic](https://yunohost.org/#/backup_fr)). You may activate backup of the library with ``` yunohost app setting calibreweb backup_core_only -v 0 @@ -52,7 +52,7 @@ chmod o+rw path/to/library Developers info ---------------- -Please do your pull request to the [testing branch](https://github.com/Yunohost-Apps/calibreweb_ynh/tree/Testing). +Please do your pull request to the [testing branch](https://github.com/Yunohost-Apps/calibre_ynh/tree/Testing). To try the testing branch, please proceed like that. ``` diff --git a/manifest.json b/manifest.json index 2e24832..598865b 100644 --- a/manifest.json +++ b/manifest.json @@ -16,7 +16,7 @@ "requirements": { "yunohost": ">= 2.7.14" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index 73a7f1b..b235d84 100755 --- a/scripts/install +++ b/scripts/install @@ -135,8 +135,9 @@ if [ ! -e "$calibre_dir"/metadata.db ]; then fi -ynh_multimedia_build_main_dir -ynh_multimedia_addfolder "eBook" "$calibre_dir" +#ynh_multimedia_build_main_dir +#ynh_multimedia_addfolder "eBook" "$calibre_dir" +#ynh_multimedia_addaccess $app #================================================= From 0bfa836f034b62d8c69b5c847d2b0325e832040b Mon Sep 17 00:00:00 2001 From: Krakinou Date: Fri, 28 Dec 2018 18:58:32 +0100 Subject: [PATCH 3/4] Activate check_process for multi-instance --- check_process | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 91fcf3d..1f41b77 100644 --- a/check_process +++ b/check_process @@ -16,8 +16,9 @@ setup_private=1 setup_public=1 upgrade=1 from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341 + upgrade=1 from_commit=03bafd5219544c5d317eaf54182e4122ba63a4ad backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=1 port_already_use=1 (8083) change_url=1 @@ -56,5 +57,6 @@ Notification=none ; commit=3b9c5041e4fa73cb965368379f2b83d076c65341 name=First in progress release of the app 0.9~ynh1 manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& - - \ No newline at end of file + ; commit=03bafd5219544c5d317eaf54182e4122ba63a4ad + name=Release 0.91~ynh2 + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& \ No newline at end of file From d453b1916609c49126f6fecc001691e1585b1dcd Mon Sep 17 00:00:00 2001 From: Krakinou Date: Fri, 28 Dec 2018 20:33:28 +0100 Subject: [PATCH 4/4] Update README.md for multi-instance --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02ce026..abaa53d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre ## Todo -- [ ] Multiinstance +- [X] Multiinstance - [ ] Better Multimedia integration : Integrate in Yunohost.multimedia - [X] Package_check integration - [X] On backup/remove/upgrade : check for database location to update settings