From 13ba7b2803f7af8e0e2c48e4a60000ebad8960d0 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 30 Dec 2018 12:03:24 +0100 Subject: [PATCH 01/37] Add yunohost_multimedia_1.2 --- README.md | 1 + scripts/_common.sh | 6 +++--- scripts/install | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index abaa53d..1cc2eb8 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre ## Todo - [X] Multiinstance - [ ] Better Multimedia integration : Integrate in Yunohost.multimedia +- [ ] User and possibly LDAP integration - [X] Package_check integration - [X] On backup/remove/upgrade : check for database location to update settings diff --git a/scripts/_common.sh b/scripts/_common.sh index 12deedc..ac230db 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -100,11 +100,11 @@ ynh_systemd_action() { # # usage: ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.1" - local checksum="9ec4321a92aa2c388af4ee0072735e3e" + local ynh_media_release="v1.2" + local checksum="b933c446b4aff8a7619804480c06a879" # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + wget -nv https://github.com/Krakinou/yunohost.multimedia/archive/${ynh_media_release}.tar.gz # Check the control sum echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ diff --git a/scripts/install b/scripts/install index b235d84..6f933d6 100755 --- a/scripts/install +++ b/scripts/install @@ -135,8 +135,7 @@ 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_addaccess $app From c1f803b8d58bbc6d0d2d8c778b838b3b3ff8ed36 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 11:36:30 +0100 Subject: [PATCH 02/37] Commit --- manifest.json | 26 ++++++++++++------------ scripts/_common.sh | 5 +++-- scripts/install | 49 +++++++++++++++++++++++----------------------- 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/manifest.json b/manifest.json index 598865b..3389eab 100644 --- a/manifest.json +++ b/manifest.json @@ -40,18 +40,6 @@ }, "example": "/calibre", "default": "/calibre" - }, - { - "name": "calibre_path", - "ask": { - "en": "Select the folder containing the Calibre library", - "fr": "Choisissez le répertoire contenant la bibliothèque Calibre" - }, - "help": { - "en": "This folder should have read write access. It will be created if it does not exist.", - "fr": "Le répertoire doit être accessible en lecture écriture, il sera créé s'il n'existe pas." - }, - "default": "/home/yunohost.app/calibreweb" }, { "name": "admin", @@ -73,6 +61,7 @@ }, { "name": "language", + "optional": true, "ask": { "en": "Select a default language (you may change it later in the app)", "fr": "Choisissez une langue par défaut (vous pourrez la changer ultérieurement dans l'application)" @@ -82,13 +71,24 @@ }, { "name": "upload", - "type":"boolean", + "type":"boolean", + "optional": true, "ask": { "en": "Do you want to allow uploading of books (you may change it later in the app)?", "fr": "Voulez vous autoriser l'upload de livres (vous pourrez le changer ultérieurement dans l'application)?" }, "default": false }, + { + "name": "public_library", + "type":"boolean", + "optional": true, + "ask": { + "en": "Do you want to allow access to the library to all Yunohost users?", + "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?" + }, + "default": false + }, { "name": "password", "type": "password", diff --git a/scripts/_common.sh b/scripts/_common.sh index ac230db..b1e3fb4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,7 @@ #!/bin/bash -pkg_dependencies="sqlite3 python-pip imagemagick" +PKG_DEPENDENCIES="sqlite3 python-pip imagemagick" +DOSSIER_MEDIA=/home/yunohost.multimedia create_dir=0 @@ -101,7 +102,7 @@ ynh_systemd_action() { # usage: ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir () { local ynh_media_release="v1.2" - local checksum="b933c446b4aff8a7619804480c06a879" + local checksum="806a827ba1902d6911095602a9221181" # Download yunohost.multimedia scripts wget -nv https://github.com/Krakinou/yunohost.multimedia/archive/${ynh_media_release}.tar.gz diff --git a/scripts/install b/scripts/install index 6f933d6..e552210 100755 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,8 @@ ynh_print_OFF pass=$YNH_APP_ARG_PASSWORD ynh_print_ON app=$YNH_APP_INSTANCE_NAME -#removing / at the end for consistency -calibre_dir=${3%/} -upload=$7 +upload=$6 +public_library=$7 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -56,7 +55,7 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app calibre_dir $calibre_dir + #================================================= # STANDARD MODIFICATIONS @@ -80,13 +79,12 @@ ynh_print_info "Downloading sources to $final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_print_info "Installing dependencies and pip packages" -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $PKG_DEPENDENCIES pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= @@ -120,24 +118,30 @@ ynh_add_systemd_config # CREATE FILES AND DIRECTORIES #================================================= +#Logic is as follow : if app is set to be publicly accessible, we will assume that the library should be set in "Share" multimedia directory +# If app is set to be private but access is requested for all user, we will assume the same +# If app is set to be private but access is limited to the admin user, we will set it inside his own multimedia directory. +# Access to the app is managed in the SSOwat part of the script. -#Check if library folder exists. If not create it -if [ ! -e "$calibre_dir" ]; then - ynh_print_info "Create calibre library folder $calibre_dir" - mkdir -p $calibre_dir - chown -R $app:$app $calibre_dir - create_dir=1 +#build multimedia directory +ynh_multimedia_build_main_dir +ynh_multimedia_addaccess $app + +if [ $is_public -eq 1 ]; then #app is public, library is public + calibre_dir=$DOSSIER_MEDIA/Share/eBook +elif [$is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public + calibre_dir=$DOSSIER_MEDIA/Share/eBook +else #app is private, library is private + calibre_dir=$DOSSIER_MEDIA/$admin/eBook fi + #Check if metadata.db file exists. If not create it (empty library) if [ ! -e "$calibre_dir"/metadata.db ]; then cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db chown $app:$app $calibre_dir/* fi - -ynh_multimedia_build_main_dir -#ynh_multimedia_addaccess $app - +ynh_app_setting_set $app calibre_dir $calibre_dir #================================================= # SETUP LOGROTATE @@ -210,6 +214,11 @@ then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set $app unprotected_uris "/" fi +if [ $public_library -eq 0 ]; then + yunohost app addaccess $app -u $admin +fi + + #================================================= # RELOAD NGINX @@ -217,11 +226,3 @@ fi ynh_print_info "Reload nginx and start $app" systemctl reload nginx ynh_systemd_action -l "INFO in server: Starting Gevent server" - -#================================================= -# WARNING FOR READ ACCESS -#================================================= - -if [[ $create_dir = 0 ]] ; then - ynh_print_warn "Please, give required access to $app user to the $calibre_dir folder." -fi \ No newline at end of file From d2a717fec0daebcd9e8c80621aec845870fb2e96 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 20:04:35 +0100 Subject: [PATCH 03/37] Change to LDAP supported version --- conf/app.src | 4 ++-- conf/init_calibre_db_settings | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index c765e11..5b5b484 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ #useless as long as V1.0 not issued -SOURCE_URL=https://github.com/janeczku/calibre-web/archive/d0fd1a46014006138977398ee65f48c98df937e7.zip -SOURCE_SUM=0d297719f32670840fb1fcee52d3e73fa6213127709809d9a232f862d037af03 +SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/calibre-web-masterzip +SOURCE_SUM=3cef8d95f2543cc07f5b2a9975f8633d614d2f02e404e1538353a6bd18f3f405 SOURCE_FORMAT=zip diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index 8dacf91..e84ebce 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,4 +8,7 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_uploading=\'$upload\' \ No newline at end of file +config_uploading=\'$upload\' +config_use_ldap=1 +config_ldap_provider_url=\'localhost:389\' +config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' \ No newline at end of file From d30380a4f8e42eb7d5134475c1fb29529c218b4a Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 20:09:28 +0100 Subject: [PATCH 04/37] typo --- conf/app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/app.src b/conf/app.src index 5b5b484..f7088b4 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ #useless as long as V1.0 not issued -SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/calibre-web-masterzip +SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/calibre-web-master.zip SOURCE_SUM=3cef8d95f2543cc07f5b2a9975f8633d614d2f02e404e1538353a6bd18f3f405 SOURCE_FORMAT=zip From dc279c8e468209f55092516f8d25a77dc156e753 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 20:12:17 +0100 Subject: [PATCH 05/37] typo --- conf/app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/app.src b/conf/app.src index f7088b4..9c71a22 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ #useless as long as V1.0 not issued -SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/calibre-web-master.zip +SOURCE_URL=https://github.com/YunoHost-Apps/calibre_ynh/archive/master.zip SOURCE_SUM=3cef8d95f2543cc07f5b2a9975f8633d614d2f02e404e1538353a6bd18f3f405 SOURCE_FORMAT=zip From c959b0a90b0bff7f5bbb009ce346e987ea9bd0de Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 20:16:15 +0100 Subject: [PATCH 06/37] source update --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 9c71a22..9eecae9 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ #useless as long as V1.0 not issued -SOURCE_URL=https://github.com/YunoHost-Apps/calibre_ynh/archive/master.zip -SOURCE_SUM=3cef8d95f2543cc07f5b2a9975f8633d614d2f02e404e1538353a6bd18f3f405 +SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/82e4f11334444f8650fbf5e0b16a4e8eb70253da.zip +SOURCE_SUM=29f68e6ef88cce19f0f6a2006517c43d93167ad80f13cbe16cdc78b4ea8d52be SOURCE_FORMAT=zip From c5143ba88890ed475a0b4a6597f302dfbfa9c392 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 23:02:02 +0100 Subject: [PATCH 07/37] correct db_settings for ldap --- conf/init_calibre_db_settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index e84ebce..cf39aca 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -9,6 +9,6 @@ config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', config_uploading=\'$upload\' -config_use_ldap=1 +config_use_ldap=\'1\' config_ldap_provider_url=\'localhost:389\' config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' \ No newline at end of file From b1973cd56bfbd436a947f881c55bca2608bc7d90 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 23:10:36 +0100 Subject: [PATCH 08/37] revert config_use_ldap --- conf/init_calibre_db_settings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index cf39aca..ee54396 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,7 +8,7 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_uploading=\'$upload\' -config_use_ldap=\'1\' +config_use_ldap=1 config_ldap_provider_url=\'localhost:389\' -config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' \ No newline at end of file +config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' +config_uploading=\'$upload\' From bba261cf4385cbd0323714203c0d072270a11c84 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 12 Jan 2019 23:13:22 +0100 Subject: [PATCH 09/37] la virgule, mais la virgule! --- conf/init_calibre_db_settings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index ee54396..f600faa 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,7 +8,7 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_use_ldap=1 -config_ldap_provider_url=\'localhost:389\' -config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' +config_use_ldap=1, +config_ldap_provider_url=\'localhost:389\', +config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\', config_uploading=\'$upload\' From 0b15e9c9fecf12fe19d7c65403f23494f4b5d6b2 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 11:57:47 +0100 Subject: [PATCH 10/37] Move to last version --- conf/app.src | 5 ++--- conf/nginx.conf | 13 +++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf/app.src b/conf/app.src index 9eecae9..33e5909 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,3 @@ -#useless as long as V1.0 not issued -SOURCE_URL=https://github.com/Krakinou/calibre-web/archive/82e4f11334444f8650fbf5e0b16a4e8eb70253da.zip -SOURCE_SUM=29f68e6ef88cce19f0f6a2006517c43d93167ad80f13cbe16cdc78b4ea8d52be +SOURCE_URL=https://github.com/janeczku/calibre-web/archive/c527d1f49a2213e523957fd90d814c075bacde89.zip +SOURCE_SUM=61aff733df259382ae53646e5445ac973a0c4fe70e54ec4d3ed63a7f66c4f04f SOURCE_FORMAT=zip diff --git a/conf/nginx.conf b/conf/nginx.conf index 75e244a..64bc976 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,12 +4,13 @@ location __PATH__ { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://localhost:__PORT__; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Scheme $scheme; - proxy_set_header X-Script-Name __PATH__; + proxy_pass http://localhost:__PORT__; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Script-Name __PATH__; + proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; From 72530669dbc76768c0f6c2c681b663b07ee9a773 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 12:33:17 +0100 Subject: [PATCH 11/37] Patch sources --- sources/patches/app-config.patch | 24 +++++++++++ sources/patches/app-ub.patch | 72 ++++++++++++++++++++++++++++++++ sources/patches/app-web.patch | 44 +++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 sources/patches/app-config.patch create mode 100644 sources/patches/app-ub.patch create mode 100644 sources/patches/app-web.patch diff --git a/sources/patches/app-config.patch b/sources/patches/app-config.patch new file mode 100644 index 0000000..c816372 --- /dev/null +++ b/sources/patches/app-config.patch @@ -0,0 +1,24 @@ +--- a/cps/templates/config_edit.html 2019-01-12 09:01:08.000000000 +0100 ++++ b/cps/templates/config_edit.html 2019-01-13 11:21:11.000000000 +0100 +@@ -162,6 +162,21 @@ + + + {% endif %} ++
++ ++ ++
++
++
++ ++ ++
++
++ ++ ++
++
++ + + + diff --git a/sources/patches/app-ub.patch b/sources/patches/app-ub.patch new file mode 100644 index 0000000..5da0e64 --- /dev/null +++ b/sources/patches/app-ub.patch @@ -0,0 +1,72 @@ +--- a/cps/ub.py 2019-01-12 09:01:08.000000000 +0100 ++++ b/cps/ub.py 2019-01-13 11:21:11.000000000 +0100 +@@ -148,6 +148,14 @@ + def __repr__(self): + return '' % self.nickname + ++ #Login via LDAP method ++ @staticmethod ++ def try_login(username, password): ++ conn = get_ldap_connection() ++ conn.simple_bind_s( ++ config.config_ldap_dn.replace("%s", username), ++ password ++ ) + + # Baseclass for Users in Calibre-Web, settings which are depending on certain users are stored here. It is derived from + # User Base (all access methods are declared there) +@@ -306,6 +314,9 @@ + config_use_goodreads = Column(Boolean) + config_goodreads_api_key = Column(String) + config_goodreads_api_secret = Column(String) ++ config_use_ldap = Column(Boolean) ++ config_ldap_provider_url = Column(String) ++ config_ldap_dn = Column(String) + config_mature_content_tags = Column(String) + config_logfile = Column(String) + config_ebookconverter = Column(Integer, default=0) +@@ -379,6 +390,9 @@ + self.config_use_goodreads = data.config_use_goodreads + self.config_goodreads_api_key = data.config_goodreads_api_key + self.config_goodreads_api_secret = data.config_goodreads_api_secret ++ self.config_use_ldap = data.config_use_ldap ++ self.config_ldap_provider_url = data.config_ldap_provider_url ++ self.config_ldap_dn = data.config_ldap_dn + if data.config_mature_content_tags: + self.config_mature_content_tags = data.config_mature_content_tags + else: +@@ -662,13 +676,20 @@ + conn.execute("ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''") + session.commit() + try: ++ session.query(exists().where(Settings.config_use_ldap)).scalar() ++ except exc.OperationalError: ++ conn = engine.connect() ++ conn.execute("ALTER TABLE Settings ADD column `config_use_ldap` INTEGER DEFAULT 0") ++ conn.execute("ALTER TABLE Settings ADD column `config_ldap_provider_url` String DEFAULT ''") ++ conn.execute("ALTER TABLE Settings ADD column `config_ldap_dn` String DEFAULT ''") ++ session.commit() ++ try: + session.query(exists().where(Settings.config_theme)).scalar() + except exc.OperationalError: # Database is not compatible, some rows are missing + conn = engine.connect() + conn.execute("ALTER TABLE Settings ADD column `config_theme` INTEGER DEFAULT 0") + session.commit() + +- + # Remove login capability of user Guest + conn = engine.connect() + conn.execute("UPDATE user SET password='' where nickname = 'Guest' and password !=''") +@@ -778,6 +799,12 @@ + migrate_Database() + clean_database() + ++#get LDAP connection ++def get_ldap_connection(): ++ import ldap ++ conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url)) ++ return conn ++ + # Generate global Settings Object accessible from every file + config = Config() + searched_ids = {} diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch new file mode 100644 index 0000000..f8536d9 --- /dev/null +++ b/sources/patches/app-web.patch @@ -0,0 +1,44 @@ +--- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100 ++++ b/cps/web.py 2019-01-13 11:21:11.000000000 +0100 +@@ -2363,7 +2363,18 @@ + if request.method == "POST": + form = request.form.to_dict() + user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first() +- if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++ if config.config_use_ldap and user: ++ import ldap ++ try: ++ ub.User.try_login(form['username'], form['password']) ++ login_user(user, remember=True) ++ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") ++ return redirect_back(url_for("index")) ++ except ldap.INVALID_CREDENTIALS: ++ ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr) ++ app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) ++ flash(_(u"Wrong Username or Password"), category="error") ++ elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": + login_user(user, remember=True) + flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") + return redirect_back(url_for("index")) +@@ -3088,6 +3099,21 @@ + if "config_ebookconverter" in to_save: + content.config_ebookconverter = int(to_save["config_ebookconverter"]) + ++ #LDAP configuratop, ++ if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": ++ if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: ++ ub.session.commit() ++ flash(_(u'Please enter a LDAP provider and a DN'), category="error") ++ return render_title_template("config_edit.html", content=config, origin=origin, ++ gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, ++ goodreads=goodreads_support, title=_(u"Basic Configuration"), ++ page="config") ++ else: ++ content.config_use_ldap = 1 ++ content.config_ldap_provider_url = to_save["config_ldap_provider_url"] ++ content.config_ldap_dn = to_save["config_ldap_dn"] ++ db_change = True ++ + # Remote login configuration + content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on") + if not content.config_remote_login: From 5f553d72ccc01654a509af5000be1b5aea5a4501 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 15:39:06 +0100 Subject: [PATCH 12/37] Apply new patch for logout --- sources/patches/app-web.patch | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index f8536d9..a941437 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,6 +1,15 @@ --- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100 -+++ b/cps/web.py 2019-01-13 11:21:11.000000000 +0100 -@@ -2363,7 +2363,18 @@ ++++ b/cps/web.py 2019-01-13 15:29:45.000000000 +0100 +@@ -2360,10 +2360,27 @@ + return redirect(url_for('basic_configuration')) + if current_user is not None and current_user.is_authenticated: + return redirect(url_for('index')) ++ auth_user = request.headers.get('X-Remote-User') ++ if auth_user and config.config_use_ldap: ++ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() ++ login_user(user, remember=True) ++ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") ++ return redirect(url_for("index")) if request.method == "POST": form = request.form.to_dict() user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first() @@ -20,7 +29,18 @@ login_user(user, remember=True) flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") return redirect_back(url_for("index")) -@@ -3088,6 +3099,21 @@ +@@ -2384,8 +2401,9 @@ + @login_required + def logout(): + if current_user is not None and current_user.is_authenticated: ++ logout_host = request.headers.get('Host') + logout_user() +- return redirect(url_for('login')) ++ return redirect("https://%servername/yunohost/sso/".replace("%servername", logout_host)) + + + @app.route('/remote/login') +@@ -3088,6 +3106,21 @@ if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) From 2760dea36f8219dd43dab92abca311561420a02c Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 16:16:36 +0100 Subject: [PATCH 13/37] Correct patches w/ vlogout correct install script for tab add new todo --- README.md | 1 + scripts/install | 2 +- sources/patches/app-web.patch | 95 +++++++++++++++++++---------------- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 7f24b66..dc4f95a 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre - [X] Package_check integration - [X] On backup/remove/upgrade : check for database location to update settings - [ ] enable magic link +- [ ] Add cronjob to reload database ## LICENSE diff --git a/scripts/install b/scripts/install index b235d84..182a99d 100755 --- a/scripts/install +++ b/scripts/install @@ -94,7 +94,7 @@ pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= #Cannot use empty string for X-script-name, causes an issue in the python prg if [ $path_url = "/" ] ; then - ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name /$app;" ../conf/nginx.conf + ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name $app;" ../conf/nginx.conf fi # Create a dedicated nginx config diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index a941437..51bd470 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,64 +1,71 @@ ---- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100 -+++ b/cps/web.py 2019-01-13 15:29:45.000000000 +0100 -@@ -2360,10 +2360,27 @@ +--- ./calibre-web-Yunohost_integration/cps/web.py 2019-01-13 16:13:23.000000000 +0100 ++++ ./ori-calibre-web-master/cps/web.py 2019-01-12 09:01:08.000000000 +0100 +@@ -58,8 +58,6 @@ + import server + from reverseproxy import ReverseProxied + +-global vlogout +- + try: + from googleapiclient.errors import HttpError + except ImportError: +@@ -2362,28 +2360,10 @@ return redirect(url_for('basic_configuration')) if current_user is not None and current_user.is_authenticated: return redirect(url_for('index')) -+ auth_user = request.headers.get('X-Remote-User') -+ if auth_user and config.config_use_ldap: -+ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() -+ login_user(user, remember=True) -+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") -+ return redirect(url_for("index")) +- auth_user = request.headers.get('X-Remote-User') +- if auth_user and config.config_use_ldap and not vlogout: +- vlogout = 0 +- user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() +- login_user(user, remember=True) +- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") +- return redirect(url_for("index")) if request.method == "POST": form = request.form.to_dict() user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first() -- if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": -+ if config.config_use_ldap and user: -+ import ldap -+ try: -+ ub.User.try_login(form['username'], form['password']) -+ login_user(user, remember=True) -+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") -+ return redirect_back(url_for("index")) -+ except ldap.INVALID_CREDENTIALS: -+ ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr) -+ app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) -+ flash(_(u"Wrong Username or Password"), category="error") -+ elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": +- if config.config_use_ldap and user: +- import ldap +- try: +- ub.User.try_login(form['username'], form['password']) +- login_user(user, remember=True) +- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") +- return redirect_back(url_for("index")) +- except ldap.INVALID_CREDENTIALS: +- ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr) +- app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) +- flash(_(u"Wrong Username or Password"), category="error") +- elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++ if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": login_user(user, remember=True) flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") return redirect_back(url_for("index")) -@@ -2384,8 +2401,9 @@ +@@ -2404,7 +2384,6 @@ @login_required def logout(): if current_user is not None and current_user.is_authenticated: -+ logout_host = request.headers.get('Host') +- vlogout = 1 logout_user() -- return redirect(url_for('login')) -+ return redirect("https://%servername/yunohost/sso/".replace("%servername", logout_host)) + return redirect(url_for('login')) - - @app.route('/remote/login') -@@ -3088,6 +3106,21 @@ +@@ -3109,21 +3088,6 @@ if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) -+ #LDAP configuratop, -+ if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": -+ if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: -+ ub.session.commit() -+ flash(_(u'Please enter a LDAP provider and a DN'), category="error") -+ return render_title_template("config_edit.html", content=config, origin=origin, -+ gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, -+ goodreads=goodreads_support, title=_(u"Basic Configuration"), -+ page="config") -+ else: -+ content.config_use_ldap = 1 -+ content.config_ldap_provider_url = to_save["config_ldap_provider_url"] -+ content.config_ldap_dn = to_save["config_ldap_dn"] -+ db_change = True -+ +- #LDAP configuratop, +- if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": +- if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: +- ub.session.commit() +- flash(_(u'Please enter a LDAP provider and a DN'), category="error") +- return render_title_template("config_edit.html", content=config, origin=origin, +- gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, +- goodreads=goodreads_support, title=_(u"Basic Configuration"), +- page="config") +- else: +- content.config_use_ldap = 1 +- content.config_ldap_provider_url = to_save["config_ldap_provider_url"] +- content.config_ldap_dn = to_save["config_ldap_dn"] +- db_change = True +- # Remote login configuration content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on") if not content.config_remote_login: From f2a8067c93327d8126ca957ec4220da41a2a9176 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 16:19:08 +0100 Subject: [PATCH 14/37] path correction --- sources/patches/app-web.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index 51bd470..7913803 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,5 +1,5 @@ ---- ./calibre-web-Yunohost_integration/cps/web.py 2019-01-13 16:13:23.000000000 +0100 -+++ ./ori-calibre-web-master/cps/web.py 2019-01-12 09:01:08.000000000 +0100 +--- a/cps/web.py 2019-01-13 16:13:23.000000000 +0100 ++++ b/cps/web.py 2019-01-12 09:01:08.000000000 +0100 @@ -58,8 +58,6 @@ import server from reverseproxy import ReverseProxied From 4e40df22a69c1c10fab5cd320129109ad0c58058 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 19:13:34 +0100 Subject: [PATCH 15/37] Reupload web.patch --- sources/patches/app-web.patch | 88 +++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index 7913803..8be0b4e 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,71 +1,71 @@ ---- a/cps/web.py 2019-01-13 16:13:23.000000000 +0100 -+++ b/cps/web.py 2019-01-12 09:01:08.000000000 +0100 -@@ -58,8 +58,6 @@ +--- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100 ++++ b/cps/web.py 2019-01-13 16:13:23.000000000 +0100 +@@ -58,6 +58,8 @@ import server from reverseproxy import ReverseProxied --global vlogout -- ++global vlogout ++ try: from googleapiclient.errors import HttpError except ImportError: -@@ -2362,28 +2360,10 @@ +@@ -2360,10 +2362,28 @@ return redirect(url_for('basic_configuration')) if current_user is not None and current_user.is_authenticated: return redirect(url_for('index')) -- auth_user = request.headers.get('X-Remote-User') -- if auth_user and config.config_use_ldap and not vlogout: -- vlogout = 0 -- user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() -- login_user(user, remember=True) -- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") -- return redirect(url_for("index")) ++ auth_user = request.headers.get('X-Remote-User') ++ if auth_user and config.config_use_ldap and not vlogout: ++ vlogout = 0 ++ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() ++ login_user(user, remember=True) ++ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") ++ return redirect(url_for("index")) if request.method == "POST": form = request.form.to_dict() user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first() -- if config.config_use_ldap and user: -- import ldap -- try: -- ub.User.try_login(form['username'], form['password']) -- login_user(user, remember=True) -- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") -- return redirect_back(url_for("index")) -- except ldap.INVALID_CREDENTIALS: -- ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr) -- app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) -- flash(_(u"Wrong Username or Password"), category="error") -- elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": -+ if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": +- if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++ if config.config_use_ldap and user: ++ import ldap ++ try: ++ ub.User.try_login(form['username'], form['password']) ++ login_user(user, remember=True) ++ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") ++ return redirect_back(url_for("index")) ++ except ldap.INVALID_CREDENTIALS: ++ ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr) ++ app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) ++ flash(_(u"Wrong Username or Password"), category="error") ++ elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": login_user(user, remember=True) flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") return redirect_back(url_for("index")) -@@ -2404,7 +2384,6 @@ +@@ -2384,6 +2404,7 @@ @login_required def logout(): if current_user is not None and current_user.is_authenticated: -- vlogout = 1 ++ vlogout = 1 logout_user() return redirect(url_for('login')) -@@ -3109,21 +3088,6 @@ +@@ -3088,6 +3109,21 @@ if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) -- #LDAP configuratop, -- if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": -- if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: -- ub.session.commit() -- flash(_(u'Please enter a LDAP provider and a DN'), category="error") -- return render_title_template("config_edit.html", content=config, origin=origin, -- gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, -- goodreads=goodreads_support, title=_(u"Basic Configuration"), -- page="config") -- else: -- content.config_use_ldap = 1 -- content.config_ldap_provider_url = to_save["config_ldap_provider_url"] -- content.config_ldap_dn = to_save["config_ldap_dn"] -- db_change = True -- ++ #LDAP configuratop, ++ if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": ++ if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: ++ ub.session.commit() ++ flash(_(u'Please enter a LDAP provider and a DN'), category="error") ++ return render_title_template("config_edit.html", content=config, origin=origin, ++ gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError, ++ goodreads=goodreads_support, title=_(u"Basic Configuration"), ++ page="config") ++ else: ++ content.config_use_ldap = 1 ++ content.config_ldap_provider_url = to_save["config_ldap_provider_url"] ++ content.config_ldap_dn = to_save["config_ldap_dn"] ++ db_change = True ++ # Remote login configuration content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on") if not content.config_remote_login: From cbdef9bda77b8603953f094ae3f6c125b5969bd2 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 13 Jan 2019 20:57:54 +0100 Subject: [PATCH 16/37] udpate global patches --- sources/patches/app-web.patch | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index 8be0b4e..1145a8d 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,19 +1,20 @@ ---- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100 -+++ b/cps/web.py 2019-01-13 16:13:23.000000000 +0100 +--- ./ori-calibre-web/cps/web.py 2019-01-12 09:01:08.000000000 +0100 ++++ ./calibre-web-Yunohost_integration/cps/web.py 2019-01-13 20:11:57.000000000 +0100 @@ -58,6 +58,8 @@ import server from reverseproxy import ReverseProxied -+global vlogout ++vlogout = 0 + try: from googleapiclient.errors import HttpError except ImportError: -@@ -2360,10 +2362,28 @@ +@@ -2360,10 +2362,29 @@ return redirect(url_for('basic_configuration')) if current_user is not None and current_user.is_authenticated: return redirect(url_for('index')) + auth_user = request.headers.get('X-Remote-User') ++ global vlogout + if auth_user and config.config_use_ldap and not vlogout: + vlogout = 0 + user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first() @@ -39,15 +40,16 @@ login_user(user, remember=True) flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") return redirect_back(url_for("index")) -@@ -2384,6 +2404,7 @@ +@@ -2384,6 +2405,8 @@ @login_required def logout(): if current_user is not None and current_user.is_authenticated: ++ global vlogout + vlogout = 1 logout_user() return redirect(url_for('login')) -@@ -3088,6 +3109,21 @@ +@@ -3088,6 +3111,21 @@ if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) From 05c15e969cd3da6a8fc5fcb018de93485745e879 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 14 Jan 2019 23:31:49 +0100 Subject: [PATCH 17/37] Initial commit for hook --- conf/generate_password_hash.py | 1 + hooks/post_user_create | 52 ++++++++++++++++++++++++++++++++++ hooks/post_user_delete | 37 ++++++++++++++++++++++++ manifest.json | 25 ++++++---------- scripts/install | 13 ++++----- 5 files changed, 103 insertions(+), 25 deletions(-) create mode 100644 hooks/post_user_create create mode 100644 hooks/post_user_delete diff --git a/conf/generate_password_hash.py b/conf/generate_password_hash.py index 6d45018..4778e8c 100644 --- a/conf/generate_password_hash.py +++ b/conf/generate_password_hash.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # Permet de générer le hash pour le password +#Plus utilisé depuis la MAJ 0.92~ynh3 avec LDAP import sys path=sys.argv[2] sys.path.append(path) diff --git a/hooks/post_user_create b/hooks/post_user_create new file mode 100644 index 0000000..472d734 --- /dev/null +++ b/hooks/post_user_create @@ -0,0 +1,52 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers +#reste à insérer la gestion des répertoires + +app=calibreweb +username=$1 +mail=$2 +pass_clear=$3 +final_path=$(ynh_app_setting_get $app final_path) + +get_db() { + # $1 = nom de la table + # cette ligne de malade : + # 1/ Recupere le schém de la table user + # 2/ En extrait les noms de champs (en prenant le premier mot après la tabulation) + # 3/ en supprime les clé UNIQUE, PRIMARY et CHECK dont on ne veut pas + # 4/ remplace la liste avec retour à la ligne par une liste séparé par des virgules + # 5/ Enlève la dernière virgule + sqlite3 ./app.db ".schema $1" | awk '/\t/ {print $1}' | grep -v -e "UNIQUE" -e "PRIMARY" -e "CHECK" -e "FOREIGN" | awk '{printf "%s, ", $0}' | head -c -2 +} + +###################################### +#1 get admin user and id from database +###################################### +#we take the admin user as we're sure there is at least this one + +admin=$(ynh_app_setting_get $app admin) +echo "admin : $admin" +admin_id=$(sqlite3 $final_path/app.db "SELECT id FROM user WHERE nickname='$admin'") + +###################################### +#get user table structure +###################################### +table_schema=$(get_db "user") + +###################################### +#Build new entry for user +###################################### +insert_user=$table_schema +insert_user="${insert_user/id/null}" #so that a new entry is created +insert_user="${insert_user/nickname/\'$username\'}" +insert_user="${insert_user/role/0}" #standard role +pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor) +insert_user="${insert_user/password/\$pass_hash}" #we get the same pass even if it's not use with LDAP, ones never knows... +insert_user="${insert_user/email/\'$mail\'}" + +####################################### +# Insert New entry in database +####################################### + +sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = $admin_id;" diff --git a/hooks/post_user_delete b/hooks/post_user_delete new file mode 100644 index 0000000..94218da --- /dev/null +++ b/hooks/post_user_delete @@ -0,0 +1,37 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +app=calibreweb +username=$1 +final_path=$(ynh_app_setting_get $app final_path) +del_tables_user="book_read_link remote_auth_token downloads shelf bookmark" +del_tables_shelf="book_shelf_link" + +del_id() { + #$1=table + #$2=id_type + #$3=id + + sqlite3 $final_path/app.db "DELETE FROM $1 WHERE $2='$3'" +} + + +user_id=$(sqlite3 $final_path/app.db "SELECT id from user WHERE nickname='$username'") +shelf_id=$(sqlite3 $final_path/app.db "SELECT id from shelf WHERE user_id='$user_id'") + + +#Delete all entry with dependencies for user +for i in $del_tables_shelf +do + echo "$i" + del_id "$i" "shelf" $shelf_id +done +for i in $del_tables_user +do + echo "$i" + del_id "$i" "user_id" $user_id +done + +#delete user +del_id "user" "id" $user_id \ No newline at end of file diff --git a/manifest.json b/manifest.json index 3389eab..5fcfa42 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Calibre-web for Yunohost", "fr": "Calibre-web pour Yunohost" }, - "version": "0.91~ynh2", + "version": "0.92~ynh3", "url": "https://github.com/janeczku/calibre-web", "license": "free", "maintainer": { @@ -14,7 +14,7 @@ "email": "misterl56@hotmail.com" }, "requirements": { - "yunohost": ">= 2.7.14" + "yunohost": ">= 3.0.0" }, "multi_instance": true, "services": [ @@ -61,18 +61,18 @@ }, { "name": "language", - "optional": true, + "optional": true, "ask": { "en": "Select a default language (you may change it later in the app)", "fr": "Choisissez une langue par défaut (vous pourrez la changer ultérieurement dans l'application)" }, - "choices": [ "fr", "en", "es", "de"], + "choices": [ "fr", "en", "es", "de"], "default": "fr" }, { "name": "upload", - "type":"boolean", - "optional": true, + "type":"boolean", + "optional": true, "ask": { "en": "Do you want to allow uploading of books (you may change it later in the app)?", "fr": "Voulez vous autoriser l'upload de livres (vous pourrez le changer ultérieurement dans l'application)?" @@ -81,22 +81,13 @@ }, { "name": "public_library", - "type":"boolean", - "optional": true, + "type":"boolean", + "optional": true, "ask": { "en": "Do you want to allow access to the library to all Yunohost users?", "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?" }, "default": false - }, - { - "name": "password", - "type": "password", - "ask": { - "en": "Set the administrator password", - "fr": "Définissez le mot de passe administrateur" - }, - "example": "Averystrongpassword" } ] } diff --git a/scripts/install b/scripts/install index a2e1473..07699af 100755 --- a/scripts/install +++ b/scripts/install @@ -25,9 +25,6 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE -ynh_print_OFF -pass=$YNH_APP_ARG_PASSWORD -ynh_print_ON app=$YNH_APP_INSTANCE_NAME upload=$6 public_library=$7 @@ -161,7 +158,7 @@ chown -R $app:$app /var/log/$app ynh_print_info "Setting up database and settings" #we need to start and stop the service so that initial app.db file is created and that we can set default data ynh_systemd_action -l "INFO in server: Starting Gevent server" -#systemctl start $app + #sleep required on low spec like raspberryPi sleep 2s ynh_systemd_action -a stop @@ -175,11 +172,11 @@ conf="\"UPDATE user SET $(. <(echo -E echo $(<../conf/init_calibre_db_user))) WH eval sqlite3 $final_path/app.db "$conf" #mise à jour du mot de passe (je ne sais pas pourquoi, je n'arrive pas à l'intégrer dans le fichier de conf, pb de " et ') -ynh_print_OFF +#ynh_print_OFF #had to set it on two lines or package_linter cries like a baby... -pass=$(python ../conf/generate_password_hash.py "$pass" $final_path/vendor) -sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1" -ynh_print_ON +#pass=$(python ../conf/generate_password_hash.py "$pass" $final_path/vendor) +#sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1" +#ynh_print_ON #================================================= # SECURE FILES AND DIRECTORIES From b4b5725182ebc32222b9a828e435556f88470c94 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 19 Jan 2019 12:33:21 +0100 Subject: [PATCH 18/37] Update calibre-web version + comment in patch --- conf/app.src | 4 +-- sources/patches/app-ub.patch | 44 +++++++++++++++++++++++++++----- sources/patches/app-web.patch | 48 ++++++++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/conf/app.src b/conf/app.src index 33e5909..d238056 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,3 +1,3 @@ -SOURCE_URL=https://github.com/janeczku/calibre-web/archive/c527d1f49a2213e523957fd90d814c075bacde89.zip -SOURCE_SUM=61aff733df259382ae53646e5445ac973a0c4fe70e54ec4d3ed63a7f66c4f04f +SOURCE_URL=https://github.com/janeczku/calibre-web/archive/9e5fa45df7cd840d8a26d25f953857a13d6bc5de.zip +SOURCE_SUM=be288d5caa3ccdd612b66927b0849899107941f600a58dd2e0a3dc04feb594a2 SOURCE_FORMAT=zip diff --git a/sources/patches/app-ub.patch b/sources/patches/app-ub.patch index 5da0e64..e3313c5 100644 --- a/sources/patches/app-ub.patch +++ b/sources/patches/app-ub.patch @@ -1,9 +1,10 @@ ---- a/cps/ub.py 2019-01-12 09:01:08.000000000 +0100 -+++ b/cps/ub.py 2019-01-13 11:21:11.000000000 +0100 -@@ -148,6 +148,14 @@ +--- ./calibre-web-9e5fa45df7cd840d8a26d25f953857a13d6bc5de/cps/ub.py 2019-01-16 17:50:51.000000000 +0100 ++++ "/home/nicolas/Nextcloud/06 - Technique/08 - git/calibre-web/cps/ub.py" 2019-01-19 11:03:55.799293389 +0100 +@@ -148,6 +148,16 @@ def __repr__(self): return '' % self.nickname ++#Yunohost Integration - 1 + #Login via LDAP method + @staticmethod + def try_login(username, password): @@ -12,33 +13,59 @@ + config.config_ldap_dn.replace("%s", username), + password + ) ++#END Yunohost Integration - 1 # Baseclass for Users in Calibre-Web, settings which are depending on certain users are stored here. It is derived from # User Base (all access methods are declared there) -@@ -306,6 +314,9 @@ +@@ -268,8 +278,8 @@ + domain = Column(String) + + def __repr__(self): +- return u"".format(self.domain) +- ++ return u"".format(self.domain) ++ + + # Baseclass for representing settings in app.db with email server settings and Calibre database settings + # (application settings) +@@ -306,6 +316,11 @@ config_use_goodreads = Column(Boolean) config_goodreads_api_key = Column(String) config_goodreads_api_secret = Column(String) ++#Yunohost Integration - 2 + config_use_ldap = Column(Boolean) + config_ldap_provider_url = Column(String) + config_ldap_dn = Column(String) ++#END Yunohost Integration - 2 config_mature_content_tags = Column(String) config_logfile = Column(String) config_ebookconverter = Column(Integer, default=0) -@@ -379,6 +390,9 @@ +@@ -379,6 +394,11 @@ self.config_use_goodreads = data.config_use_goodreads self.config_goodreads_api_key = data.config_goodreads_api_key self.config_goodreads_api_secret = data.config_goodreads_api_secret ++#Yunohost Integration - 3 + self.config_use_ldap = data.config_use_ldap + self.config_ldap_provider_url = data.config_ldap_provider_url + self.config_ldap_dn = data.config_ldap_dn ++#END Yunohost Integration - 3 if data.config_mature_content_tags: self.config_mature_content_tags = data.config_mature_content_tags else: -@@ -662,13 +676,20 @@ +@@ -555,7 +575,7 @@ + conn.execute("ALTER TABLE Settings ADD column `config_use_google_drive` INTEGER DEFAULT 0") + conn.execute("ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''") + conn.execute("ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''") +- session.commit() ++ session.commit() + try: + session.query(exists().where(Settings.config_columns_to_ignore)).scalar() + except exc.OperationalError: +@@ -662,13 +682,22 @@ conn.execute("ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''") session.commit() try: ++#Yunohost Integration - 4 + session.query(exists().where(Settings.config_use_ldap)).scalar() + except exc.OperationalError: + conn = engine.connect() @@ -47,6 +74,7 @@ + conn.execute("ALTER TABLE Settings ADD column `config_ldap_dn` String DEFAULT ''") + session.commit() + try: ++#END Yunohost Integration - 4 session.query(exists().where(Settings.config_theme)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing conn = engine.connect() @@ -57,15 +85,17 @@ # Remove login capability of user Guest conn = engine.connect() conn.execute("UPDATE user SET password='' where nickname = 'Guest' and password !=''") -@@ -778,6 +799,12 @@ +@@ -778,6 +807,14 @@ migrate_Database() clean_database() ++#Yunohost Integration - 5 +#get LDAP connection +def get_ldap_connection(): + import ldap + conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url)) + return conn ++#END Yunohost Integration - 5 + # Generate global Settings Object accessible from every file config = Config() diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index 1145a8d..2388477 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,18 +1,42 @@ ---- ./ori-calibre-web/cps/web.py 2019-01-12 09:01:08.000000000 +0100 -+++ ./calibre-web-Yunohost_integration/cps/web.py 2019-01-13 20:11:57.000000000 +0100 -@@ -58,6 +58,8 @@ +--- ./calibre-web-9e5fa45df7cd840d8a26d25f953857a13d6bc5de/cps/web.py 2019-01-16 17:50:51.000000000 +0100 ++++ "/home/nicolas/Nextcloud/06 - Technique/08 - git/calibre-web/cps/web.py" 2019-01-19 10:55:51.728967203 +0100 +@@ -58,6 +58,11 @@ import server from reverseproxy import ReverseProxied ++#Yunohost LDAP integration - 1 +vlogout = 0 ++#END Yunohost LDAP integration -1 ++ + try: from googleapiclient.errors import HttpError except ImportError: -@@ -2360,10 +2362,29 @@ +@@ -1072,7 +1077,7 @@ + json_dumps = json.dumps([dict(name=r.name.replace('|',',')) for r in entries]) + return json_dumps + +- ++ + @app.route("/get_tags_json", methods=['GET', 'POST']) + @login_required_if_no_ano + def get_tags_json(): +@@ -1192,8 +1197,8 @@ + r = requests.get(repository_url + '/git/commits/' + commit['object']['sha']) + r.raise_for_status() + update_data = r.json() +- except requests.exceptions.HTTPError as e: +- status['error'] = _(u'HTTP Error') + ' ' + str(e) ++ except requests.exceptions.HTTPError as ex: ++ status['error'] = _(u'HTTP Error') + ' ' + str(ex) + except requests.exceptions.ConnectionError: + status['error'] = _(u'Connection error') + except requests.exceptions.Timeout: +@@ -2360,10 +2365,36 @@ return redirect(url_for('basic_configuration')) if current_user is not None and current_user.is_authenticated: return redirect(url_for('index')) ++#Yunohost integration - 2 + auth_user = request.headers.get('X-Remote-User') + global vlogout + if auth_user and config.config_use_ldap and not vlogout: @@ -21,10 +45,15 @@ + login_user(user, remember=True) + flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") + return redirect(url_for("index")) ++#END Yunohost integration - 2 if request.method == "POST": form = request.form.to_dict() user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first() - if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++#Yunohost integration - 3 ++# if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++#END Yunohost integration - 3 ++#Yunohost Integration - 4 + if config.config_use_ldap and user: + import ldap + try: @@ -37,23 +66,27 @@ + app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress) + flash(_(u"Wrong Username or Password"), category="error") + elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest": ++#End Yunohost Integration - 4 login_user(user, remember=True) flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success") return redirect_back(url_for("index")) -@@ -2384,6 +2405,8 @@ +@@ -2384,6 +2415,10 @@ @login_required def logout(): if current_user is not None and current_user.is_authenticated: ++#Yunohost Integration - 5 + global vlogout + vlogout = 1 ++#End Yunohost integration - 5 logout_user() return redirect(url_for('login')) -@@ -3088,6 +3111,21 @@ +@@ -3088,6 +3123,23 @@ if "config_ebookconverter" in to_save: content.config_ebookconverter = int(to_save["config_ebookconverter"]) -+ #LDAP configuratop, ++#Yunohost Integration - 6 ++ #LDAP configuration, + if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on": + if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save: + ub.session.commit() @@ -67,6 +100,7 @@ + content.config_ldap_provider_url = to_save["config_ldap_provider_url"] + content.config_ldap_dn = to_save["config_ldap_dn"] + db_change = True ++#END Yunohost integration - 6 + # Remote login configuration content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on") From 8ce614f76b8558dcf9f58060d4c5a7fead5dc126 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 19 Jan 2019 12:40:43 +0100 Subject: [PATCH 19/37] Correct sources patches path --- sources/patches/app-ub.patch | 4 ++-- sources/patches/app-web.patch | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/patches/app-ub.patch b/sources/patches/app-ub.patch index e3313c5..537236a 100644 --- a/sources/patches/app-ub.patch +++ b/sources/patches/app-ub.patch @@ -1,5 +1,5 @@ ---- ./calibre-web-9e5fa45df7cd840d8a26d25f953857a13d6bc5de/cps/ub.py 2019-01-16 17:50:51.000000000 +0100 -+++ "/home/nicolas/Nextcloud/06 - Technique/08 - git/calibre-web/cps/ub.py" 2019-01-19 11:03:55.799293389 +0100 +--- z/cps/ub.py 2019-01-16 17:50:51.000000000 +0100 ++++ b/cps/ub.py 2019-01-19 11:03:55.799293389 +0100 @@ -148,6 +148,16 @@ def __repr__(self): return '' % self.nickname diff --git a/sources/patches/app-web.patch b/sources/patches/app-web.patch index 2388477..340fbb9 100644 --- a/sources/patches/app-web.patch +++ b/sources/patches/app-web.patch @@ -1,5 +1,5 @@ ---- ./calibre-web-9e5fa45df7cd840d8a26d25f953857a13d6bc5de/cps/web.py 2019-01-16 17:50:51.000000000 +0100 -+++ "/home/nicolas/Nextcloud/06 - Technique/08 - git/calibre-web/cps/web.py" 2019-01-19 10:55:51.728967203 +0100 +--- a/cps/web.py 2019-01-16 17:50:51.000000000 +0100 ++++ b/cps/web.py 2019-01-19 10:55:51.728967203 +0100 @@ -58,6 +58,11 @@ import server from reverseproxy import ReverseProxied From 4066aa02e60f8f5230a8805ae72c1a8b4619a242 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 19 Jan 2019 12:54:54 +0100 Subject: [PATCH 20/37] Correct path to yunohost.multimedia --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b1e3fb4..ff113f5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -105,7 +105,7 @@ ynh_multimedia_build_main_dir () { local checksum="806a827ba1902d6911095602a9221181" # Download yunohost.multimedia scripts - wget -nv https://github.com/Krakinou/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + 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 \ From 9978725fc0d56e3b0867a6673baed7bc6befd400 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 21 Jan 2019 23:56:30 +0100 Subject: [PATCH 21/37] Add user --- hooks/post_user_create | 83 ++++++++++++++++++++---------------------- hooks/post_user_delete | 11 +++--- scripts/_common.sh | 10 +++++ scripts/install | 31 ++++++++++++++++ 4 files changed, 87 insertions(+), 48 deletions(-) diff --git a/hooks/post_user_create b/hooks/post_user_create index 472d734..23a6b1a 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -1,52 +1,49 @@ #!/bin/bash + # Source YunoHost helpers source /usr/share/yunohost/helpers -#reste à insérer la gestion des répertoires -app=calibreweb +#pour récupérer l'app_id, on prend le nom du fichier puis on retire les 3 premiers caratères +app=`basename "$0"` +app=${app:3} +source /etc/yunohost/apps/$app/scripts/_common.sh + + username=$1 mail=$2 pass_clear=$3 final_path=$(ynh_app_setting_get $app final_path) -get_db() { - # $1 = nom de la table - # cette ligne de malade : - # 1/ Recupere le schém de la table user - # 2/ En extrait les noms de champs (en prenant le premier mot après la tabulation) - # 3/ en supprime les clé UNIQUE, PRIMARY et CHECK dont on ne veut pas - # 4/ remplace la liste avec retour à la ligne par une liste séparé par des virgules - # 5/ Enlève la dernière virgule - sqlite3 ./app.db ".schema $1" | awk '/\t/ {print $1}' | grep -v -e "UNIQUE" -e "PRIMARY" -e "CHECK" -e "FOREIGN" | awk '{printf "%s, ", $0}' | head -c -2 -} - -###################################### -#1 get admin user and id from database -###################################### -#we take the admin user as we're sure there is at least this one - -admin=$(ynh_app_setting_get $app admin) -echo "admin : $admin" -admin_id=$(sqlite3 $final_path/app.db "SELECT id FROM user WHERE nickname='$admin'") - -###################################### -#get user table structure -###################################### -table_schema=$(get_db "user") - -###################################### -#Build new entry for user -###################################### -insert_user=$table_schema -insert_user="${insert_user/id/null}" #so that a new entry is created -insert_user="${insert_user/nickname/\'$username\'}" -insert_user="${insert_user/role/0}" #standard role -pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor) -insert_user="${insert_user/password/\$pass_hash}" #we get the same pass even if it's not use with LDAP, ones never knows... -insert_user="${insert_user/email/\'$mail\'}" - -####################################### -# Insert New entry in database -####################################### - -sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = $admin_id;" +public_library=$(ynh_app_setting_get "$app" public_library) +#User are duplicated in the database only if library is public +if [ public_library -eq 1 ]; then + ###################################### + #1 get admin user and id from database + ###################################### + #we take the admin user as we're sure there is at least this one + + admin=$(ynh_app_setting_get $app admin) + admin_id=$(sqlite3 $final_path/app.db "SELECT id FROM user WHERE nickname='$admin'") + + ###################################### + #get user table structure + ###################################### + table_schema=$(get_db "user") + + ###################################### + #Build new entry for user + ###################################### + insert_user=$table_schema + insert_user="${insert_user/id/null}" #so that a new entry is created + insert_user="${insert_user/nickname/\'$username\'}" + insert_user="${insert_user/role/0}" #standard role + pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor) + insert_user="${insert_user/password/\'$pass_hash\'}" #we get the same pass even if it's not thanks to LDAP, ones never knows... + insert_user="${insert_user/email/\'$mail\'}" + + ####################################### + # Insert New entry in database + ####################################### + + sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = $admin_id;" +fi \ No newline at end of file diff --git a/hooks/post_user_delete b/hooks/post_user_delete index 94218da..03d072a 100644 --- a/hooks/post_user_delete +++ b/hooks/post_user_delete @@ -2,7 +2,11 @@ # Source YunoHost helpers source /usr/share/yunohost/helpers -app=calibreweb +#pour récupérer l'app_id, on prend le nom du fichier puis on retire les 3 premiers caratères +app=`basename "$0"` +app=${app:3} +source /etc/yunohost/apps/$app/scripts/_common.sh + username=$1 final_path=$(ynh_app_setting_get $app final_path) del_tables_user="book_read_link remote_auth_token downloads shelf bookmark" @@ -12,7 +16,6 @@ del_id() { #$1=table #$2=id_type #$3=id - sqlite3 $final_path/app.db "DELETE FROM $1 WHERE $2='$3'" } @@ -20,16 +23,14 @@ del_id() { user_id=$(sqlite3 $final_path/app.db "SELECT id from user WHERE nickname='$username'") shelf_id=$(sqlite3 $final_path/app.db "SELECT id from shelf WHERE user_id='$user_id'") - #Delete all entry with dependencies for user +#pas de check sur l'existence de l'utilisateur car fonctionne sans for i in $del_tables_shelf do - echo "$i" del_id "$i" "shelf" $shelf_id done for i in $del_tables_user do - echo "$i" del_id "$i" "user_id" $user_id done diff --git a/scripts/_common.sh b/scripts/_common.sh index ff113f5..6d2551a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,16 @@ PKG_DEPENDENCIES="sqlite3 python-pip imagemagick" DOSSIER_MEDIA=/home/yunohost.multimedia create_dir=0 +get_db() { + # $1 = nom de la table + # cette ligne de malade : + # 1/ Recupere le schém de la table user + # 2/ En extrait les noms de champs (en prenant le premier mot après la tabulation) + # 3/ en supprime les clé UNIQUE, PRIMARY et CHECK dont on ne veut pas + # 4/ remplace la liste avec retour à la ligne par une liste séparé par des virgules + # 5/ Enlève la dernière virgule + sqlite3 $final_path/app.db ".schema $1" | awk '/\t/ {print $1}' | grep -v -e "UNIQUE" -e "PRIMARY" -e "CHECK" -e "FOREIGN" | awk '{printf "%s, ", $0}' | head -c -2 +} #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index 07699af..b51f806 100755 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,10 @@ language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME upload=$6 public_library=$7 +#if app is public, we assume library is public +if [ $is_public -eq 1 ]; then + public_library=1 +fi #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -178,6 +182,33 @@ eval sqlite3 $final_path/app.db "$conf" #sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1" #ynh_print_ON +#Creation des autres utilisateurs +if [ $public_library -eq 1 ]; then + table_schema=$(get_db "user") + + for i in $(ynh_user_list); do + if [ $i = $admin ]; then continue; fi + mail=$(ynh_user_get_info $i 'mail') + ###################################### + #Build new entry for user + ###################################### + insert_user=$table_schema + insert_user="${insert_user/id/null}" #so that a new entry is created + insert_user="${insert_user/nickname/\'$i\'}" + insert_user="${insert_user/role/0}" #standard role + # pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor) + # insert_user="${insert_user/password/\'$pass_hash\'}" #we get the same pass even if it's not thanks to LDAP, ones never knows... + insert_user="${insert_user/email/\'$mail\'}" + + ####################################### + # Insert New entry in database + ####################################### + + sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = 1;" + + done +fi + #================================================= # SECURE FILES AND DIRECTORIES #================================================= From d75010c89b38d1846d8c525fe73e01df8009f5ae Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 22 Jan 2019 00:02:38 +0100 Subject: [PATCH 22/37] typo --- manifest.json | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 5fcfa42..78f65b9 100644 --- a/manifest.json +++ b/manifest.json @@ -87,7 +87,7 @@ "en": "Do you want to allow access to the library to all Yunohost users?", "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?" }, - "default": false + "default": true } ] } diff --git a/scripts/install b/scripts/install index b51f806..29d59e4 100755 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,7 @@ ynh_multimedia_addaccess $app if [ $is_public -eq 1 ]; then #app is public, library is public calibre_dir=$DOSSIER_MEDIA/Share/eBook -elif [$is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public +elif [ $is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public calibre_dir=$DOSSIER_MEDIA/Share/eBook else #app is private, library is private calibre_dir=$DOSSIER_MEDIA/$admin/eBook From fa1300ac02d6a3de1e15ea323d5c0956b3de9ebf Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 22 Jan 2019 00:11:12 +0100 Subject: [PATCH 23/37] typo --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 29d59e4..d1d10e6 100755 --- a/scripts/install +++ b/scripts/install @@ -129,9 +129,9 @@ ynh_multimedia_build_main_dir ynh_multimedia_addaccess $app if [ $is_public -eq 1 ]; then #app is public, library is public - calibre_dir=$DOSSIER_MEDIA/Share/eBook + calibre_dir=$DOSSIER_MEDIA/share/eBook elif [ $is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public - calibre_dir=$DOSSIER_MEDIA/Share/eBook + calibre_dir=$DOSSIER_MEDIA/share/eBook else #app is private, library is private calibre_dir=$DOSSIER_MEDIA/$admin/eBook fi From 03a0b42c115f1c55bcbb833f9148a86d6eace674 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 23 Jan 2019 23:35:43 +0100 Subject: [PATCH 24/37] add multimedia dir --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 875de9c..9a45b42 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,6 +95,11 @@ ynh_backup_if_checksum_is_different "$final_path/app.db" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/app.db" +#build multimedia directory +#Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice. +ynh_multimedia_build_main_dir +ynh_multimedia_addaccess $app + #================================================= # SETUP LOGROTATE #================================================= From 7bbd113545aacece1d2652e91b8281ceaf1ff91c Mon Sep 17 00:00:00 2001 From: Krakinou Date: Thu, 24 Jan 2019 00:35:34 +0100 Subject: [PATCH 25/37] typo variable --- scripts/restore | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 3c6de79..4f9c05f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -88,7 +88,7 @@ chown -R $app: $final_path # Define and install dependencies ynh_print_info "Installing dependencies and pip packages" -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $PKG_DEPENDENCIES pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9a45b42..f66a801 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,7 +72,7 @@ ynh_add_nginx_config # UPGRADE DEPENDENCIES #================================================= -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $PKG_DEPENDENCIES pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= From 0d37d1c138113c71c5932a6da3089362f387c907 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 28 Jan 2019 22:58:03 +0100 Subject: [PATCH 26/37] Remove X-script-Name when root --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d1d10e6..e4c3a8a 100755 --- a/scripts/install +++ b/scripts/install @@ -93,7 +93,7 @@ pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= #Cannot use empty string for X-script-name, causes an issue in the python prg if [ $path_url = "/" ] ; then - ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name $app;" ../conf/nginx.conf + ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi # Create a dedicated nginx config From 58f499ea37cb9faece617176e5f048ceb26f0b8a Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 28 Jan 2019 23:24:43 +0100 Subject: [PATCH 27/37] X-script name in change url check process level 4 to 1 add more comments on manifest --- check_process | 2 +- manifest.json | 4 ++-- scripts/change_url | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index 1f41b77..6da2504 100644 --- a/check_process +++ b/check_process @@ -43,7 +43,7 @@ Level 1=auto Level 2=auto Level 3=auto - Level 4=na + Level 4=1 Level 5=auto Level 6=auto Level 7=auto diff --git a/manifest.json b/manifest.json index 78f65b9..04cac8f 100644 --- a/manifest.json +++ b/manifest.json @@ -84,8 +84,8 @@ "type":"boolean", "optional": true, "ask": { - "en": "Do you want to allow access to the library to all Yunohost users?", - "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?" + "en": "Do you want to allow access to the library to all Yunohost users? Yes will set the library in /home/yunohost.multimedia/share/eBook", + "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost? Yes parametrera la bibliothèque pour /home/yunohost.multimedia/share/eBook" }, "default": true } diff --git a/scripts/change_url b/scripts/change_url index 8a5b158..369c1b6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,7 +71,7 @@ then path_url="$new_path" #Cannot use empty string for X-script-name, causes an issue in the python prg if [ $path_url = "/" ] ; then - ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name /$app;" ../conf/nginx.conf + ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi # Create a dedicated nginx config ynh_add_nginx_config From afcf08fefa178c969b78df62cc461e357446e810 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 29 Jan 2019 23:04:48 +0100 Subject: [PATCH 28/37] Update manifest with help Update upgrade script with ldap --- manifest.json | 28 ++++++++++++++++++++++------ scripts/upgrade | 7 ++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/manifest.json b/manifest.json index 04cac8f..fbf956c 100644 --- a/manifest.json +++ b/manifest.json @@ -57,14 +57,22 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help":{ + "en":"No will set the library in /home/yunohost.multimedia/admin/eBook, but if you set thje library as public", + "fr":"Non parametrera la bibliothèque pour /home/yunohost.multimedia/admin/eBook sauf si la bibliothèque est également publique" + }, "default": false }, { "name": "language", "optional": true, "ask": { - "en": "Select a default language (you may change it later in the app)", - "fr": "Choisissez une langue par défaut (vous pourrez la changer ultérieurement dans l'application)" + "en": "Select a default language", + "fr": "Choisissez une langue par défaut" + }, + "help":{ + "en":"You may change it later in the app", + "fr":"Vous pourrez la changer ultérieurement dans l'application" }, "choices": [ "fr", "en", "es", "de"], "default": "fr" @@ -74,8 +82,12 @@ "type":"boolean", "optional": true, "ask": { - "en": "Do you want to allow uploading of books (you may change it later in the app)?", - "fr": "Voulez vous autoriser l'upload de livres (vous pourrez le changer ultérieurement dans l'application)?" + "en": "Do you want to allow uploading of books?", + "fr": "Voulez vous autoriser l'upload de livres?" + }, + "help":{ + "en":"You may change it later in the app", + "fr":"Vous pourrez le changer ultérieurement dans l'application" }, "default": false }, @@ -84,8 +96,12 @@ "type":"boolean", "optional": true, "ask": { - "en": "Do you want to allow access to the library to all Yunohost users? Yes will set the library in /home/yunohost.multimedia/share/eBook", - "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost? Yes parametrera la bibliothèque pour /home/yunohost.multimedia/share/eBook" + "en": "Do you want to allow access to the library to all Yunohost users? ", + "fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?" + }, + "help":{ + "en":"Yes will set the library in /home/yunohost.multimedia/share/eBook", + "fr":"Oui parametrera la bibliothèque pour /home/yunohost.multimedia/share/eBook" }, "default": true } diff --git a/scripts/upgrade b/scripts/upgrade index f66a801..be3884f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,7 +71,7 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= - +ynh_print_info "Download and install dependencies" ynh_install_app_dependencies $PKG_DEPENDENCIES pip install --target $final_path/vendor -r $final_path/requirements.txt @@ -92,6 +92,11 @@ ynh_system_user_create $app ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ynh_backup_if_checksum_is_different "$final_path/app.db" + +#set database settings as per conf file +conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) WHERE ID=1\"" +eval sqlite3 $final_path/app.db "$conf" + # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/app.db" From 987cd0e568fad126a61210cd2e463c376540a8fe Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 29 Jan 2019 23:25:09 +0100 Subject: [PATCH 29/37] Generate ldap setting during upgrade --- conf/init_calibre_db_ldap_settings | 3 +++ conf/init_calibre_db_settings | 3 --- scripts/upgrade | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 conf/init_calibre_db_ldap_settings diff --git a/conf/init_calibre_db_ldap_settings b/conf/init_calibre_db_ldap_settings new file mode 100644 index 0000000..3e45426 --- /dev/null +++ b/conf/init_calibre_db_ldap_settings @@ -0,0 +1,3 @@ +config_use_ldap=1, +config_ldap_provider_url=\'localhost:389\', +config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\', \ No newline at end of file diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index f600faa..b50120f 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,7 +8,4 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_use_ldap=1, -config_ldap_provider_url=\'localhost:389\', -config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\', config_uploading=\'$upload\' diff --git a/scripts/upgrade b/scripts/upgrade index be3884f..ddaeb37 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,22 +89,23 @@ ynh_system_user_create $app # ... #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different "$final_path/app.db" - -#set database settings as per conf file -conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) WHERE ID=1\"" -eval sqlite3 $final_path/app.db "$conf" - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$final_path/app.db" - #build multimedia directory #Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice. ynh_multimedia_build_main_dir ynh_multimedia_addaccess $app +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different "$final_path/app.db" + +#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap settings +ynh_systemd_action -a restart -l "INFO in server: Starting Gevent server" +conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" +eval sqlite3 $final_path/app.db "$conf" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum "$final_path/app.db" + #================================================= # SETUP LOGROTATE #================================================= From c150540feaaae0f5eb7624b79c3cc70d9b6c20a4 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 29 Jan 2019 23:45:23 +0100 Subject: [PATCH 30/37] update ldap script --- conf/init_calibre_db_ldap_settings | 2 +- scripts/install | 2 +- scripts/upgrade | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/init_calibre_db_ldap_settings b/conf/init_calibre_db_ldap_settings index 3e45426..d16c8e9 100644 --- a/conf/init_calibre_db_ldap_settings +++ b/conf/init_calibre_db_ldap_settings @@ -1,3 +1,3 @@ config_use_ldap=1, config_ldap_provider_url=\'localhost:389\', -config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\', \ No newline at end of file +config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\' \ No newline at end of file diff --git a/scripts/install b/scripts/install index e4c3a8a..2600de5 100755 --- a/scripts/install +++ b/scripts/install @@ -169,7 +169,7 @@ ynh_systemd_action -a stop #set database settings as per conf file -conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) WHERE ID=1\"" +conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" conf="\"UPDATE user SET $(. <(echo -E echo $(<../conf/init_calibre_db_user))) WHERE ID=1\"" diff --git a/scripts/upgrade b/scripts/upgrade index ddaeb37..6ba7e9d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -99,7 +99,8 @@ ynh_multimedia_addaccess $app ynh_backup_if_checksum_is_different "$final_path/app.db" #set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap settings -ynh_systemd_action -a restart -l "INFO in server: Starting Gevent server" +ynh_systemd_action -a stop +ynh_systemd_action -l "INFO in server: Starting Gevent server" conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" From 8f987cc6f8b0af90df294ba21124c9fa046328a3 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Tue, 29 Jan 2019 23:55:22 +0100 Subject: [PATCH 31/37] Typo --- conf/init_calibre_db_settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index b50120f..b54e177 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,4 +8,4 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_uploading=\'$upload\' +config_uploading=\'$upload\', From 1be8c6e4a62863ba3a311294869cbb5f149f1ce5 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 00:05:19 +0100 Subject: [PATCH 32/37] stop app before upgrade --- scripts/upgrade | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6ba7e9d..a5f4ee1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,6 +44,9 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#Stop the app in case database is updated +ynh_systemd_action -a stop + #================================================= # CHECK THE PATH #================================================= @@ -99,8 +102,11 @@ ynh_multimedia_addaccess $app ynh_backup_if_checksum_is_different "$final_path/app.db" #set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap settings -ynh_systemd_action -a stop ynh_systemd_action -l "INFO in server: Starting Gevent server" +#sleep required on low spec like raspberryPi +sleep 2s +ynh_systemd_action -a stop + conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" From 71749b4abe4b76d4c68ca2ea475f727f986fbab3 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 22:27:04 +0100 Subject: [PATCH 33/37] Update patch --- README.md | 4 ++-- sources/patches/app-ub.patch | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index dc4f95a..7b54c5b 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre ## Todo - [X] Multiinstance -- [ ] Better Multimedia integration : Integrate in Yunohost.multimedia -- [ ] User and possibly LDAP integration +- [X] Better Multimedia integration : Integrate in Yunohost.multimedia +- [X] User and possibly LDAP integration, http auth - [X] Package_check integration - [X] On backup/remove/upgrade : check for database location to update settings - [ ] enable magic link diff --git a/sources/patches/app-ub.patch b/sources/patches/app-ub.patch index 537236a..16f7494 100644 --- a/sources/patches/app-ub.patch +++ b/sources/patches/app-ub.patch @@ -1,5 +1,5 @@ ---- z/cps/ub.py 2019-01-16 17:50:51.000000000 +0100 -+++ b/cps/ub.py 2019-01-19 11:03:55.799293389 +0100 +--- a/cps/ub.py 2019-01-16 17:50:51.000000000 +0100 ++++ b/cps/ub.py 2019-01-30 22:23:29.709075421 +0100 @@ -148,6 +148,16 @@ def __repr__(self): return '' % self.nickname @@ -61,9 +61,9 @@ try: session.query(exists().where(Settings.config_columns_to_ignore)).scalar() except exc.OperationalError: -@@ -662,13 +682,22 @@ - conn.execute("ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''") - session.commit() +@@ -624,6 +644,16 @@ + conn.execute("ALTER TABLE Settings ADD column `config_goodreads_api_key` String DEFAULT ''") + conn.execute("ALTER TABLE Settings ADD column `config_goodreads_api_secret` String DEFAULT ''") try: +#Yunohost Integration - 4 + session.query(exists().where(Settings.config_use_ldap)).scalar() @@ -75,9 +75,10 @@ + session.commit() + try: +#END Yunohost Integration - 4 - session.query(exists().where(Settings.config_theme)).scalar() - except exc.OperationalError: # Database is not compatible, some rows are missing + session.query(exists().where(Settings.config_mature_content_tags)).scalar() + except exc.OperationalError: conn = engine.connect() +@@ -668,7 +698,6 @@ conn.execute("ALTER TABLE Settings ADD column `config_theme` INTEGER DEFAULT 0") session.commit() From 05d51fb948b611c92729fa4e8bc3e5cae37ebe06 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 22:39:40 +0100 Subject: [PATCH 34/37] Give access to app prior to update --- scripts/upgrade | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a5f4ee1..e77ea9d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -85,18 +85,23 @@ pip install --target $final_path/vendor -r $final_path/requirements.txt # Create a dedicated user (if not existing) ynh_system_user_create $app +# Set permissions on app files (required to be able to update database) +chown -R $app: $final_path #================================================= # SPECIFIC UPGRADE #================================================= -# ... +#build multimedia directory #================================================= -#build multimedia directory #Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice. ynh_multimedia_build_main_dir ynh_multimedia_addaccess $app +#================================================= +#Update database structure +#================================================= + ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ynh_backup_if_checksum_is_different "$final_path/app.db" From 0039c3672039cb920f328ed9c565eb2120d7f681 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 22:58:20 +0100 Subject: [PATCH 35/37] Correct nginx conf --- manifest.json | 2 +- scripts/upgrade | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index fbf956c..783924c 100644 --- a/manifest.json +++ b/manifest.json @@ -58,7 +58,7 @@ "fr": "Est-ce une application publique ?" }, "help":{ - "en":"No will set the library in /home/yunohost.multimedia/admin/eBook, but if you set thje library as public", + "en":"No will set the library in /home/yunohost.multimedia/admin/eBook, except if you set the library as public", "fr":"Non parametrera la bibliothèque pour /home/yunohost.multimedia/admin/eBook sauf si la bibliothèque est également publique" }, "default": false diff --git a/scripts/upgrade b/scripts/upgrade index e77ea9d..0c037a6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,6 +68,10 @@ ynh_setup_source "$final_path" # NGINX CONFIGURATION #================================================= +if [ $path_url = "/" ] ; then + ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf +fi + # Create a dedicated nginx config ynh_add_nginx_config From 32a539844f6e674cfb470e407e9e993b6e897782 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 23:11:52 +0100 Subject: [PATCH 36/37] Update README --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b54c5b..076a94c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,14 @@ Alternatively, you may use [COPS](https://github.com/YunoHost-Apps/cops_ynh) whi **Shipped version:** To be 1.0, let's say 0.9 :) +Library will be placed in /home/yunohost.multimedia/share/eBook except if both + - calibreweb is set as a private application + - calibreweb library is set as a public library +In this case the library will be set in /home/yunohost.multimedia/[admin]/eBook folder +Library folder can always be changed manually in the application settings by the admin + +This app support http authentification. + ## Screenshots ![screenshot](https://raw.githubusercontent.com/janeczku/docker-calibre-web/master/screenshot.png) @@ -31,10 +39,10 @@ yunohost app setting calibreweb backup_core_only -v 0 By default, removing the app will **never** delete the library. -## Limitations +## Known Limitations -* No LDAP support -* access to library to be done manually after install if Calibre library was already existing, for example : +* Partial LDAP support : user existing both in Yunohost and calibreweb can use their Yunohost password to log in, but user existing previously to the application installation will not be duplicated in the database automatically +* Authorization access to library to be done manually after install if Calibre library was already existing, for example : ``` chown -R calibreweb: path/to/library or @@ -42,6 +50,7 @@ chmod o+rw path/to/library ``` * Do not use a Nextcloud folder. It's all right if the folder is an external storage in Nextcloud but not if it's an internal one : Changing the data in the library will cause trouble with the sync * "Magic link feature is not yet available +* Change to library made outside calibreweb are not automatically updated in calibreweb. It is required to disconnect and reconnect to see the changes ## Links From b502b4f969909f7fd0fcb03bb2d6bded564c023b Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 30 Jan 2019 23:16:38 +0100 Subject: [PATCH 37/37] Update README --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 076a94c..81bafa5 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,16 @@ Calibre-Web is a web app providing a clean interface for browsing, reading and d *This software is a fork of [library](https://github.com/mutschler/calibreserver) and licensed under the GPL v3 License.* -Alternatively, you may use [COPS](https://github.com/YunoHost-Apps/cops_ynh) which also allows access to you Calibre Library, but in read-only mode. +Alternatively, you may use [COPS](https://github.com/YunoHost-Apps/cops_ynh) which also allows access to your Calibre Library, but in read-only mode. **Shipped version:** To be 1.0, let's say 0.9 :) -Library will be placed in /home/yunohost.multimedia/share/eBook except if both + +Library will be placed in `/home/yunohost.multimedia/share/eBook` folder except if both : - calibreweb is set as a private application - calibreweb library is set as a public library -In this case the library will be set in /home/yunohost.multimedia/[admin]/eBook folder -Library folder can always be changed manually in the application settings by the admin + +In this case the library will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. Library folder can always be changed manually in the application settings by the administrator. This app support http authentification.