From 09b4c213f6de00dd65c94663a810a872f101b6c1 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 6 Aug 2023 00:43:42 +0200 Subject: [PATCH] kepubify for multi-instance --- scripts/backup | 2 +- scripts/install | 6 +++--- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 18 +++++++++++++----- sources/patches/main-config_sql.py.patch.src | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5bb9056..5a29dca 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,7 +32,7 @@ ynh_backup --src_path="$install_dir" # BACKUP THE KEPUBIFY BINARY #================================================= -ynh_backup --src_path="/opt/kepubify" +ynh_backup --src_path="/opt/kepubify/$app" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 10cea64..65f736d 100755 --- a/scripts/install +++ b/scripts/install @@ -43,7 +43,7 @@ fi #install kepubify converter ynh_script_progression --message="Installing kepubify..." --weight=1 -ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" +ynh_setup_source --dest_dir="/opt/kepubify/$app/" --source_id="kepubify" #================================================= @@ -152,8 +152,8 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi chown -R $app: $install_dir chmod 740 $install_dir -chown -R $app: /opt/kepubify -chmod 770 /opt/kepubify/kepubify +chown -R $app: /opt/kepubify/$app +chmod 770 /opt/kepubify/$app/kepubify #================================================= # SETUP FAIL2BAN diff --git a/scripts/remove b/scripts/remove index d33955b..a1944a7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -48,7 +48,7 @@ fi # Remove the data directory if --purge option is used ynh_script_progression --message="Removing kepubify directory..." --weight=1 -ynh_secure_remove --file="/opt/kepubify" +ynh_secure_remove --file="/opt/kepubify/$app" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 7ff7f48..078c8f3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ ynh_restore_file --origin_path="$install_dir" # RESTORE THE KEPUBIFY BINARIES #================================================= ynh_script_progression --message="Restoring Kepubify..." --weight=1 -ynh_restore_file --origin_path="/opt/kepubify" +ynh_restore_file --origin_path="/opt/kepubify/$app" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 40452d2..95be743 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,11 +79,19 @@ fi #Adding kepubify converter if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings") ]; then - eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\"" + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\"" fi -if [ ! -d /opt/kepubify ]; then - ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" - chmod 770 /opt/kepubify/kepubify +if [ ! -d /opt/kepubify/$app ]; then + ynh_setup_source --dest_dir="/opt/kepubify/$app" --source_id="kepubify" + chmod 770 /opt/kepubify/$app/kepubify +fi + +#Change kepubify to new path (for multiinstance +if [ -f /opt/kepubify/kepubify ]; then + rm /opt/kepubify/kepubify +fi +if sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings" | grep -xq "/opt/kepubify/kepubify" ; then + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\"" fi #================================================= @@ -214,7 +222,7 @@ ynh_add_systemd_config # Set permissions on app files chown -R $app: $install_dir -chown -R $app: /opt/kepubify +chown -R $app: /opt/kepubify/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/sources/patches/main-config_sql.py.patch.src b/sources/patches/main-config_sql.py.patch.src index 903215d..6ea77a6 100644 --- a/sources/patches/main-config_sql.py.patch.src +++ b/sources/patches/main-config_sql.py.patch.src @@ -55,7 +55,7 @@ config_ldap_group_name = Column(String, default='calibreweb') - config_kepubifypath = Column(String, default=None) -+ config_kepubifypath = Column(String, default='/opt/kepubify/kepubify') ++ config_kepubifypath = Column(String, default='/opt/kepubify/__APP__/kepubify') config_converterpath = Column(String, default=None) config_calibre = Column(String) config_rarfile_location = Column(String, default=None)