From 42ee0808da4f1f7a0e343793604b9dda1262be59 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 26 Jul 2023 01:01:32 +0200 Subject: [PATCH 01/33] convert v2 : initial commit --- .github/workflows/updater.sh | 212 ------------------------- .github/workflows/updater.yml | 50 ------ .project | 8 +- .pydevproject | 5 - check_process | 28 ---- conf/app.src | 3 - conf/app066.src | 3 - conf/appkepubify.src.default | 4 - conf/init_calibre_db_ldap_settings_old | 11 -- conf/init_calibre_db_settings_old | 7 - conf/nginx.conf | 4 +- doc/{DISCLAIMER.md => ADMIN.md} | 25 --- doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 25 +-- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + doc/POST_INSTALL.md | 5 + doc/POST_INSTALL_fr.md | 4 + doc/PRE_INSTALL.md | 3 + doc/PRE_INSTALL_fr.md | 3 + manifest.json | 104 ------------ manifest.toml | 101 ++++++++++++ scripts/_common.sh | 34 ---- scripts/backup | 21 +-- scripts/change_url | 97 +---------- scripts/install | 175 +++++--------------- scripts/remove | 39 ----- scripts/restore | 87 ++-------- scripts/upgrade | 148 ++++------------- tests.toml | 14 ++ 29 files changed, 219 insertions(+), 1003 deletions(-) delete mode 100755 .github/workflows/updater.sh delete mode 100644 .github/workflows/updater.yml delete mode 100644 .pydevproject delete mode 100644 check_process delete mode 100644 conf/app.src delete mode 100644 conf/app066.src delete mode 100644 conf/appkepubify.src.default delete mode 100644 conf/init_calibre_db_ldap_settings_old delete mode 100644 conf/init_calibre_db_settings_old rename doc/{DISCLAIMER.md => ADMIN.md} (69%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (69%) create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md create mode 100644 doc/POST_INSTALL.md create mode 100644 doc/POST_INSTALL_fr.md create mode 100644 doc/PRE_INSTALL.md create mode 100644 doc/PRE_INSTALL_fr.md delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100755 index 6dfd010..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/bash - -#========================================== -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.upstream.version|split("~")[0]') -current_yunohost_package_version=$(cat manifest.json | jq -j '.version|split("~ynh")[1]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -#fetching info for kepubify -current_version_kepubify=$(sed -n '1p' ./conf/appkepubify.src.default | sed 's/^SOURCE_URL=https:\/\/github.com\/pgaskin\/kepubify\/releases\/download\/v//;s/\/kepubify-linux-__MACH__//') -repo_kepubify="pgaskin/kepubify" -version_kepubify=$(curl --silent "https://api.github.com/repos/$repo_kepubify/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets_kepubify=($(curl --silent "https://api.github.com/repos/$repo_kepubify/releases" | jq -r '[ .[] | select(.tag_name=="'$version_kepubify'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi -if [[ ${version_kepubify:0:1} == "v" || ${version_kepubify:0:1} == "V" ]]; then - version_kepubify=${version_kepubify:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $GITHUB_ENV -echo "Current version for kepubify: $current_version_kepubify" -echo "Latest release from upstream for kepubify: $version_kepubify" -echo "VERSION_KEPUBIFY=$version_kepubify" >> $GITHUB_ENV -echo "REPO_KEPUBIFY=$repo_kepubify" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -update_upstream=1 -update_kepubify=1 - -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available for upstream app" - update_upstream=0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - update_upstream=0 -fi - -if ! dpkg --compare-versions "$current_version_kepubify" "lt" "$version_kepubify" ; then - echo "::warning ::No new version available for kepubify" - update_kepubify=0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-update-kepubify-v$version_kepubify ; then - echo "::warning ::A branch already exists for this kepubify update" - update_kepubify=0 -fi - -if [ "$update_kepubify" == 0 ] && [ "$update_upstream" == 0 ]; then - echo "::no update : exit" - exit 0 -fi - -if [ "$update_upstream" == 1 ]; then - echo "Update upstream" - # Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) - echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs - for asset_url in ${assets[@]}; do - - echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset - case $asset_url in - *"calibre-web-$version.zip"*) - src="app" - ;; - *) - src="" - ;; - esac - -# If $src is not empty, let's process the asset - if [ ! -z "$src" ]; then - -# Create the temporary directory - tempdir="$(mktemp -d)" - -# Download sources and calculate checksum - filename=${asset_url##*/} - curl --silent -4 -L $asset_url -o "$tempdir/$filename" - checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory - rm -rf $tempdir - - extension=zip -# Rewrite source file - -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_FORMAT=$extension -EOT - echo "... conf/$src.src updated" - - else - echo "... asset ignored" - fi - - done -fi - -if [ "$update_kepubify" == 1 ]; then - echo "Update kepubify" - for asset_url_kepubify in ${assets_kepubify[@]}; do - - echo "Handling asset at $asset_url_kepubify" - - case $asset_url_kepubify in - *"linux-32bit"*) - sha="sha256_32bit" - src="appkepubify" - ;; - *"linux-64bit"*) - sha="sha256_64bit" - src="appkepubify" - ;; - *"linux-arm"*) - sha="sha256_arm" - src="appkepubify" - ;; - *"linux-arm64"*) - sha="sha256_arm64" - src="appkepubify" - ;; - *"linux-armv6"*) - sha="sha256_armv6" - src="appkepubify" - ;; - *) - src="" - ;; - esac - -# If $src is not empty, let's process the asset - if [ ! -z "$src" ]; then - -# Create the temporary directory - tempdir="$(mktemp -d)" - -# Download sources and calculate checksum - filename=${asset_url##*/} - curl --silent -4 -L $asset_url -o "$tempdir/$filename" - checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory - rm -rf $tempdir -# Rewrite source file - -cat < conf/$src.src.default -SOURCE_URL=https://github.com/pgaskin/kepubify/releases/download/v$version_kepubify/kepubify-linux-__MACH__ -SOURCE_SUM=__SHA256__ -SOURCE_EXTRACT=false -SOURCE_FILENAME=kepubify-linux-__MACH__ -EOT - echo "... conf/$src.src updated" -#rewrite sha256sum - sed -i 's/^$sha=.*/$sha=$checksum/' ./scripts/_common.sh - echo "... ./scripts/_common.sh updated for $sha" - else - echo "... asset ignored" - fi - - done - - - -fi - -#================================================= -# GENERIC FINALIZATION -#================================================= -if [ "$update_upstream" == 1 ]; then -# Replace new version in manifest - echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - echo "$(jq -s --indent 4 ".[] | .upstream.version = \"$version\"" manifest.json)" > manifest.json -fi -if [ "$update_kepubify" == 1 ] && [ "$update_upstream" == 0 ]; then -new_yunohost_package_version=$(("$current_yunohost_package_version+1")) - echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh$new_yunohost_package_version\"" manifest.json)" > manifest.json -fi - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index 4a866ff..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,50 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - [See upstream release page](https://github.com/${{ env.REPO }}/releases/tag/v${{ env.VERSION }}) - draft: false diff --git a/.project b/.project index 0675d93..54cd73b 100644 --- a/.project +++ b/.project @@ -1,17 +1,11 @@ - calibre_ynh + calibreweb_ynh - - org.python.pydev.PyDevBuilder - - - - org.python.pydev.pythonNature diff --git a/.pydevproject b/.pydevproject deleted file mode 100644 index d001f0a..0000000 --- a/.pydevproject +++ /dev/null @@ -1,5 +0,0 @@ - - -Default -python interpreter - diff --git a/check_process b/check_process deleted file mode 100644 index e1d3435..0000000 --- a/check_process +++ /dev/null @@ -1,28 +0,0 @@ -;; Complete Test -# First Run of complete test - ; Manifest - domain="domain.tld" - path="/calibre" - calibre_path="/home/yunohost.app/calibreweb" - admin="john" - language="en" - is_public=0 - upload=1 - password="a very long password" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_private=1 - setup_public=1 - upgrade=1 -#Last version - upgrade=1 from_commit=3d6385a2a58984a53c328a4f1aa1b900a84aba1e - backup_restore=1 - multi_instance=1 - port_already_use=1 (8083) - change_url=1 -;;; Options -Email=nicolas@aubonalbanais.ovh -Notification=none - diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 9ef0ec0..0000000 --- a/conf/app.src +++ /dev/null @@ -1,3 +0,0 @@ -SOURCE_URL=https://github.com/janeczku/calibre-web/releases/download/0.6.20/calibre-web-0.6.20.zip -SOURCE_SUM=2f1f8a5ae06f182986193a90796fa96a7b0b5c61fdd29971969b49245b1aaf24 -SOURCE_FORMAT=zip diff --git a/conf/app066.src b/conf/app066.src deleted file mode 100644 index 586a6ab..0000000 --- a/conf/app066.src +++ /dev/null @@ -1,3 +0,0 @@ -SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0.6.6.zip -SOURCE_SUM=87633c2817263ed2d12fce67ea292b1c6d042aa949aafb728789c15d495415cc -SOURCE_FORMAT=zip \ No newline at end of file diff --git a/conf/appkepubify.src.default b/conf/appkepubify.src.default deleted file mode 100644 index e7d020d..0000000 --- a/conf/appkepubify.src.default +++ /dev/null @@ -1,4 +0,0 @@ -SOURCE_URL=https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-__MACH__ -SOURCE_SUM=__SHA256__ -SOURCE_EXTRACT=false -SOURCE_FILENAME=kepubify-linux-__MACH__ \ No newline at end of file diff --git a/conf/init_calibre_db_ldap_settings_old b/conf/init_calibre_db_ldap_settings_old deleted file mode 100644 index 4a7f0aa..0000000 --- a/conf/init_calibre_db_ldap_settings_old +++ /dev/null @@ -1,11 +0,0 @@ -#To be deleted in future release -config_login_type=1, -config_ldap_provider_url=\'localhost\', -config_ldap_port=389, -config_ldap_authentication=0, -config_ldap_dn=\'dc=yunohost,dc=org\', -config_ldap_user_object=\'\(\&\(objectClass=posixAccount\)\(permission=cn=calibreweb.main,ou=permission,dc=yunohost,dc=org\)\(uid=%s\)\)\', -config_ldap_openldap=1, -config_ldap_group_object_filter=\'\(\&\(objectClass=posixGroup\)\(cn=%s.main\)\)\', -config_ldap_group_members_field=\'memberUid\', -config_ldap_group_name=\'calibreweb\' \ No newline at end of file diff --git a/conf/init_calibre_db_settings_old b/conf/init_calibre_db_settings_old deleted file mode 100644 index e94a893..0000000 --- a/conf/init_calibre_db_settings_old +++ /dev/null @@ -1,7 +0,0 @@ -#to be deleted in future release -config_calibre_dir=\'$calibre_dir\', -config_port=$port, -config_logfile=\'$LOG_FILE\', -config_access_log=1, -config_access_logfile=\'$ACCESS_LOG_FILE\', -config_uploading=\'$upload\' \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 86caa24..92aade2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,11 +11,11 @@ location __PATH__ { proxy_pass http://localhost:__PORT__; proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $http_host; + proxy_set_header Host $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; + proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 69% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md index 437f69c..d12313a 100644 --- a/doc/DISCLAIMER.md +++ b/doc/ADMIN.md @@ -1,18 +1,5 @@ - -### Post install - -Users having the calibreweb.main authorization group can be automatically sync from within the app, by using the "Import LDAP user" function. -Deletion of a Yunohost User will delete the according calibreweb-user. - - ### Library management -* **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 administrator. - * By default, Yunohost backup process **will backup** Calibreweb library. You may deactivate backup of the library with ``` @@ -48,17 +35,5 @@ Version number in Yunohost is different from the upstream Calibre-web app : vers ### Known Limitations * 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 : Do not open a database both in Calibre & Calibreweb! * Kobo Sync doesn’t work when Calibreweb is installed on a subdomain. This issue is caused by nginx. However, it works great when installed on a path e.g. `https://domain.tld/calibreweb` - -### Todo -- [ ] Update mail settings with yunohost settings -- [ ] enable magic link -- [ ] Add cronjob to reload database (for nextcloud integration) -- [ ] Add config-panel option to trigger do_not_backup_data -- [ ] Add config-panel to manage max upload size -- [ ] Add action to restart the server -- [ ] Add action to synchronize users -- [ ] Add action to deactivate LDAP et retrieve admin password -- [ ] Use internal updater to update version? diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 69% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md index b96d501..28bf475 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/ADMIN_fr.md @@ -1,18 +1,7 @@ -### Post installation - -Les utilisateurs appartenant au groupe d'autorisation calibreweb.main peuvent être synchronisé automatiquement depuis l'application en utilisant la fonction "Importer les utilisateurs LDAP". -Lorsque les utilisateurs sont supprimés dans Yunohost, ils sont également supprimés dans Calibreweb. - ### Gestion de la bibliothèque -* La **bibliothèque** sera placée dans `/home/yunohost.multimedia/share/eBook` sauf si simultanément : - - Calibreweb est paramétré comme une application privée - - La bibliothèque Calibreweb est paramétrée comme une bilbiothèque privée - -Dans ce cas, la bibliothèque sera placée dans `/home/yunohost.multimedia/[admin]/eBook`. Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur. - * Par défaut, le processus de backup de Yunohost **archivera** la bibliothèque Calibreweb. Vous pouvez le désactiver avec cette commande: ``` @@ -47,18 +36,6 @@ La numérotation est modifiée dans yunohost par rapport à Calibre-web: la vers ### Problèmes connus -* Ne pas utiliser un répertoire Nextcloud pour y installer la bibliothèque: Cela fonctionnera s'il s'agit d'un stockage externe à Nextcloud, mais pas dans le cas d'un répertoire interne qui causerait des problèmes lors des synchronisations. -* La fonction "Magic link" n'est pas disponible +* Ne pas utiliser un répertoire Nextcloud pour y installer la bibliothèque: Cela fonctionnera s'il s'agit d'un stockage externe à Nextcloud, mais pas dans le cas d'un répertoire interne qui causerait des problèmes lors des synchronisations. * Les changements fait à la bibliothèque en dehors de Calibreweb ne sont pas automatiquement vu par Calibreweb : Il est nécessaire de se déconnecter puis reconnecter ou redémarrer le service pour que les modifications soient visibles : N'utilisez donc pas simultanément Calibre et Calibreweb sur la même bibliothèque! * La synchronisation Kobo ne fonctionne pas quand Calibreweb est installée dans un sous-domaine. Ce problème est causé par nginx. Par contre, cela fonctionne très bien quand installé dans un répertoire, par exemple `https://domain.tld/calibreweb` - -## Todo -- [ ] Mise à jour des réglages mails -- [ ] Activation de magic link -- [ ] Add cronjob to reload database (for nextcloud integration) -- [ ] Add config-panel option to trigger do_not_backup_data -- [ ] Add config-panel to manage max upload size -- [ ] Add action to restart the server -- [ ] Add action to synchronize users -- [ ] Add action to deactivate LDAP et retrieve admin password -- [ ] Use internal updater to update version? diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..d731e42 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Browsing, reading and downloading eBooks using a Calibre database \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..cbcc939 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre \ No newline at end of file diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..b2847d1 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,5 @@ +### Post install + +Users having the calibreweb.main authorization group can be automatically sync from within the app, by using the "Import LDAP user" function. +Deletion of a Yunohost User will delete the according calibreweb-user. + diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..4c9a669 --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,4 @@ +### Post installation + +Les utilisateurs appartenant au groupe d'autorisation calibreweb.main peuvent être synchronisé automatiquement depuis l'application en utilisant la fonction "Importer les utilisateurs LDAP". +Lorsque les utilisateurs sont supprimés dans Yunohost, ils sont également supprimés dans Calibreweb. diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..02ff235 --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,3 @@ +If calibreweb library is set as a public library, it will be placed in `/home/yunohost.multimedia/share/eBook` +If not, it will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. +Library folder can always be changed manually in the application settings by the administrator. diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..440d01c --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,3 @@ +Si la bibliothèque Calibreweb est paramétrée comme une bilbiothèque publique, elle sera placée dans `/home/yunohost.multimedia/share/eBook`. +Si non, elle sera placée dans `/home/yunohost.multimedia/[admin]/eBook`. +Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur. \ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 32c2a06..0000000 --- a/manifest.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "name": "Calibre-web", - "id": "calibreweb", - "packaging_format": 1, - "description": { - "en": "Browsing, reading and downloading eBooks using a Calibre database", - "fr": "Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre" - }, - "version": "0.6.20~ynh1", - "url": "https://github.com/janeczku/calibre-web", - "upstream": { - "version": "0.6.20", - "license": "GPL-3.0-only", - "admindoc": "https://github.com/janeczku/calibre-web/wiki", - "code": "https://github.com/janeczku/calibre-web" - }, - "license": "GPL-3.0-only", - "maintainer": { - "name": "Krakinou", - "email": "misterl56@hotmail.com" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/calibre", - "default": "/calibre" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "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 - }, - { - "name": "language", - "type": "string", - "optional": true, - "ask": { - "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" - }, - { - "name": "upload", - "type": "boolean", - "optional": true, - "ask": { - "en": "Do you want to allow uploading of books?", - "fr": "Voulez vous autoriser le téléversement de livres?" - }, - "help": { - "en": "You may change it later in the app", - "fr": "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?" - }, - "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/manifest.toml b/manifest.toml new file mode 100644 index 0000000..3992fe5 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,101 @@ +packaging_format = 2 + +id = "calibreweb" +name = "Calibre-web" +description.en = "Browsing, reading and downloading eBooks using a Calibre database" +description.fr = "Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre" + +version = "0.6.20~ynh1" + +maintainers = ["Krakinou"] + +[upstream] +license = "GPL-3.0-only" +admindoc = "https://github.com/janeczku/calibre-web/wiki" +code = "https://github.com/janeczku/calibre-web" + +[integration] +yunohost = ">= 4.3.0" +architectures = "all" +multi_instance = true +ldap = true +sso = true +disk = "400M" +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/calibre" + + [install.admin] + type = "user" + + [install.language] + ask.en = "Select a default language" + ask.fr = "Choisissez une langue par défaut" + help.en = "You may change it later in the app" + help.fr = "Vous pourrez la changer ultérieurement dans l'application" + type = "select" + optional = true + choices = ["fr", "en", "es", "de"] + default = "fr" + + [install.upload] + ask.en = "Do you want to allow uploading of books?" + ask.fr = "Voulez vous autoriser le téléversement de livres?" + help.en = "You may change it later in the app" + help.fr = "Vous pourrez le changer ultérieurement dans l'application" + type = "boolean" + optional = true + default = false + + [install.public_library] + ask.en = "Do you want to allow access to the library to all Yunohost users? " + ask.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" + help.fr = "Oui parametrera la bibliothèque pour /home/yunohost.multimedia/share/eBook" + type = "boolean" + optional = true + default = true + +[resources] + [resources.sources] + [resources.sources.main] + url = "https://github.com/janeczku/calibre-web/releases/download/0.6.20/calibre-web-0.6.20.zip" + sha256 = "2f1f8a5ae06f182986193a90796fa96a7b0b5c61fdd29971969b49245b1aaf24" + + autoupdate.strategy = "latest_github_release" + autoupdate.asset = "calibre-web-.*.zip" + + [resources.sources.kepubify] + arm64.url = "https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-arm64" + arm64.sha256="5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3" + armhf.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-arm" + armhf.sha256="07f23275c4e674093443f01a591aa0980b0b87dbb0a10986d5001e9d56b0e1e7" + i386.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-32bit" + i386.sha256="3365a848ce06d43fca8f1999eb69c6c8e0e20a56b6b8658a8466b9726adef0f5" + amd64.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-64bit" + amd64.sha256="37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5" + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + kobo.url= "/kobo" + kobo.show_tile= false + kobo.allowed= "visitors" + + [resources.ports] + main.default = 8083 + + [resources.apt] + packages = [ "sqlite3", "imagemagick", "libldap2-dev", "libsasl2-dev", "python3-venv", "python3-dev", "python3-lxml", "libjpeg-dev", "zlib1g-dev", "libffi-dev" ] + \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 1b177ab..3e215b2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,42 +1,8 @@ #!/bin/bash -PKG_DEPENDENCIES="sqlite3 imagemagick libldap2-dev libsasl2-dev python3-venv python3-dev python3-lxml libjpeg-dev zlib1g-dev libffi-dev" -#PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick" - DOSSIER_MEDIA=/home/yunohost.multimedia - -#These var are used in init_calibre_db_settings conf file log_file=/var/log/$app/$app.log access_log_file=/var/log/$app/$app-access.log -mach=`uname -m` -sha256_32bit=3365a848ce06d43fca8f1999eb69c6c8e0e20a56b6b8658a8466b9726adef0f5 -sha256_64bit=37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5 -sha256_arm=07f23275c4e674093443f01a591aa0980b0b87dbb0a10986d5001e9d56b0e1e7 -sha256_arm64=5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3 -sha256_armv6=7912901dc7b6f51e119f59cfd1f3f8ac2a5c64c42efba9d69ebf2ea8c3a7a2c9 - - - -case "$mach" in - "armv6l" ) mach="arm" - sha256=$sha256_arm - ;; - "armv7l" ) mach="arm" - sha256=$sha256_arm - ;; - "armv8l" ) mach="arm64" - sha256=$sha256_arm64 - ;; - "aarch64" ) mach="arm64" - sha256=$sha256_arm64 - ;; - "x86_64" ) mach="64bit" - sha256=$sha256_64bit - ;; - * ) mach="32bit" - sha256=$sha256_32bit - ;; -esac diff --git a/scripts/backup b/scripts/backup index e02e021..5bb9056 100755 --- a/scripts/backup +++ b/scripts/backup @@ -9,26 +9,9 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -path_url=$(ynh_app_setting_get $app path) -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) #Get settings from database in case it has been changed in the app -calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") +calibre_dir=$(sqlite3 $install_dir/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") #Save it in settings so that it can be used back afterward calibre_dir=${calibre_dir%/} ynh_app_setting_set $app calibre_dir $calibre_dir @@ -43,7 +26,7 @@ ynh_print_info --message="Declaring files to be backed up..." #================================================= #This will backup the app.db file at the same time -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE KEPUBIFY BINARY diff --git a/scripts/change_url b/scripts/change_url index fc03a01..5195dab 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,27 +8,6 @@ source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) -port=$(ynh_app_setting_get $app port) - -#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script -#when initializing the conf file of the app source _common.sh #================================================= @@ -36,44 +15,6 @@ source _common.sh #================================================= ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=10 -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK THE SYNTAX OF THE PATHS -#================================================= - -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -86,35 +27,8 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 - -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the nginx config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" - # Set global variables for nginx helper - domain="$old_domain" - 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 " 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 -fi - -# Change the domain for nginx -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -125,13 +39,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30 -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index fa49f0c..c024ffe 100755 --- a/scripts/install +++ b/scripts/install @@ -6,84 +6,27 @@ # IMPORT GENERIC HELPERS #================================================= - +source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= -app=$YNH_APP_INSTANCE_NAME - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) -is_public=$YNH_APP_ARG_IS_PUBLIC -language=$YNH_APP_ARG_LANGUAGE -upload=$YNH_APP_ARG_UPLOAD -public_library=$YNH_APP_ARG_PUBLIC_LIBRARY -#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script -#when initializing the conf file of the app -source _common.sh - -#if app is public, we assume library is public -if [ $is_public -eq 1 ]; then - public_library=1 -fi - -if [ $is_public -eq 1 ]; then #app is public, library is public +if [ $public_library -eq 1 ]; then 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 +else # library is private calibre_dir=$DOSSIER_MEDIA/$admin/eBook fi -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=5 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=5 - -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin - #================================================= # STANDARD MODIFICATIONS #================================================= -# FIND AN AVAILABLE PORT -#================================================= - -# Find a free port -port=$(ynh_find_port 8083) -ynh_script_progression --message="Setting port $port..." --weight=5 -ynh_app_setting_set $app port $port #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Downloading sources to $final_path..." --weight=10 -ynh_app_setting_set $app final_path $final_path +ynh_script_progression --message="Downloading sources to $install_dir..." --weight=10 +#REMOVEME? ynh_app_setting_set $app install_dir $install_dir #Set settings constant initializer of the app ynh_add_config --template="../sources/patches/app-config_sql.py.patch.src" --destination="../sources/patches/app-config_sql.py.patch" @@ -91,50 +34,55 @@ ynh_add_config --template="../sources/patches/app-ub.py.patch.src" --destination ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch" # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$install_dir" #install kepubify converter ynh_script_progression --message="Installing kepubify..." --weight=1 -ynh_add_config --template="../conf/appkepubify.src.default" --destination="../conf/appkepubify.src" -ynh_setup_source --dest_dir="/opt/kepubify" --source_id="appkepubify" - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 -# Create a system user -ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell +ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing package dependencies..." --weight=80 -ynh_install_app_dependencies $PKG_DEPENDENCIES - #Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install ynh_script_progression --message="Installing pip requirements..." --weight=70 # Always recreate everything fresh with current python version -if [ -d "${final_path}/venv" ] ; then - ynh_secure_remove "${final_path}/venv" +if [ -d "${install_dir}/venv" ] ; then + ynh_secure_remove "${install_dir}/venv" fi # Skip pip because of: https://github.com/YunoHost/issues/issues/1960 -python3 -m venv --without-pip "${final_path}/venv" -chown -R "$app:" "$final_path" +python3 -m venv --without-pip "${install_dir}/venv" +chown -R "$app:" "$install_dir" #run source in a 'sub shell' ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" set -o nounset - ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip - ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt" - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip + ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt" ) +#================================================= +# CREATE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Creating files and directory..." --weight=5 + +#build multimedia directory +ynh_multimedia_build_main_dir +ynh_multimedia_addaccess $app + +#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_app_setting_set $app calibre_dir $calibre_dir #================================================= # NGINX CONFIGURATION @@ -143,7 +91,7 @@ chown -R "$app:" "$final_path" ynh_script_progression --message="Setting up system configuration..." --weight=5 -if [ $path_url = "/" ] ; then +if [ $path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi @@ -158,32 +106,9 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# CREATE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Creating files and directory..." --weight=5 -#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. - -#build multimedia directory -ynh_multimedia_build_main_dir -ynh_multimedia_addaccess $app - - -#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_app_setting_set $app calibre_dir $calibre_dir - #================================================= # SETUP LOGROTATE #================================================= - # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile="$log_file" ynh_use_logrotate --logfile="/var/log/$app/$access_log_file" @@ -193,21 +118,11 @@ chown -R $app:$app /var/log/$app #================================================= # SPECIFIC SETUP #================================================= - #Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files ynh_replace_string --match_string="" \ --replace_string="" \ --target_file="/etc/ImageMagick-6/policy.xml" - - -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -# Calculate and store the config file checksum into the app settings -#ynh_store_file_checksum "${final_path}/app.db" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -221,8 +136,8 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi # SECURE FILES AND DIRECTORIES #================================================= -chown -R $app: $final_path -chmod 740 $final_path +chown -R $app: $install_dir +chmod 740 $install_dir chown -R $app: /opt/kepubify chmod 770 /opt/kepubify/kepubify-linux-$mach @@ -240,29 +155,11 @@ fi # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: .*$" --max_retry=5 -#================================================= -# SETUP SSOWAT -#================================================= - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - #ynh_app_setting_set $app unprotected_uris "/" - ynh_permission_update --permission "main" --add visitors -fi -if [ $public_library -eq 0 ]; then - ynh_permission_update --permission "main" --add $admin -fi - -#Kobo sync permission -ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload nginx and start $app..." --weight=5 -ynh_systemd_action --service_name=nginx --action=reload +ynh_script_progression --message="Start $app..." --weight=5 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30 #================================================= diff --git a/scripts/remove b/scripts/remove index 16b2d82..981fa96 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 - -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -final_path=$(ynh_app_setting_get $app final_path) -calibre_dir=$(ynh_app_setting_get $app calibre_dir) - - #================================================= # REMOVE SERVICE FROM ADMIN PANEL #================================================= @@ -43,24 +31,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config - -#================================================= -# REMOVE DEPENDENCIES -#================================================= - -# Remove metapackage and its dependencies -ynh_script_progression --message="Removing Dependencies..." --weight=25 -ynh_remove_app_dependencies - - -#================================================= -# REMOVE APP MAIN DIR -#================================================= - -# Remove the app directory securely -ynh_script_progression --message="Removing $final_path..." --weight=1 -ynh_secure_remove --file="$final_path" - #================================================= # REMOVE DATA DIR #================================================= @@ -125,15 +95,6 @@ fi ynh_script_progression --message="Removing log file..." --weight=1 ynh_secure_remove "/var/log/$app/" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -# Delete a system user -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 -ynh_system_user_delete --username=$app - #================================================= # MESSAGE TO USER #================================================= diff --git a/scripts/restore b/scripts/restore index a85bb32..7ff7f48 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,38 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -calibre_dir=$(ynh_app_setting_get $app calibre_dir) -port=$(ynh_app_setting_get $app port) - -#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script -#when initializing the conf file of the app -source ../settings/scripts/_common.sh - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path || ynh_die "There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -47,27 +18,11 @@ test ! -d $final_path || ynh_die "There is already a directory: $final_path " ynh_script_progression --message="Restoring nginx configuration..." --weight=1 ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# REOPEN PORT -#================================================= - -ynh_script_progression --message="reopening port $port..." --weight=5 -ynh_app_setting_set $app port $port - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= - -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" #================================================= # RESTORE THE KEPUBIFY BINARIES @@ -79,40 +34,30 @@ ynh_restore_file --origin_path="/opt/kepubify" #================================================= # RESTORE USER RIGHTS #================================================= -chown -R $app: $final_path -chmod 740 $final_path - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= - -# Define and install dependencies -ynh_script_progression --message="Reinstalling dependencies..." --weight=15 -ynh_install_app_dependencies $PKG_DEPENDENCIES +chown -R $app: $install_dir +chmod 740 $install_dir #Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install ynh_script_progression --message="Reinstalling pip requirements..." --weight=70 # Always recreate everything fresh with current python version # When reinstalling on a new yunohost, this is required -if [ -d "${final_path}/venv" ] ; then - ynh_secure_remove "${final_path}/venv" +if [ -d "${install_dir}/venv" ] ; then + ynh_secure_remove "${install_dir}/venv" fi # Skip pip because of: https://github.com/YunoHost/issues/issues/1960 -python3 -m venv --without-pip "${final_path}/venv" -chown -R "$app:" "$final_path" +python3 -m venv --without-pip "${install_dir}/venv" +chown -R "$app:" "$install_dir" #run source in a 'sub shell' ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" set -o nounset - ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip - ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt" - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip + ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt" ) #================================================= @@ -146,11 +91,7 @@ chown -R $app:$app /var/log/$app #================================================= ynh_script_progression --message="Restoring data directory if required..." --weight=2 -# The data directory will be restored only if it exists in the backup archive -# So only if it was backup previously. -#if [ -d "$YNH_BACKUP_DIR/apps/$app/backup/$calibre_dir" ] && [ ! tail "$calibre_dir" | grep "yunohost.multimedia" ]; then - ynh_restore_file --origin_path="$calibre_dir" --not_mandatory -#fi +ynh_restore_file --origin_path="$calibre_dir" --not_mandatory #================================================= # RESTORE THE MULTIMEDIA DIR IF NOT EXISTING diff --git a/scripts/upgrade b/scripts/upgrade index 3e18a0c..92c4cd1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,33 +9,17 @@ version_gt() { #================================================= # IMPORT GENERIC HELPERS #================================================= - +source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) -final_path=$(ynh_app_setting_get $app final_path) -language=$(ynh_app_setting_get $app language) - -#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script -#when initializing the conf file of the app -source _common.sh #Get settings from database in case it has been changed in the app and save it in settings so that it can be used back afterward -calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") +calibre_dir=$(sqlite3 $install_dir/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") calibre_dir=${calibre_dir%/} ynh_app_setting_set $app calibre_dir $calibre_dir -upload=$(sqlite3 $final_path/app.db "SELECT config_uploading FROM settings WHERE ID=1") +upload=$(sqlite3 $install_dir/app.db "SELECT config_uploading FROM settings WHERE ID=1") ynh_app_setting_set $app upload $upload #================================================= @@ -50,31 +34,19 @@ current_upstream_package_version="${current_upstream_package_version/".96"/".6"} new_upstream_package_version=$(ynh_app_upstream_version) #0.96.0 new_upstream_package_version="${new_upstream_package_version/".96"/".6"}" #0.6.0 -if [ -f $final_path/cps/constants.py ]; then #on est dans une version postérieur à la 0.6.0 - current_upstream_app_version=$(cat $final_path/cps/constants.py | grep STABLE_VERSION) - current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}" - current_upstream_app_version="${current_upstream_app_version/\'\}/""}" -else #on est encore en 0.6.0 - current_upstream_app_version='0.6.0' -fi +#if [ -f $install_dir/cps/constants.py ]; then #on est dans une version postérieur à la 0.6.0 +# current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_VERSION) +# current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}" +# current_upstream_app_version="${current_upstream_app_version/\'\}/""}" +#else #on est encore en 0.6.0 +# current_upstream_app_version='0.6.0' +#fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - - ynh_clean_check_starting - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_clean_check_starting #Stop the app in case database is updated ynh_script_progression --message="Stopping a systemd service..." --weight=2 @@ -92,71 +64,27 @@ then yunohost firewall disallow TCP $port 2>&1 fi -# If language was set delete it -if [ ! -z "$language" ]; then - ynh_app_setting_delete --app=$app --key=language -fi - -#binaries version is 0.6.0, we need to go throught upgrade to 0.6.6 so that app.db is correctly updated, otherwise database is corrupted -#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap & log settings -if version_gt "0.6.6" "$current_upstream_app_version" && [ "$current_upstream_package_version" == "0.6.0" ] && [ "$upgrade_type" == "UPGRADE_APP" ]; then - ynh_script_progression --message="Upgrading from $current_upstream_app_version to 0.6.6..." --weight=50 - ynh_setup_source --dest_dir="$final_path" --source_id="app066" - pip install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/requirements.txt - chown -R $app: $final_path - #set database settings as per conf file : restart server so that app.db is regenerated - ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server" --log_path="$final_path/calibre-web.log" -t 30 - #sleep required on low spec like raspberryPi - sleep 2s - ynh_systemd_action --service_name=$app --action="stop" - 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" - current_upstream_app_version="0.6.6" -fi - #LDAP settings were wrongly set in version prior to 0.6.13 and we could not retrieve LDAP users. This will change the settings to correct values -if sqlite3 $final_path/app.db "SELECT config_ldap_group_object_filter FROM settings" \ +if sqlite3 $install_dir/app.db "SELECT config_ldap_group_object_filter FROM settings" \ | grep -xq "(&(objectClass=posixGroup)(permission=cn=%s.main,ou=permission,dc=yunohost,dc=org))" ; then - eval sqlite3 $final_path/app.db "\"UPDATE settings SET config_ldap_group_object_filter='(&(objectClass=posixGroup)(cn=%s.main))' WHERE ID=1\"" + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_ldap_group_object_filter='(&(objectClass=posixGroup)(cn=%s.main))' WHERE ID=1\"" fi -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi #Adding kepubify converter -if [ -z $(sqlite3 $final_path/app.db "SELECT config_kepubifypath FROM settings") ]; then - eval sqlite3 $final_path/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\"" +if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings") ]; then + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\"" fi if [ ! -d /opt/kepubify ]; then - ynh_add_config --template="../conf/appkepubify.src.default" --destination="../conf/appkepubify.src" - ynh_setup_source --dest_dir="/opt/kepubify" --source_id="appkepubify" + ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" chmod 770 /opt/kepubify/kepubify-linux-$mach fi -# Create the permission "kobo_sync" only if it doesn't exist. -if ! ynh_permission_exists --permission="Kobo sync" -then - # API Authorization with dedicated URL - ynh_print_warn --message="This version has now a dedicated Kobo sync authorization, please review group and permission" - ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true" -else - ##TO BE DELETED - error in testing has led to bad permission settings - ynh_permission_delete --permission="Kobo sync" - ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true" -fi - #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - - - if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..." --weight=10 @@ -167,7 +95,8 @@ then ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" + chown -R $app: $install_dir fi #================================================= @@ -175,21 +104,12 @@ fi #================================================= ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5 -if [ $path_url = "/" ] ; then +if [ $path = "/" ] ; 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 -#================================================= -# CREATE DEDICATED USER -#================================================= - -# Create a dedicated user (if not existing) -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell -# Set permissions on app files (required to be able to update database) -chown -R $app: $final_path #================================================= @@ -198,30 +118,27 @@ chown -R $app: $final_path if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Installing package dependencies..." --weight=15 - ynh_install_app_dependencies $PKG_DEPENDENCIES - #Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install ynh_script_progression --message="Installing pip requirements..." --weight=70 # Always recreate everything fresh with current python version - if [ -d "${final_path}/venv" ] ; then - ynh_secure_remove "${final_path}/venv" + if [ -d "${install_dir}/venv" ] ; then + ynh_secure_remove "${install_dir}/venv" fi # Skip pip because of: https://github.com/YunoHost/issues/issues/1960 - python3 -m venv --without-pip "${final_path}/venv" - chown -R "$app:" "$final_path" + python3 -m venv --without-pip "${install_dir}/venv" + chown -R "$app:" "$install_dir" #run source in a 'sub shell' ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" set -o nounset - ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip - ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt" - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip + ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt" + ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt" ) fi @@ -270,7 +187,7 @@ ynh_add_systemd_config #================================================= # Set permissions on app files -chown -R $app: $final_path +chown -R $app: $install_dir chown -R $app: /opt/kepubify #================================================= @@ -294,13 +211,6 @@ fi # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: .*$" --max_retry=5 - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..484efb0 --- /dev/null +++ b/tests.toml @@ -0,0 +1,14 @@ +test_format = 1.0 + +[default] + + args.language = "en" + args.upload = true + args.public_library = true + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.30f2c9d.name = "Upgrade from 0.6.20~ynh1" + From c108d59adcaed1b31d9c8c4389e1f5f3e02e222a Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 25 Jul 2023 23:01:38 +0000 Subject: [PATCH 02/33] Auto-update README --- README.md | 70 ++-------------------------------------------------- README_fr.md | 70 ++-------------------------------------------------- 2 files changed, 4 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 9127743..653ad9e 100644 --- a/README.md +++ b/README.md @@ -18,78 +18,12 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Browsing, reading and downloading eBooks using a Calibre database -**Shipped version:** 0.6.20 +**Shipped version:** 0.6.20~ynh1 + ## Screenshots ![Screenshot of Calibre-web](./doc/screenshots/screenshot.png) -## Disclaimers / important information - - -### Post install - -Users having the calibreweb.main authorization group can be automatically sync from within the app, by using the "Import LDAP user" function. -Deletion of a Yunohost User will delete the according calibreweb-user. - - -### Library management - -* **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 administrator. - -* By default, Yunohost backup process **will backup** Calibreweb library. -You may deactivate backup of the library with -``` -yunohost app setting calibreweb do_not_backup_data -v 1 -``` - -* By default, removing the app will **never** delete the library. - - -* Authorization access to library to be done manually after install if Calibre library was already existing (except in yunohost.multimedia directory), for example : -``` -chown -R calibreweb: path/to/library -or -chmod o+rw path/to/library -``` - -### Kobo Sync - -Calibre-web comes with a [synching feature with a kobo device](https://github.com/janeczku/calibre-web/wiki/Kobo-Integration). You can activate this feature from inside the app in the administration menu. You need to set port 443 as the external server port. -A dedicated permission "Kobo sync" is created by default by the app so that you don't need to expose the whole app for synching. - -[Kepubify](https://pgaskin.net/kepubify/) is also set up as the default kepub converter during installation : This means that your whole library will be converted to kepub when creating the sync token for the first time (this will not affect the existing epubs). This can take a long time : For reference, I have around 10K ebooks on my calibre library and the conversion lasted around 3-4hours on a raspberry Pi 4. - -### OPDS - -For **OPDS** to work, most OPDS-readers will require the app must be set in public mode. -Also, you may have to activate the "anonym browsing" for some reader to access book covers or download books ([source](https://github.com/janeczku/calibre-web/wiki/FAQ#which-opds-readers-work-with-calibre-web)). - -### Versionning - -Version number in Yunohost is different from the upstream Calibre-web app : version 0.X.Y becomes 0.9.X.Y in Yunohost. This is due to the fact that Calibre-web was not versionned when first packages were built. - -### Known Limitations - -* 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 : Do not open a database both in Calibre & Calibreweb! -* Kobo Sync doesn’t work when Calibreweb is installed on a subdomain. This issue is caused by nginx. However, it works great when installed on a path e.g. `https://domain.tld/calibreweb` - -### Todo -- [ ] Update mail settings with yunohost settings -- [ ] enable magic link -- [ ] Add cronjob to reload database (for nextcloud integration) -- [ ] Add config-panel option to trigger do_not_backup_data -- [ ] Add config-panel to manage max upload size -- [ ] Add action to restart the server -- [ ] Add action to synchronize users -- [ ] Add action to deactivate LDAP et retrieve admin password -- [ ] Use internal updater to update version? - ## Documentation and resources * Official admin documentation: diff --git a/README_fr.md b/README_fr.md index ebb1bd3..d93234e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,78 +18,12 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre -**Version incluse :** 0.6.20 +**Version incluse :** 0.6.20~ynh1 + ## Captures d’écran ![Capture d’écran de Calibre-web](./doc/screenshots/screenshot.png) -## Avertissements / informations importantes - - -### Post installation - -Les utilisateurs appartenant au groupe d'autorisation calibreweb.main peuvent être synchronisé automatiquement depuis l'application en utilisant la fonction "Importer les utilisateurs LDAP". -Lorsque les utilisateurs sont supprimés dans Yunohost, ils sont également supprimés dans Calibreweb. - - -### Gestion de la bibliothèque - -* La **bibliothèque** sera placée dans `/home/yunohost.multimedia/share/eBook` sauf si simultanément : - - Calibreweb est paramétré comme une application privée - - La bibliothèque Calibreweb est paramétrée comme une bilbiothèque privée - -Dans ce cas, la bibliothèque sera placée dans `/home/yunohost.multimedia/[admin]/eBook`. Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur. - -* Par défaut, le processus de backup de Yunohost **archivera** la bibliothèque Calibreweb. -Vous pouvez le désactiver avec cette commande: -``` -yunohost app setting calibreweb do_not_backup_data -v 1 -``` - -* Par défaut, supprimer l'application **ne supprimera jamais** la bibliothèque. - - -* Si la bibliothèque existait avant l'installation de Calibreweb, les accès à celle-ci doivent être géré manuellement (sauf pour celle dans yunohost.multimedia directory). Par exemple : -``` -chown -R calibreweb: chemin/vers/bibliothèque -ou -chmod o+rw chemin/vers/bibliothèque -``` - -### Synchronisation Kobo - -Calibre-web possède [une fonction de synchronisation avec les liseuses Kobo](https://github.com/janeczku/calibre-web/wiki/Kobo-Integration). Vous pouvez activer cette fonctionnalité depuis le menu d'administration de l'application. Il faut paramétrer le port 443 comme port externe du serveur. -Une permission spécifique "Kobo sync" est créée lors de l'installation de l'application afin de ne pas avoir à exposer l'application entière. - -[Kepubify](https://pgaskin.net/kepubify/) est également installé en tant que convertisseur par défaut vers le format kepub : Cela signifie que l'intégralité de votre bibliothèque sera convertie en format kepub lorsque vous créerez le jeton de synchronisation pour la première fois (ceci n'affecte pas les epubs existant). Cela peut prendre un certain temps : Par exemple, j'ai environ 10K livres dans ma bibliothèque calibre, et la conversion a durée environ 3-4h sur un Raspberry Pi 4 . - -### OPDS - -Pour que l'**OPDS** fonctionne, la plupart des lecteurs OPDS exigent que l'application soit en accès publique. -Egalement, il se peut que l'activation de l'accès anonyme soit nécessaire pour accéder aux bibliothèque ou télécharger les livres sur certains lecteurs : ([source](https://github.com/janeczku/calibre-web/wiki/FAQ#which-opds-readers-work-with-calibre-web)). - -### Version - -La numérotation est modifiée dans yunohost par rapport à Calibre-web: la version 0.X.Y devient 0.9X.Y dans yunohost. Cela provient du fait que Calibre-web n'était pas versionné lors des premiers packages. - -### Problèmes connus - -* Ne pas utiliser un répertoire Nextcloud pour y installer la bibliothèque: Cela fonctionnera s'il s'agit d'un stockage externe à Nextcloud, mais pas dans le cas d'un répertoire interne qui causerait des problèmes lors des synchronisations. -* La fonction "Magic link" n'est pas disponible -* Les changements fait à la bibliothèque en dehors de Calibreweb ne sont pas automatiquement vu par Calibreweb : Il est nécessaire de se déconnecter puis reconnecter ou redémarrer le service pour que les modifications soient visibles : N'utilisez donc pas simultanément Calibre et Calibreweb sur la même bibliothèque! -* La synchronisation Kobo ne fonctionne pas quand Calibreweb est installée dans un sous-domaine. Ce problème est causé par nginx. Par contre, cela fonctionne très bien quand installé dans un répertoire, par exemple `https://domain.tld/calibreweb` - -## Todo -- [ ] Mise à jour des réglages mails -- [ ] Activation de magic link -- [ ] Add cronjob to reload database (for nextcloud integration) -- [ ] Add config-panel option to trigger do_not_backup_data -- [ ] Add config-panel to manage max upload size -- [ ] Add action to restart the server -- [ ] Add action to synchronize users -- [ ] Add action to deactivate LDAP et retrieve admin password -- [ ] Use internal updater to update version? - ## Documentations et ressources * Documentation officielle de l’admin : From bb79719ed654b309a366ed05f4a34b0feb7a44d5 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 26 Jul 2023 08:05:41 +0200 Subject: [PATCH 03/33] fix mach = uname -m --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3e215b2..bd9bcc2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,6 +3,6 @@ DOSSIER_MEDIA=/home/yunohost.multimedia log_file=/var/log/$app/$app.log access_log_file=/var/log/$app/$app-access.log - +mach=`uname -m` From dc3f2bb6a4d5c3c7000d0e6825c3a26e4c44aa37 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 26 Jul 2023 08:10:14 +0200 Subject: [PATCH 04/33] fix mach = uname -m --- scripts/_common.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index bd9bcc2..8ebafe9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,3 +6,19 @@ access_log_file=/var/log/$app/$app-access.log mach=`uname -m` + + +case "$mach" in + "armv6l" ) mach="arm" + ;; + "armv7l" ) mach="arm" + ;; + "armv8l" ) mach="arm64" + ;; + "aarch64" ) mach="arm64" + ;; + "x86_64" ) mach="64bit" + ;; + * ) mach="32bit" + ;; +esac \ No newline at end of file From 47df77cd0882c66fc2ff7db8c57e9dcdb32416c8 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 00:22:34 +0200 Subject: [PATCH 05/33] Fix kepubify --- scripts/install | 2 +- scripts/upgrade | 2 +- sources/patches/app-config_sql.py.patch.src | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index c024ffe..04a4107 100755 --- a/scripts/install +++ b/scripts/install @@ -139,7 +139,7 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi chown -R $app: $install_dir chmod 740 $install_dir chown -R $app: /opt/kepubify -chmod 770 /opt/kepubify/kepubify-linux-$mach +chmod 770 /opt/kepubify/kepubify #================================================= # SETUP FAIL2BAN diff --git a/scripts/upgrade b/scripts/upgrade index 92c4cd1..735a46f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,7 @@ if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings" fi if [ ! -d /opt/kepubify ]; then ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" - chmod 770 /opt/kepubify/kepubify-linux-$mach + chmod 770 /opt/kepubify/kepubify fi #================================================= diff --git a/sources/patches/app-config_sql.py.patch.src b/sources/patches/app-config_sql.py.patch.src index 6fad06e..903215d 100644 --- a/sources/patches/app-config_sql.py.patch.src +++ b/sources/patches/app-config_sql.py.patch.src @@ -55,7 +55,7 @@ config_ldap_group_name = Column(String, default='calibreweb') - config_kepubifypath = Column(String, default=None) -+ config_kepubifypath = Column(String, default='/opt/kepubify/kepubify-linux-__MACH__') ++ config_kepubifypath = Column(String, default='/opt/kepubify/kepubify') config_converterpath = Column(String, default=None) config_calibre = Column(String) config_rarfile_location = Column(String, default=None) From 30a5940fbf50cfd32e43104dc241505c5b994ed0 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 00:22:53 +0200 Subject: [PATCH 06/33] Fix install_dir --- conf/systemd.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 1ced809..bdc4a9d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=/bin/sh -c '__FINALPATH__/venv/bin/python3 __FINALPATH__/cps.py' +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=/bin/sh -c '__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/cps.py' # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these From 45b15a76ff558e7ad078fa87a05bd1323dd4ce9c Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 00:23:41 +0200 Subject: [PATCH 07/33] New version --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 3992fe5..1433857 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Calibre-web" description.en = "Browsing, reading and downloading eBooks using a Calibre database" description.fr = "Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre" -version = "0.6.20~ynh1" +version = "0.6.20~ynh2" maintainers = ["Krakinou"] From 59ddd3cc8d8a3e26434dace0c27fe0ec346ae0be Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 28 Jul 2023 22:23:45 +0000 Subject: [PATCH 08/33] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 653ad9e..f2bc767 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Browsing, reading and downloading eBooks using a Calibre database -**Shipped version:** 0.6.20~ynh1 +**Shipped version:** 0.6.20~ynh2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index d93234e..80c1a51 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre -**Version incluse :** 0.6.20~ynh1 +**Version incluse :** 0.6.20~ynh2 ## Captures d’écran From a686db4aaca993d502d38866e6c95b9cfdb44459 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 00:24:34 +0200 Subject: [PATCH 09/33] fixme --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 1433857..43a39fd 100644 --- a/manifest.toml +++ b/manifest.toml @@ -21,8 +21,8 @@ multi_instance = true ldap = true sso = true disk = "400M" -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.build = "200M" +ram.runtime = "200M" [install] [install.domain] From 2ef1482c9b6c05d2e032816d763f0ee8056534c4 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 13:57:34 +0200 Subject: [PATCH 10/33] Fix patching of sources --- manifest.toml | 2 +- scripts/install | 8 ++++---- scripts/remove | 3 ++- scripts/upgrade | 6 +++--- .../{app-admin.html.patch => main-admin.html.patch} | 0 ...nfig_sql.py.patch.src => main-config_sql.py.patch.src} | 0 ...constants.py.patch.src => main-constants.py.patch.src} | 0 ...nts.txt.patch => main-optional-requirements.txt.patch} | 0 .../patches/{app-ub.py.patch.src => main-ub.py.patch.src} | 0 9 files changed, 10 insertions(+), 9 deletions(-) rename sources/patches/{app-admin.html.patch => main-admin.html.patch} (100%) rename sources/patches/{app-config_sql.py.patch.src => main-config_sql.py.patch.src} (100%) rename sources/patches/{app-constants.py.patch.src => main-constants.py.patch.src} (100%) rename sources/patches/{app-optional-requirements.txt.patch => main-optional-requirements.txt.patch} (100%) rename sources/patches/{app-ub.py.patch.src => main-ub.py.patch.src} (100%) diff --git a/manifest.toml b/manifest.toml index 43a39fd..a095012 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Calibre-web" description.en = "Browsing, reading and downloading eBooks using a Calibre database" description.fr = "Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre" -version = "0.6.20~ynh2" +version = "0.96.20~ynh2" maintainers = ["Krakinou"] diff --git a/scripts/install b/scripts/install index 04a4107..f70331b 100755 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,9 @@ ynh_script_progression --message="Downloading sources to $install_dir..." --weig #REMOVEME? ynh_app_setting_set $app install_dir $install_dir #Set settings constant initializer of the app -ynh_add_config --template="../sources/patches/app-config_sql.py.patch.src" --destination="../sources/patches/app-config_sql.py.patch" -ynh_add_config --template="../sources/patches/app-ub.py.patch.src" --destination="../sources/patches/app-ub.py.patch" -ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch" +ynh_add_config --template="../sources/patches/main-config_sql.py.patch.src" --destination="../sources/patches/main-config_sql.py.patch" +ynh_add_config --template="../sources/patches/main-ub.py.patch.src" --destination="../sources/patches/main-ub.py.patch" +ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -111,7 +111,7 @@ ynh_add_systemd_config #================================================= # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile="$log_file" -ynh_use_logrotate --logfile="/var/log/$app/$access_log_file" +ynh_use_logrotate --logfile="$access_log_file" chown -R $app:$app /var/log/$app diff --git a/scripts/remove b/scripts/remove index 981fa96..d33955b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -93,7 +93,8 @@ fi # Remove the log files ynh_script_progression --message="Removing log file..." --weight=1 -ynh_secure_remove "/var/log/$app/" +ynh_secure_remove "$log_file" +ynh_secure_remove "$access_log_file" #================================================= # MESSAGE TO USER diff --git a/scripts/upgrade b/scripts/upgrade index 735a46f..fb4a585 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,9 +90,9 @@ then ynh_script_progression --message="Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..." --weight=10 #Set settings constant initializer of the app - ynh_add_config --template="../sources/patches/app-config_sql.py.patch.src" --destination="../sources/patches/app-config_sql.py.patch" - ynh_add_config --template="../sources/patches/app-ub.py.patch.src" --destination="../sources/patches/app-ub.py.patch" - ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch" + ynh_add_config --template="../sources/patches/main-config_sql.py.patch.src" --destination="../sources/patches/main-config_sql.py.patch" + ynh_add_config --template="../sources/patches/main-ub.py.patch.src" --destination="../sources/patches/main-ub.py.patch" + ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" diff --git a/sources/patches/app-admin.html.patch b/sources/patches/main-admin.html.patch similarity index 100% rename from sources/patches/app-admin.html.patch rename to sources/patches/main-admin.html.patch diff --git a/sources/patches/app-config_sql.py.patch.src b/sources/patches/main-config_sql.py.patch.src similarity index 100% rename from sources/patches/app-config_sql.py.patch.src rename to sources/patches/main-config_sql.py.patch.src diff --git a/sources/patches/app-constants.py.patch.src b/sources/patches/main-constants.py.patch.src similarity index 100% rename from sources/patches/app-constants.py.patch.src rename to sources/patches/main-constants.py.patch.src diff --git a/sources/patches/app-optional-requirements.txt.patch b/sources/patches/main-optional-requirements.txt.patch similarity index 100% rename from sources/patches/app-optional-requirements.txt.patch rename to sources/patches/main-optional-requirements.txt.patch diff --git a/sources/patches/app-ub.py.patch.src b/sources/patches/main-ub.py.patch.src similarity index 100% rename from sources/patches/app-ub.py.patch.src rename to sources/patches/main-ub.py.patch.src From e43a90e34a11ae6797df0de9a9ae3b150f50ce2f Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 29 Jul 2023 11:58:04 +0000 Subject: [PATCH 11/33] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2bc767..6982c82 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Browsing, reading and downloading eBooks using a Calibre database -**Shipped version:** 0.6.20~ynh2 +**Shipped version:** 0.96.20~ynh2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 80c1a51..b726de3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre -**Version incluse :** 0.6.20~ynh2 +**Version incluse :** 0.96.20~ynh2 ## Captures d’écran From 8e1dcca729a5cb3235044f97896b1ebb462329ad Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 14:01:51 +0200 Subject: [PATCH 12/33] init_main_permission --- manifest.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.toml b/manifest.toml index a095012..2445555 100644 --- a/manifest.toml +++ b/manifest.toml @@ -35,6 +35,10 @@ ram.runtime = "200M" [install.admin] type = "user" + [install.init_main_permission] + type = "group" + default = "all_users" + [install.language] ask.en = "Select a default language" ask.fr = "Choisissez une langue par défaut" From e60910572b87a8d3387c86cd633a14f8fa1064f4 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 14:10:45 +0200 Subject: [PATCH 13/33] Remove remote_user --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 92aade2..3aad432 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,7 +15,7 @@ location __PATH__ { 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; +# proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; From abe84fc59f69d1ba996f653934f3ba89d815b8bb Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 15:00:56 +0200 Subject: [PATCH 14/33] tweak nginx conf for X-script-Name --- scripts/change_url | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 5195dab..6599a65 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,11 @@ ynh_systemd_action --service_name=$app --action="stop" # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +#Cannot use empty string for X-script-name, causes an issue in the python prg +if [ $path_url = "/" ] ; then + ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf +fi + ynh_change_url_nginx_config #================================================= From e2471ec6c8c73cf4a6ec1a740c3069c36158b87b Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 16:53:49 +0200 Subject: [PATCH 15/33] add_sso_v2 --- conf/nginx.conf | 2 +- hooks/post_app_addaccess | 19 +++++++++++++++++++ hooks/post_app_removeaccess | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 hooks/post_app_addaccess create mode 100644 hooks/post_app_removeaccess diff --git a/conf/nginx.conf b/conf/nginx.conf index 3aad432..8642d49 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,7 +15,7 @@ location __PATH__ { 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; +# proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..b2e7581 --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,19 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +app=$1 +users=$2 +permission=$3 +group=$4 + +#Si le groupe visitors a été affecté à calibreweb +if echo "$group" | grep visitors ; then + if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep " proxy_set_header X-Remote-User"; then + #app is made public + domain=$(ynh_app_setting_get --app=$app --key=domain) + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" --replace_string="# proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + fi +fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..3250b25 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,18 @@ +#!/bin/bash +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +app=$1 +users=$2 +permission=$3 +group=$4 + +if echo "$group" | grep visitors; then + if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep "# proxy_set_header X-Remote-User"; then + #app is made public + domain=$(ynh_app_setting_get --app=$app --key=domain) + ynh_replace_string --match_string="# proxy_set_header X-Remote-User" --replace_string=" proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + fi +fi \ No newline at end of file From a6aeecc38ac941e852205db13c62511ba39bbc44 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 17:06:22 +0200 Subject: [PATCH 16/33] current version and package --- scripts/upgrade | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index fb4a585..9302be3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,16 +31,12 @@ upgrade_type=$(ynh_check_app_version_changed) current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json") #0.96.0 current_upstream_package_version="${current_upstream_package_version/".96"/".6"}" #0.6.0 -new_upstream_package_version=$(ynh_app_upstream_version) #0.96.0 +new_upstream_package_version=$(ynh_app_upstream_version) new_upstream_package_version="${new_upstream_package_version/".96"/".6"}" #0.6.0 -#if [ -f $install_dir/cps/constants.py ]; then #on est dans une version postérieur à la 0.6.0 -# current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_VERSION) -# current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}" -# current_upstream_app_version="${current_upstream_app_version/\'\}/""}" -#else #on est encore en 0.6.0 -# current_upstream_app_version='0.6.0' -#fi +current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_VERSION) +current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}" +current_upstream_app_version="${current_upstream_app_version/\'\}/""}" #================================================= From eb16fbaedeb250cb2aa5a47484dc0e5e782517f3 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 20:48:10 +0200 Subject: [PATCH 17/33] add manifest.toml --- conf/nginx.conf | 2 +- hooks/post_app_addaccess | 9 ++++++++- hooks/post_app_removeaccess | 20 ++++++++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8642d49..92aade2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,7 +15,7 @@ location __PATH__ { 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; + proxy_set_header X-Remote-User $remote_user; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index b2e7581..8395394 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -10,10 +10,17 @@ group=$4 #Si le groupe visitors a été affecté à calibreweb if echo "$group" | grep visitors ; then if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep " proxy_set_header X-Remote-User"; then - #app is made public + domain=$(ynh_app_setting_get --app=$app --key=domain) + path=$(ynh_app_setting_get --app=$app --key=path) + port=$(ynh_app_setting_get --app=$app --key=port) + + touch ../manifest.toml + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" --replace_string="# proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_systemd_action --service_name=nginx --action=reload + + rm ../manifest.toml fi fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index 3250b25..84170cf 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -9,10 +9,22 @@ group=$4 if echo "$group" | grep visitors; then if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep "# proxy_set_header X-Remote-User"; then - #app is made public - domain=$(ynh_app_setting_get --app=$app --key=domain) - ynh_replace_string --match_string="# proxy_set_header X-Remote-User" --replace_string=" proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" - ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + + domain = $(ynh_app_setting_get --app=$app --key=domain) + path = $(ynh_app_setting_get --app=$app --key=path) + port = $(ynh_app_setting_get --app=$app --key=port) + + touch ../manifest.toml + + ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \ + --replace_string=" proxy_set_header X-Remote-User" \ + --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" \ + --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + + rm ../manifest.toml fi fi \ No newline at end of file From 752f1c78104fbdceba927eeccb5bb6418e6d2e41 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 21:12:40 +0200 Subject: [PATCH 18/33] Fix upgrade test / language --- scripts/upgrade | 3 +++ tests.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9302be3..e82ff81 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,9 @@ ynh_app_setting_set $app calibre_dir $calibre_dir upload=$(sqlite3 $install_dir/app.db "SELECT config_uploading FROM settings WHERE ID=1") ynh_app_setting_set $app upload $upload +language=$(sqlite3 $install_dir/app.db "SELECT config_default_locale FROM settings WHERE ID=1") +ynh_app_setting_set $app language $language + #================================================= # CHECK VERSION #================================================= diff --git a/tests.toml b/tests.toml index 484efb0..7faca35 100644 --- a/tests.toml +++ b/tests.toml @@ -10,5 +10,5 @@ test_format = 1.0 # Commits to test upgrade from # ------------------------------- - test_upgrade_from.30f2c9d.name = "Upgrade from 0.6.20~ynh1" + test_upgrade_from.b8f9f95.name = "0.6.19~ynh8" From 7f6020a30c6550deb06f4f30b69ba5d46afd0c3f Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 29 Jul 2023 22:11:32 +0200 Subject: [PATCH 19/33] cleaning --- scripts/install | 2 +- scripts/upgrade | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index f70331b..fc0dafd 100755 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Downloading sources to $install_dir..." --weight=10 +ynh_script_progression --message="Installing and patching sources to $install_dir..." --weight=10 #REMOVEME? ynh_app_setting_set $app install_dir $install_dir #Set settings constant initializer of the app diff --git a/scripts/upgrade b/scripts/upgrade index e82ff81..f020a2f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,8 +1,5 @@ #!/bin/bash -version_gt() { - test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; -} #================================================= # GENERIC START From a15211390fe47f24d60c770c8778a104ddfc9937 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 11:09:56 +0200 Subject: [PATCH 20/33] Add SSO --- hooks/post_app_addaccess | 34 +++++++++++++++-------- hooks/post_app_removeaccess | 46 +++++++++++++++++-------------- hooks/post_user_delete | 8 +++--- scripts/install | 15 ++++++++++ scripts/upgrade | 10 +++++++ sources/patches/main-web.py.patch | 14 ++++++++++ 6 files changed, 91 insertions(+), 36 deletions(-) create mode 100644 sources/patches/main-web.py.patch diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 8395394..f0dc07c 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -7,20 +7,30 @@ users=$2 permission=$3 group=$4 -#Si le groupe visitors a été affecté à calibreweb +#Visitor group has been revomed => app is public if echo "$group" | grep visitors ; then - if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep " proxy_set_header X-Remote-User"; then - domain=$(ynh_app_setting_get --app=$app --key=domain) - path=$(ynh_app_setting_get --app=$app --key=path) - port=$(ynh_app_setting_get --app=$app --key=port) + #loading settings from the app + domain=$(ynh_app_setting_get --app=$app --key=domain) + path=$(ynh_app_setting_get --app=$app --key=path) + port=$(ynh_app_setting_get --app=$app --key=port) + install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - touch ../manifest.toml + #otherwise ynh_add_config complain about manifest + touch ../manifest.toml - ynh_replace_string --match_string=" proxy_set_header X-Remote-User" --replace_string="# proxy_set_header X-Remote-User" --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" - ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.conf" - ynh_systemd_action --service_name=nginx --action=reload - - rm ../manifest.toml - fi + #reset a new conf file and move it to nginx + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ + --replace_string="# proxy_set_header X-Remote-User" \ + --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" \ + --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + + rm ../manifest.toml + + #Update settings in calibre database + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" +# ynh_print_info --message="Restarting Calibre-web to take new parameters into account +# ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index 84170cf..0e4383b 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -7,24 +7,30 @@ users=$2 permission=$3 group=$4 +#Visitor group has been revomed => app is private if echo "$group" | grep visitors; then - if tail /etc/yunohost/apps/$app/conf/nginx.conf | grep "# proxy_set_header X-Remote-User"; then - - domain = $(ynh_app_setting_get --app=$app --key=domain) - path = $(ynh_app_setting_get --app=$app --key=path) - port = $(ynh_app_setting_get --app=$app --key=port) - - touch ../manifest.toml - - ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \ - --replace_string=" proxy_set_header X-Remote-User" \ - --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" - - ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" \ - --destination="/etc/nginx/conf.d/$domain.d/$app.conf" - - ynh_systemd_action --service_name=nginx --action=reload - - rm ../manifest.toml - fi -fi \ No newline at end of file + + #loading settings from the app + domain=$(ynh_app_setting_get --app=$app --key=domain) + path=$(ynh_app_setting_get --app=$app --key=path) + port=$(ynh_app_setting_get --app=$app --key=port) + install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) + + #otherwise ynh_add_config complain about manifest + touch ../manifest.toml + + #reset a new conf file and move it to nginx + ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \ + --replace_string=" proxy_set_header X-Remote-User" \ + --target_file="/etc/yunohost/apps/$app/conf/nginx.conf" + ynh_add_config --template="/etc/yunohost/apps/$app/conf/nginx.conf" \ + --destination="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=nginx --action=reload + + rm ../manifest.toml + + #Update settings in calibre database + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;" +# ynh_print_info --message="Restarting Calibre-web to take new parameters into account +# ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 +fi diff --git a/hooks/post_user_delete b/hooks/post_user_delete index 03d072a..ee058ff 100644 --- a/hooks/post_user_delete +++ b/hooks/post_user_delete @@ -8,7 +8,7 @@ app=${app:3} source /etc/yunohost/apps/$app/scripts/_common.sh username=$1 -final_path=$(ynh_app_setting_get $app final_path) +install_dir=$(ynh_app_setting_get $app install_dir) del_tables_user="book_read_link remote_auth_token downloads shelf bookmark" del_tables_shelf="book_shelf_link" @@ -16,12 +16,12 @@ del_id() { #$1=table #$2=id_type #$3=id - sqlite3 $final_path/app.db "DELETE FROM $1 WHERE $2='$3'" + sqlite3 $install_dir/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'") +user_id=$(sqlite3 $install_dir/app.db "SELECT id from user WHERE nickname='$username'") +shelf_id=$(sqlite3 $install_dir/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 diff --git a/scripts/install b/scripts/install index f70331b..b663706 100755 --- a/scripts/install +++ b/scripts/install @@ -95,6 +95,12 @@ if [ $path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi +if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ + --replace_string="# proxy_set_header X-Remote-User" \ + --target_file="../conf/nginx.conf" +fi + # Create a dedicated nginx config ynh_add_nginx_config @@ -123,6 +129,8 @@ ynh_replace_string --match_string="" \ --target_file="/etc/ImageMagick-6/policy.xml" + + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -162,6 +170,13 @@ ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed ynh_script_progression --message="Start $app..." --weight=5 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30 +#We need to update the sso login parameter, but for that the app needs to have run at least once to initialize the tables. +if [ ! $(ynh_permission_has_user --permission=main --user=visitors) ]; then + ynh_systemd_action --service_name=$app --action="stop" + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;" + ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" +fi + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e82ff81..f027ae8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -106,6 +106,16 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - if [ $path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi + +if [ ynh_permission_has_user --permission=main --user=visitors ]; then + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ + --replace_string="# proxy_set_header X-Remote-User" \ + --target_file="../conf/nginx.conf" +else + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;" +fi + # Create a dedicated nginx config ynh_add_nginx_config diff --git a/sources/patches/main-web.py.patch b/sources/patches/main-web.py.patch new file mode 100644 index 0000000..3386aba --- /dev/null +++ b/sources/patches/main-web.py.patch @@ -0,0 +1,14 @@ +--- a/cps/web.py 2023-03-27 19:49:57.000000000 +0200 ++++ b/cps/web.py 2023-08-05 11:05:36.703730438 +0200 +@@ -1411,7 +1411,10 @@ + if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): + logout_oauth_user() + log.debug("User logged out") +- return redirect(url_for('web.login')) ++ if config.config_login_type == constants.LOGIN_LDAP: ++ return redirect(request.host_url + '/yunohost/sso/?action=logout') ++ else: ++ return redirect(url_for('web.login')) + + + # ################################### Users own configuration ######################################################### From 5597cb11efe91dbd842537215b28e779b5e00ce6 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 11:36:27 +0200 Subject: [PATCH 21/33] Typo --- hooks/post_app_addaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index f0dc07c..cdc8ca3 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -30,7 +30,7 @@ if echo "$group" | grep visitors ; then rm ../manifest.toml #Update settings in calibre database - sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID=1;" # ynh_print_info --message="Restarting Calibre-web to take new parameters into account # ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 fi \ No newline at end of file From 0f1dfb6cd7e0291163acd1bfac59805c8383c458 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 12:33:12 +0200 Subject: [PATCH 22/33] Add SSO --- conf/main-web.py.patch | 15 +++++++++++++++ conf/web.py.revert.patch | 15 +++++++++++++++ doc/ADMIN_fr.md | 1 - doc/PRE_INSTALL.md | 2 ++ doc/PRE_INSTALL_fr.md | 4 +++- hooks/post_app_addaccess | 6 ++++-- hooks/post_app_removeaccess | 6 ++++-- scripts/install | 7 +++++-- scripts/upgrade | 4 ++++ sources/patches/main-web.py.patch | 5 +++-- 10 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 conf/main-web.py.patch create mode 100644 conf/web.py.revert.patch diff --git a/conf/main-web.py.patch b/conf/main-web.py.patch new file mode 100644 index 0000000..bf0c4ec --- /dev/null +++ b/conf/main-web.py.patch @@ -0,0 +1,15 @@ +--- a/cps/web.py 2023-03-27 19:49:57.000000000 +0200 ++++ b/cps/web.py 2023-08-05 11:58:20.353503437 +0200 +@@ -1411,7 +1411,11 @@ + if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): + logout_oauth_user() + log.debug("User logged out") +- return redirect(url_for('web.login')) ++# return redirect(url_for('web.login')) ++ if config.config_login_type == constants.LOGIN_LDAP: ++ return redirect(request.host_url + '/yunohost/sso/?action=logout') ++ else: ++ return redirect(url_for('web.login')) + + + # ################################### Users own configuration ######################################################### diff --git a/conf/web.py.revert.patch b/conf/web.py.revert.patch new file mode 100644 index 0000000..e5da349 --- /dev/null +++ b/conf/web.py.revert.patch @@ -0,0 +1,15 @@ +--- ./web.py 2023-08-05 11:58:20.353503437 +0200 ++++ ./web.py 2023-03-27 19:49:57.000000000 +0200 +@@ -1411,11 +1411,7 @@ + if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): + logout_oauth_user() + log.debug("User logged out") +-# return redirect(url_for('web.login')) +- if config.config_login_type == constants.LOGIN_LDAP: +- return redirect(request.host_url + '/yunohost/sso/?action=logout') +- else: +- return redirect(url_for('web.login')) ++ return redirect(url_for('web.login')) + + + # ################################### Users own configuration ######################################################### diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 28bf475..7532dc0 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -1,5 +1,4 @@ - ### Gestion de la bibliothèque * Par défaut, le processus de backup de Yunohost **archivera** la bibliothèque Calibreweb. diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md index 02ff235..e8370a2 100644 --- a/doc/PRE_INSTALL.md +++ b/doc/PRE_INSTALL.md @@ -1,3 +1,5 @@ If calibreweb library is set as a public library, it will be placed in `/home/yunohost.multimedia/share/eBook` If not, it will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. Library folder can always be changed manually in the application settings by the administrator. + +If you grant access to visitors (The application is publicly accessible on the Internet), SSO will be deactivated for security reasons. \ No newline at end of file diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md index 440d01c..c54049a 100644 --- a/doc/PRE_INSTALL_fr.md +++ b/doc/PRE_INSTALL_fr.md @@ -1,3 +1,5 @@ Si la bibliothèque Calibreweb est paramétrée comme une bilbiothèque publique, elle sera placée dans `/home/yunohost.multimedia/share/eBook`. Si non, elle sera placée dans `/home/yunohost.multimedia/[admin]/eBook`. -Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur. \ No newline at end of file +Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur. + +Si vous accorder l'accès à l'application aux visiteurs (l'application est publiquement accessible sur internet), le sso sera désactivé pour des raisons de sécurité. \ No newline at end of file diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index cdc8ca3..08f2736 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -31,6 +31,8 @@ if echo "$group" | grep visitors ; then #Update settings in calibre database sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID=1;" -# ynh_print_info --message="Restarting Calibre-web to take new parameters into account -# ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 + #remove logout from web.py + patch -u /$install_dir/cps/web.py -i /etc/yunohost/apps/$app/conf/web.py.revert.patch + ynh_print_info --message="Restarting Calibre-web to take new parameters into account" + ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index 0e4383b..d0d14e9 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -31,6 +31,8 @@ if echo "$group" | grep visitors; then #Update settings in calibre database sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;" -# ynh_print_info --message="Restarting Calibre-web to take new parameters into account -# ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 + #reinstate logout from web.py + patch -u /$install_dir/cps/web.py -i /etc/yunohost/apps/$app/conf/main-web.py.patch + ynh_print_info --message="Restarting Calibre-web to take new parameters into account" + ynh_systemd_action --service_name=$app --action=restart --line_match="Starting Gevent server on" -t 30 fi diff --git a/scripts/install b/scripts/install index b663706..fcaa3b0 100755 --- a/scripts/install +++ b/scripts/install @@ -87,14 +87,15 @@ ynh_app_setting_set $app calibre_dir $calibre_dir #================================================= # NGINX CONFIGURATION #================================================= -#Cannot use empty string for X-script-name, causes an issue in the python prg ynh_script_progression --message="Setting up system configuration..." --weight=5 - +#Cannot use empty string for X-script-name, causes an issue in the python prg +#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#nginx if [ $path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi +# if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ --replace_string="# proxy_set_header X-Remote-User" \ @@ -170,6 +171,8 @@ ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed ynh_script_progression --message="Start $app..." --weight=5 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30 +#Setting the proxy authentication in case calibre is not open to visitor. +#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source #We need to update the sso login parameter, but for that the app needs to have run at least once to initialize the tables. if [ ! $(ynh_permission_has_user --permission=main --user=visitors) ]; then ynh_systemd_action --service_name=$app --action="stop" diff --git a/scripts/upgrade b/scripts/upgrade index f027ae8..13a6aa6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,10 +103,14 @@ fi #================================================= ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5 +#Cannot use empty string for X-script-name, causes an issue in the python prg +#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#nginx if [ $path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf fi +#Setting the proxy authentication in case calibre is not open to visitor. +#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source if [ ynh_permission_has_user --permission=main --user=visitors ]; then sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ diff --git a/sources/patches/main-web.py.patch b/sources/patches/main-web.py.patch index 3386aba..bf0c4ec 100644 --- a/sources/patches/main-web.py.patch +++ b/sources/patches/main-web.py.patch @@ -1,10 +1,11 @@ --- a/cps/web.py 2023-03-27 19:49:57.000000000 +0200 -+++ b/cps/web.py 2023-08-05 11:05:36.703730438 +0200 -@@ -1411,7 +1411,10 @@ ++++ b/cps/web.py 2023-08-05 11:58:20.353503437 +0200 +@@ -1411,7 +1411,11 @@ if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): logout_oauth_user() log.debug("User logged out") - return redirect(url_for('web.login')) ++# return redirect(url_for('web.login')) + if config.config_login_type == constants.LOGIN_LDAP: + return redirect(request.host_url + '/yunohost/sso/?action=logout') + else: From 0d92ad63ddf9a66e274be25d6c35be1f0d1a6fcf Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 12:41:05 +0200 Subject: [PATCH 23/33] patch web.py for visitors --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index fcaa3b0..71428ad 100755 --- a/scripts/install +++ b/scripts/install @@ -36,6 +36,9 @@ ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --des # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" +# Remove the patch for web.py in case visitor are allowed +patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch + #install kepubify converter ynh_script_progression --message="Installing kepubify..." --weight=1 ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" From 7a69b41542d5ed76f035a86325d73122c70a03a8 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 12:44:13 +0200 Subject: [PATCH 24/33] patch web.py --- scripts/install | 4 +++- scripts/upgrade | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 71428ad..d1f349e 100755 --- a/scripts/install +++ b/scripts/install @@ -37,7 +37,9 @@ ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --des ynh_setup_source --dest_dir="$install_dir" # Remove the patch for web.py in case visitor are allowed -patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch +if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then + patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch +fi #install kepubify converter ynh_script_progression --message="Installing kepubify..." --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index 13a6aa6..eb88a01 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -96,6 +96,12 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" chown -R $app: $install_dir + + # Remove the patch for web.py in case visitor are allowed + if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then + patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch + fi + fi #================================================= From d4bac0470d705abe6e1d1778b920dad1d143f69a Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 13:45:02 +0200 Subject: [PATCH 25/33] fix if statements --- hooks/post_app_addaccess | 2 +- hooks/post_app_removeaccess | 2 +- scripts/install | 6 +++--- scripts/upgrade | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 08f2736..15e6ef2 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -8,7 +8,7 @@ permission=$3 group=$4 #Visitor group has been revomed => app is public -if echo "$group" | grep visitors ; then +if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ]; then #loading settings from the app domain=$(ynh_app_setting_get --app=$app --key=domain) diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index d0d14e9..e80fea7 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -8,7 +8,7 @@ permission=$3 group=$4 #Visitor group has been revomed => app is private -if echo "$group" | grep visitors; then +if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ]; then #loading settings from the app domain=$(ynh_app_setting_get --app=$app --key=domain) diff --git a/scripts/install b/scripts/install index d1f349e..68f5ab4 100755 --- a/scripts/install +++ b/scripts/install @@ -37,7 +37,7 @@ ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --des ynh_setup_source --dest_dir="$install_dir" # Remove the patch for web.py in case visitor are allowed -if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then +if $(ynh_permission_has_user --permission=main --user=visitors); then patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch fi @@ -101,7 +101,7 @@ if [ $path = "/" ] ; then fi # -if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then +if $(ynh_permission_has_user --permission=main --user=visitors); then ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ --replace_string="# proxy_set_header X-Remote-User" \ --target_file="../conf/nginx.conf" @@ -179,7 +179,7 @@ ynh_systemd_action --service_name=$app --action="start" --line_match="Starting G #Setting the proxy authentication in case calibre is not open to visitor. #https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source #We need to update the sso login parameter, but for that the app needs to have run at least once to initialize the tables. -if [ ! $(ynh_permission_has_user --permission=main --user=visitors) ]; then +if ! $(ynh_permission_has_user --permission=main --user=visitors); then ynh_systemd_action --service_name=$app --action="stop" sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;" ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" diff --git a/scripts/upgrade b/scripts/upgrade index eb88a01..1ab7b25 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,7 +98,7 @@ then chown -R $app: $install_dir # Remove the patch for web.py in case visitor are allowed - if [ $(ynh_permission_has_user --permission=main --user=visitors) ]; then + if $(ynh_permission_has_user --permission=main --user=visitors); then patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch fi @@ -117,7 +117,7 @@ fi #Setting the proxy authentication in case calibre is not open to visitor. #https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source -if [ ynh_permission_has_user --permission=main --user=visitors ]; then +if $(ynh_permission_has_user --permission=main --user=visitors); then sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ --replace_string="# proxy_set_header X-Remote-User" \ From 73f313389ff21d9da18b7c3cd0016e87b4f64d4e Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 14:06:45 +0200 Subject: [PATCH 26/33] typo in sqlite3 command --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1ab7b25..5a1765c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,7 +118,7 @@ fi #Setting the proxy authentication in case calibre is not open to visitor. #https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source if $(ynh_permission_has_user --permission=main --user=visitors); then - sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID)1;" + sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID=1;" ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ --replace_string="# proxy_set_header X-Remote-User" \ --target_file="../conf/nginx.conf" From 09bbc720c5b2aa1831bee22e1adc54398b62a150 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 14:21:15 +0200 Subject: [PATCH 27/33] syntax --- doc/PRE_INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md index e8370a2..0442a9d 100644 --- a/doc/PRE_INSTALL.md +++ b/doc/PRE_INSTALL.md @@ -1,5 +1,5 @@ If calibreweb library is set as a public library, it will be placed in `/home/yunohost.multimedia/share/eBook` If not, it will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. -Library folder can always be changed manually in the application settings by the administrator. +Library folder can be changed manually in the application settings by the administrator. If you grant access to visitors (The application is publicly accessible on the Internet), SSO will be deactivated for security reasons. \ No newline at end of file From 24b0704cbb776e527a43a3769a308391dd3da58f Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 14:34:54 +0200 Subject: [PATCH 28/33] column nickname became name --- hooks/post_user_delete | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/post_user_delete b/hooks/post_user_delete index ee058ff..ec22d9e 100644 --- a/hooks/post_user_delete +++ b/hooks/post_user_delete @@ -20,9 +20,11 @@ del_id() { } -user_id=$(sqlite3 $install_dir/app.db "SELECT id from user WHERE nickname='$username'") +user_id=$(sqlite3 $install_dir/app.db "SELECT id from user WHERE name='$username'") shelf_id=$(sqlite3 $install_dir/app.db "SELECT id from shelf WHERE user_id='$user_id'") +ynh_print_info --message="Suppression de l'utilisateur dans calibreweb" + #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 From dce91854bb604b135117088574d2dde5b0aee902 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 14:46:22 +0200 Subject: [PATCH 29/33] version --- scripts/upgrade | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d833945..40452d2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,11 +28,21 @@ ynh_app_setting_set $app language $language upgrade_type=$(ynh_check_app_version_changed) -current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json") #0.96.0 +if [ -f /etc/yunohost/apps/$app/manifest.toml ]; then + current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.toml") #0.96.0 +else + current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json") #0.96.0 +fi current_upstream_package_version="${current_upstream_package_version/".96"/".6"}" #0.6.0 +current_upstream_package_version="${current_upstream_package_version/".97"/".7"}" +current_upstream_package_version="${current_upstream_package_version/".98"/".8"}" +current_upstream_package_version="${current_upstream_package_version/".99"/".9"}" new_upstream_package_version=$(ynh_app_upstream_version) new_upstream_package_version="${new_upstream_package_version/".96"/".6"}" #0.6.0 +new_upstream_package_version="${new_upstream_package_version/".97"/".7"}" +new_upstream_package_version="${new_upstream_package_version/".98"/".8"}" +new_upstream_package_version="${new_upstream_package_version/".99"/".9"}" current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_VERSION) current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}" From 96d54565e0b4c3b9803844c17c96477b9b0e5b3d Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 18:20:59 +0200 Subject: [PATCH 30/33] Fix multiinstance trigger when provisionning --- hooks/post_app_addaccess | 5 +++-- hooks/post_app_removeaccess | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 15e6ef2..c81f399 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -2,13 +2,14 @@ # Source YunoHost helpers source /usr/share/yunohost/helpers -app=$1 +app="${0//.\/50-}" +app_trigger=$1 users=$2 permission=$3 group=$4 #Visitor group has been revomed => app is public -if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ]; then +if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ] && [ $app = $app_trigger ]; then #loading settings from the app domain=$(ynh_app_setting_get --app=$app --key=domain) diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index e80fea7..42535f1 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -2,13 +2,15 @@ # Source YunoHost helpers source /usr/share/yunohost/helpers -app=$1 +app="${0//.\/50-}" +app_trigger=$1 users=$2 permission=$3 group=$4 #Visitor group has been revomed => app is private -if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ]; then +#app & app_trigger to be used for multiinstance +if [ $(echo "$group" | grep visitors) ] && [ $permission = "main" ] && [ $app = $app_trigger ]; then #loading settings from the app domain=$(ynh_app_setting_get --app=$app --key=domain) From f49b71de8702e73deb098a748e32faffe4312d9d Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 5 Aug 2023 18:47:52 +0200 Subject: [PATCH 31/33] Fix X-Script-Name & X-Remote-User --- scripts/change_url | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 6599a65..3b5a8f1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,6 +31,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- #Cannot use empty string for X-script-name, causes an issue in the python prg if [ $path_url = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf +else + ynh_replace_string "# proxy_set_header X-Script-Name" " proxy_set_header X-Script-Name" ../conf/nginx.conf +fi + +if $(ynh_permission_has_user --permission=main --user=visitors); then + ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \ + --replace_string="# proxy_set_header X-Remote-User" \ + --target_file="../conf/nginx.conf" +else + ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \ + --replace_string=" proxy_set_header X-Remote-User" \ + --target_file="../conf/nginx.conf" + fi ynh_change_url_nginx_config From 82c8532b5fbb80bcc913b48fb5550f7bfc025faf Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 6 Aug 2023 00:16:23 +0200 Subject: [PATCH 32/33] use new_path instead of path_url --- scripts/change_url | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 3b5a8f1..0844e6c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,7 +29,7 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 #Cannot use empty string for X-script-name, causes an issue in the python prg -if [ $path_url = "/" ] ; then +if [ $new_path = "/" ] ; then ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf else ynh_replace_string "# proxy_set_header X-Script-Name" " proxy_set_header X-Script-Name" ../conf/nginx.conf @@ -43,7 +43,6 @@ else ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \ --replace_string=" proxy_set_header X-Remote-User" \ --target_file="../conf/nginx.conf" - fi ynh_change_url_nginx_config From 09b4c213f6de00dd65c94663a810a872f101b6c1 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 6 Aug 2023 00:43:42 +0200 Subject: [PATCH 33/33] kepubify for multi-instance --- scripts/backup | 2 +- scripts/install | 6 +++--- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 18 +++++++++++++----- sources/patches/main-config_sql.py.patch.src | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5bb9056..5a29dca 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,7 +32,7 @@ ynh_backup --src_path="$install_dir" # BACKUP THE KEPUBIFY BINARY #================================================= -ynh_backup --src_path="/opt/kepubify" +ynh_backup --src_path="/opt/kepubify/$app" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 10cea64..65f736d 100755 --- a/scripts/install +++ b/scripts/install @@ -43,7 +43,7 @@ fi #install kepubify converter ynh_script_progression --message="Installing kepubify..." --weight=1 -ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" +ynh_setup_source --dest_dir="/opt/kepubify/$app/" --source_id="kepubify" #================================================= @@ -152,8 +152,8 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi chown -R $app: $install_dir chmod 740 $install_dir -chown -R $app: /opt/kepubify -chmod 770 /opt/kepubify/kepubify +chown -R $app: /opt/kepubify/$app +chmod 770 /opt/kepubify/$app/kepubify #================================================= # SETUP FAIL2BAN diff --git a/scripts/remove b/scripts/remove index d33955b..a1944a7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -48,7 +48,7 @@ fi # Remove the data directory if --purge option is used ynh_script_progression --message="Removing kepubify directory..." --weight=1 -ynh_secure_remove --file="/opt/kepubify" +ynh_secure_remove --file="/opt/kepubify/$app" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 7ff7f48..078c8f3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ ynh_restore_file --origin_path="$install_dir" # RESTORE THE KEPUBIFY BINARIES #================================================= ynh_script_progression --message="Restoring Kepubify..." --weight=1 -ynh_restore_file --origin_path="/opt/kepubify" +ynh_restore_file --origin_path="/opt/kepubify/$app" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 40452d2..95be743 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,11 +79,19 @@ fi #Adding kepubify converter if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings") ]; then - eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\"" + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\"" fi -if [ ! -d /opt/kepubify ]; then - ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify" - chmod 770 /opt/kepubify/kepubify +if [ ! -d /opt/kepubify/$app ]; then + ynh_setup_source --dest_dir="/opt/kepubify/$app" --source_id="kepubify" + chmod 770 /opt/kepubify/$app/kepubify +fi + +#Change kepubify to new path (for multiinstance +if [ -f /opt/kepubify/kepubify ]; then + rm /opt/kepubify/kepubify +fi +if sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings" | grep -xq "/opt/kepubify/kepubify" ; then + eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\"" fi #================================================= @@ -214,7 +222,7 @@ ynh_add_systemd_config # Set permissions on app files chown -R $app: $install_dir -chown -R $app: /opt/kepubify +chown -R $app: /opt/kepubify/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/sources/patches/main-config_sql.py.patch.src b/sources/patches/main-config_sql.py.patch.src index 903215d..6ea77a6 100644 --- a/sources/patches/main-config_sql.py.patch.src +++ b/sources/patches/main-config_sql.py.patch.src @@ -55,7 +55,7 @@ config_ldap_group_name = Column(String, default='calibreweb') - config_kepubifypath = Column(String, default=None) -+ config_kepubifypath = Column(String, default='/opt/kepubify/kepubify') ++ config_kepubifypath = Column(String, default='/opt/kepubify/__APP__/kepubify') config_converterpath = Column(String, default=None) config_calibre = Column(String) config_rarfile_location = Column(String, default=None)