mirror of
https://github.com/YunoHost-Apps/calibreweb_ynh.git
synced 2024-09-03 18:16:20 +02:00
Merge pull request #130 from YunoHost-Apps/testing
Packaging V2 + bugfixes
This commit is contained in:
commit
fec93a1184
43 changed files with 459 additions and 1151 deletions
212
.github/workflows/updater.sh
vendored
212
.github/workflows/updater.sh
vendored
|
@ -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 <<EOT > 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 <<EOT > 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
|
|
50
.github/workflows/updater.yml
vendored
50
.github/workflows/updater.yml
vendored
|
@ -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 <yunohost-bot@users.noreply.github.com>'
|
|
||||||
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
|
||||||
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
|
|
8
.project
8
.project
|
@ -1,17 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>calibre_ynh</name>
|
<name>calibreweb_ynh</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
|
||||||
<name>org.python.pydev.PyDevBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.python.pydev.pythonNature</nature>
|
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
|
||||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
|
||||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
|
||||||
</pydev_project>
|
|
70
README.md
70
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
|
Browsing, reading and downloading eBooks using a Calibre database
|
||||||
|
|
||||||
**Shipped version:** 0.6.20
|
**Shipped version:** 0.96.20~ynh2
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 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
|
## Documentation and resources
|
||||||
|
|
||||||
* Official admin documentation: <https://github.com/janeczku/calibre-web/wiki>
|
* Official admin documentation: <https://github.com/janeczku/calibre-web/wiki>
|
||||||
|
|
70
README_fr.md
70
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
|
Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre
|
||||||
|
|
||||||
**Version incluse :** 0.6.20
|
**Version incluse :** 0.96.20~ynh2
|
||||||
|
|
||||||
## Captures d’écran
|
## Captures d’écran
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 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
|
## Documentations et ressources
|
||||||
|
|
||||||
* Documentation officielle de l’admin : <https://github.com/janeczku/calibre-web/wiki>
|
* Documentation officielle de l’admin : <https://github.com/janeczku/calibre-web/wiki>
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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
|
|
|
@ -1,3 +0,0 @@
|
||||||
SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0.6.6.zip
|
|
||||||
SOURCE_SUM=87633c2817263ed2d12fce67ea292b1c6d042aa949aafb728789c15d495415cc
|
|
||||||
SOURCE_FORMAT=zip
|
|
|
@ -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__
|
|
|
@ -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\'
|
|
|
@ -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\'
|
|
15
conf/main-web.py.patch
Normal file
15
conf/main-web.py.patch
Normal file
|
@ -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 #########################################################
|
|
@ -11,11 +11,11 @@ location __PATH__ {
|
||||||
|
|
||||||
proxy_pass http://localhost:__PORT__;
|
proxy_pass http://localhost:__PORT__;
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
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-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Scheme $scheme;
|
proxy_set_header X-Scheme $scheme;
|
||||||
proxy_set_header X-Script-Name __PATH__;
|
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 SSOWAT user panel.
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
|
|
|
@ -6,8 +6,8 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
ExecStart=/bin/sh -c '__FINALPATH__/venv/bin/python3 __FINALPATH__/cps.py'
|
ExecStart=/bin/sh -c '__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/cps.py'
|
||||||
|
|
||||||
# Sandboxing options to harden security
|
# Sandboxing options to harden security
|
||||||
# Depending on specificities of your service/app, you may need to tweak these
|
# Depending on specificities of your service/app, you may need to tweak these
|
||||||
|
|
15
conf/web.py.revert.patch
Normal file
15
conf/web.py.revert.patch
Normal file
|
@ -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 #########################################################
|
|
@ -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 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.
|
* By default, Yunohost backup process **will backup** Calibreweb library.
|
||||||
You may deactivate backup of the library with
|
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
|
### 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
|
* 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!
|
* 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`
|
* 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?
|
|
|
@ -1,18 +1,6 @@
|
||||||
|
|
||||||
### 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
|
### 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.
|
* Par défaut, le processus de backup de Yunohost **archivera** la bibliothèque Calibreweb.
|
||||||
Vous pouvez le désactiver avec cette commande:
|
Vous pouvez le désactiver avec cette commande:
|
||||||
```
|
```
|
||||||
|
@ -48,17 +36,5 @@ La numérotation est modifiée dans yunohost par rapport à Calibre-web: la vers
|
||||||
### Problèmes connus
|
### 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.
|
* 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!
|
* 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`
|
* 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?
|
|
1
doc/DESCRIPTION.md
Normal file
1
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Browsing, reading and downloading eBooks using a Calibre database
|
1
doc/DESCRIPTION_fr.md
Normal file
1
doc/DESCRIPTION_fr.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre
|
5
doc/POST_INSTALL.md
Normal file
5
doc/POST_INSTALL.md
Normal file
|
@ -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.
|
||||||
|
|
4
doc/POST_INSTALL_fr.md
Normal file
4
doc/POST_INSTALL_fr.md
Normal file
|
@ -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.
|
5
doc/PRE_INSTALL.md
Normal file
5
doc/PRE_INSTALL.md
Normal file
|
@ -0,0 +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 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.
|
5
doc/PRE_INSTALL_fr.md
Normal file
5
doc/PRE_INSTALL_fr.md
Normal file
|
@ -0,0 +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.
|
||||||
|
|
||||||
|
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é.
|
39
hooks/post_app_addaccess
Normal file
39
hooks/post_app_addaccess
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
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" ] && [ $app = $app_trigger ]; then
|
||||||
|
|
||||||
|
#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='', config_allow_reverse_proxy_header_login=0 WHERE ID=1;"
|
||||||
|
#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
|
40
hooks/post_app_removeaccess
Normal file
40
hooks/post_app_removeaccess
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
app="${0//.\/50-}"
|
||||||
|
app_trigger=$1
|
||||||
|
users=$2
|
||||||
|
permission=$3
|
||||||
|
group=$4
|
||||||
|
|
||||||
|
#Visitor group has been revomed => app is private
|
||||||
|
#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)
|
||||||
|
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;"
|
||||||
|
#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
|
|
@ -8,7 +8,7 @@ app=${app:3}
|
||||||
source /etc/yunohost/apps/$app/scripts/_common.sh
|
source /etc/yunohost/apps/$app/scripts/_common.sh
|
||||||
|
|
||||||
username=$1
|
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_user="book_read_link remote_auth_token downloads shelf bookmark"
|
||||||
del_tables_shelf="book_shelf_link"
|
del_tables_shelf="book_shelf_link"
|
||||||
|
|
||||||
|
@ -16,12 +16,14 @@ del_id() {
|
||||||
#$1=table
|
#$1=table
|
||||||
#$2=id_type
|
#$2=id_type
|
||||||
#$3=id
|
#$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'")
|
user_id=$(sqlite3 $install_dir/app.db "SELECT id from user WHERE name='$username'")
|
||||||
shelf_id=$(sqlite3 $final_path/app.db "SELECT id from shelf WHERE user_id='$user_id'")
|
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
|
#Delete all entry with dependencies for user
|
||||||
#pas de check sur l'existence de l'utilisateur car fonctionne sans
|
#pas de check sur l'existence de l'utilisateur car fonctionne sans
|
||||||
|
|
104
manifest.json
104
manifest.json
|
@ -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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
105
manifest.toml
Normal file
105
manifest.toml
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
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.96.20~ynh2"
|
||||||
|
|
||||||
|
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 = "200M"
|
||||||
|
ram.runtime = "200M"
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.path]
|
||||||
|
type = "path"
|
||||||
|
default = "/calibre"
|
||||||
|
|
||||||
|
[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"
|
||||||
|
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" ]
|
||||||
|
|
|
@ -1,42 +1,24 @@
|
||||||
#!/bin/bash
|
#!/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
|
DOSSIER_MEDIA=/home/yunohost.multimedia
|
||||||
|
|
||||||
#These var are used in init_calibre_db_settings conf file
|
|
||||||
log_file=/var/log/$app/$app.log
|
log_file=/var/log/$app/$app.log
|
||||||
access_log_file=/var/log/$app/$app-access.log
|
access_log_file=/var/log/$app/$app-access.log
|
||||||
|
|
||||||
|
|
||||||
mach=`uname -m`
|
mach=`uname -m`
|
||||||
|
|
||||||
sha256_32bit=3365a848ce06d43fca8f1999eb69c6c8e0e20a56b6b8658a8466b9726adef0f5
|
|
||||||
sha256_64bit=37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5
|
|
||||||
sha256_arm=07f23275c4e674093443f01a591aa0980b0b87dbb0a10986d5001e9d56b0e1e7
|
|
||||||
sha256_arm64=5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3
|
|
||||||
sha256_armv6=7912901dc7b6f51e119f59cfd1f3f8ac2a5c64c42efba9d69ebf2ea8c3a7a2c9
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case "$mach" in
|
case "$mach" in
|
||||||
"armv6l" ) mach="arm"
|
"armv6l" ) mach="arm"
|
||||||
sha256=$sha256_arm
|
|
||||||
;;
|
;;
|
||||||
"armv7l" ) mach="arm"
|
"armv7l" ) mach="arm"
|
||||||
sha256=$sha256_arm
|
|
||||||
;;
|
;;
|
||||||
"armv8l" ) mach="arm64"
|
"armv8l" ) mach="arm64"
|
||||||
sha256=$sha256_arm64
|
|
||||||
;;
|
;;
|
||||||
"aarch64" ) mach="arm64"
|
"aarch64" ) mach="arm64"
|
||||||
sha256=$sha256_arm64
|
|
||||||
;;
|
;;
|
||||||
"x86_64" ) mach="64bit"
|
"x86_64" ) mach="64bit"
|
||||||
sha256=$sha256_64bit
|
|
||||||
;;
|
;;
|
||||||
* ) mach="32bit"
|
* ) mach="32bit"
|
||||||
sha256=$sha256_32bit
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
|
@ -9,26 +9,9 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
#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
|
#Save it in settings so that it can be used back afterward
|
||||||
calibre_dir=${calibre_dir%/}
|
calibre_dir=${calibre_dir%/}
|
||||||
ynh_app_setting_set $app calibre_dir $calibre_dir
|
ynh_app_setting_set $app calibre_dir $calibre_dir
|
||||||
|
@ -43,13 +26,13 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#This will backup the app.db file at the same time
|
#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
|
# BACKUP THE KEPUBIFY BINARY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/opt/kepubify"
|
ynh_backup --src_path="/opt/kepubify/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -8,27 +8,6 @@
|
||||||
|
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
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
|
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
|
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
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,36 +27,26 @@ ynh_systemd_action --service_name=$app --action="stop"
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
|
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
|
#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
|
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||||
fi
|
else
|
||||||
# Create a dedicated nginx config
|
ynh_replace_string "# proxy_set_header X-Script-Name" " proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||||
ynh_add_nginx_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
if $(ynh_permission_has_user --permission=main --user=visitors); then
|
||||||
if [ $change_domain -eq 1 ]
|
ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \
|
||||||
then
|
--replace_string="# proxy_set_header X-Remote-User" \
|
||||||
# Delete file checksum for the old conf file location
|
--target_file="../conf/nginx.conf"
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
else
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \
|
||||||
# Store file checksum for the new config file location
|
--replace_string=" proxy_set_header X-Remote-User" \
|
||||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
--target_file="../conf/nginx.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -125,13 +56,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
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
210
scripts/install
210
scripts/install
|
@ -6,147 +6,107 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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)
|
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
|
if [ $public_library -eq 1 ]; then
|
||||||
#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
|
|
||||||
calibre_dir=$DOSSIER_MEDIA/share/eBook
|
calibre_dir=$DOSSIER_MEDIA/share/eBook
|
||||||
elif [ $is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public
|
else # library is private
|
||||||
calibre_dir=$DOSSIER_MEDIA/share/eBook
|
|
||||||
else #app is private, library is private
|
|
||||||
calibre_dir=$DOSSIER_MEDIA/$admin/eBook
|
calibre_dir=$DOSSIER_MEDIA/$admin/eBook
|
||||||
fi
|
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
|
# 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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Downloading sources to $final_path..." --weight=10
|
ynh_script_progression --message="Installing and patching sources to $install_dir..." --weight=10
|
||||||
ynh_app_setting_set $app final_path $final_path
|
#REMOVEME? ynh_app_setting_set $app install_dir $install_dir
|
||||||
|
|
||||||
#Set settings constant initializer of the app
|
#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/main-config_sql.py.patch.src" --destination="../sources/patches/main-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/main-ub.py.patch.src" --destination="../sources/patches/main-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-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch"
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source "$final_path"
|
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
|
||||||
|
patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch
|
||||||
|
fi
|
||||||
|
|
||||||
#install kepubify converter
|
#install kepubify converter
|
||||||
ynh_script_progression --message="Installing kepubify..." --weight=1
|
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/$app/" --source_id="kepubify"
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# 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
|
#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
|
ynh_script_progression --message="Installing pip requirements..." --weight=70
|
||||||
# Always recreate everything fresh with current python version
|
# Always recreate everything fresh with current python version
|
||||||
if [ -d "${final_path}/venv" ] ; then
|
if [ -d "${install_dir}/venv" ] ; then
|
||||||
ynh_secure_remove "${final_path}/venv"
|
ynh_secure_remove "${install_dir}/venv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
python3 -m venv --without-pip "${final_path}/venv"
|
python3 -m venv --without-pip "${install_dir}/venv"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$install_dir"
|
||||||
|
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${install_dir}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
ynh_exec_as $app $install_dir/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 $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/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/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
|
# 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
|
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
|
||||||
if [ $path_url = "/" ] ; then
|
#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
|
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||||
fi
|
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
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
@ -158,42 +118,18 @@ ynh_add_nginx_config
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_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
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --logfile="$log_file"
|
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
|
chown -R $app:$app /var/log/$app
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# 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
|
#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="<policy domain="coder" rights="none" pattern="PDF" />" \
|
ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern="PDF" />" \
|
||||||
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
|
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
|
||||||
|
@ -201,13 +137,6 @@ ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern=
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -221,10 +150,10 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
chown -R $app: $final_path
|
chown -R $app: $install_dir
|
||||||
chmod 740 $final_path
|
chmod 740 $install_dir
|
||||||
chown -R $app: /opt/kepubify
|
chown -R $app: /opt/kepubify/$app
|
||||||
chmod 770 /opt/kepubify/kepubify-linux-$mach
|
chmod 770 /opt/kepubify/$app/kepubify
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
|
@ -240,31 +169,22 @@ fi
|
||||||
# Create a dedicated Fail2Ban config
|
# Create a dedicated Fail2Ban config
|
||||||
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --max_retry=5
|
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --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
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reload nginx and start $app..." --weight=5
|
ynh_script_progression --message="Start $app..." --weight=5
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
|
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"
|
||||||
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -9,18 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -43,24 +31,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||||
ynh_remove_systemd_config
|
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
|
# REMOVE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -78,7 +48,7 @@ fi
|
||||||
|
|
||||||
# Remove the data directory if --purge option is used
|
# Remove the data directory if --purge option is used
|
||||||
ynh_script_progression --message="Removing kepubify directory..." --weight=1
|
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
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
@ -123,16 +93,8 @@ fi
|
||||||
|
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_script_progression --message="Removing log file..." --weight=1
|
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"
|
||||||
#=================================================
|
|
||||||
# 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
|
# MESSAGE TO USER
|
||||||
|
|
|
@ -6,38 +6,9 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -47,72 +18,46 @@ test ! -d $final_path || ynh_die "There is already a directory: $final_path "
|
||||||
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
|
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
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
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
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
|
# RESTORE THE KEPUBIFY BINARIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring Kepubify..." --weight=1
|
ynh_script_progression --message="Restoring Kepubify..." --weight=1
|
||||||
ynh_restore_file --origin_path="/opt/kepubify"
|
ynh_restore_file --origin_path="/opt/kepubify/$app"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
chown -R $app: $final_path
|
chown -R $app: $install_dir
|
||||||
chmod 740 $final_path
|
chmod 740 $install_dir
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC RESTORATION
|
|
||||||
#=================================================
|
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
ynh_script_progression --message="Reinstalling 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
|
#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
|
ynh_script_progression --message="Reinstalling pip requirements..." --weight=70
|
||||||
# Always recreate everything fresh with current python version
|
# Always recreate everything fresh with current python version
|
||||||
# When reinstalling on a new yunohost, this is required
|
# When reinstalling on a new yunohost, this is required
|
||||||
if [ -d "${final_path}/venv" ] ; then
|
if [ -d "${install_dir}/venv" ] ; then
|
||||||
ynh_secure_remove "${final_path}/venv"
|
ynh_secure_remove "${install_dir}/venv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
python3 -m venv --without-pip "${final_path}/venv"
|
python3 -m venv --without-pip "${install_dir}/venv"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$install_dir"
|
||||||
|
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${install_dir}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
ynh_exec_as $app $install_dir/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 $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/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/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
|
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
|
ynh_restore_file --origin_path="$calibre_dir" --not_mandatory
|
||||||
#fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MULTIMEDIA DIR IF NOT EXISTING
|
# RESTORE THE MULTIMEDIA DIR IF NOT EXISTING
|
||||||
|
|
192
scripts/upgrade
192
scripts/upgrade
|
@ -1,81 +1,59 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
version_gt() {
|
|
||||||
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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)
|
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
|
#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%/}
|
calibre_dir=${calibre_dir%/}
|
||||||
ynh_app_setting_set $app 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
|
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
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
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
|
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/".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) #0.96.0
|
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/".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"}"
|
||||||
|
|
||||||
if [ -f $final_path/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=$(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/STABLE_VERSION = \{\'version\': \'/""}"
|
||||||
current_upstream_app_version="${current_upstream_app_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
|
# 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
|
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
|
|
||||||
|
|
||||||
#Stop the app in case database is updated
|
#Stop the app in case database is updated
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
||||||
|
|
||||||
|
@ -92,61 +70,28 @@ then
|
||||||
yunohost firewall disallow TCP $port 2>&1
|
yunohost firewall disallow TCP $port 2>&1
|
||||||
fi
|
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
|
#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
|
| 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
|
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
|
#Adding kepubify converter
|
||||||
if [ -z $(sqlite3 $final_path/app.db "SELECT config_kepubifypath FROM settings") ]; then
|
if [ -z $(sqlite3 $install_dir/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\""
|
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\""
|
||||||
fi
|
fi
|
||||||
if [ ! -d /opt/kepubify ]; then
|
if [ ! -d /opt/kepubify/$app ]; then
|
||||||
ynh_add_config --template="../conf/appkepubify.src.default" --destination="../conf/appkepubify.src"
|
ynh_setup_source --dest_dir="/opt/kepubify/$app" --source_id="kepubify"
|
||||||
ynh_setup_source --dest_dir="/opt/kepubify" --source_id="appkepubify"
|
chmod 770 /opt/kepubify/$app/kepubify
|
||||||
chmod 770 /opt/kepubify/kepubify-linux-$mach
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the permission "kobo_sync" only if it doesn't exist.
|
#Change kepubify to new path (for multiinstance
|
||||||
if ! ynh_permission_exists --permission="Kobo sync"
|
if [ -f /opt/kepubify/kepubify ]; then
|
||||||
then
|
rm /opt/kepubify/kepubify
|
||||||
# API Authorization with dedicated URL
|
fi
|
||||||
ynh_print_warn --message="This version has now a dedicated Kobo sync authorization, please review group and permission"
|
if sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings" | grep -xq "/opt/kepubify/kepubify" ; then
|
||||||
ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true"
|
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\""
|
||||||
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -154,20 +99,24 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..." --weight=10
|
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
|
#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/main-config_sql.py.patch.src" --destination="../sources/patches/main-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/main-ub.py.patch.src" --destination="../sources/patches/main-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-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch"
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# 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
|
||||||
|
|
||||||
|
# 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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -175,21 +124,26 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5
|
||||||
if [ $path_url = "/" ] ; then
|
#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
|
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||||
fi
|
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" \
|
||||||
|
--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
|
# Create a dedicated nginx config
|
||||||
ynh_add_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 +152,27 @@ chown -R $app: $final_path
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
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
|
#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
|
ynh_script_progression --message="Installing pip requirements..." --weight=70
|
||||||
# Always recreate everything fresh with current python version
|
# Always recreate everything fresh with current python version
|
||||||
if [ -d "${final_path}/venv" ] ; then
|
if [ -d "${install_dir}/venv" ] ; then
|
||||||
ynh_secure_remove "${final_path}/venv"
|
ynh_secure_remove "${install_dir}/venv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
python3 -m venv --without-pip "${final_path}/venv"
|
python3 -m venv --without-pip "${install_dir}/venv"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$install_dir"
|
||||||
|
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${install_dir}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
ynh_exec_as $app $install_dir/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 $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/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/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -270,8 +221,8 @@ ynh_add_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R $app: $install_dir
|
||||||
chown -R $app: /opt/kepubify
|
chown -R $app: /opt/kepubify/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
@ -294,13 +245,6 @@ fi
|
||||||
# Create a dedicated Fail2Ban config
|
# Create a dedicated Fail2Ban config
|
||||||
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --max_retry=5
|
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --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
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
config_ldap_group_name = Column(String, default='calibreweb')
|
config_ldap_group_name = Column(String, default='calibreweb')
|
||||||
|
|
||||||
- config_kepubifypath = Column(String, default=None)
|
- config_kepubifypath = Column(String, default=None)
|
||||||
+ config_kepubifypath = Column(String, default='/opt/kepubify/kepubify-linux-__MACH__')
|
+ config_kepubifypath = Column(String, default='/opt/kepubify/__APP__/kepubify')
|
||||||
config_converterpath = Column(String, default=None)
|
config_converterpath = Column(String, default=None)
|
||||||
config_calibre = Column(String)
|
config_calibre = Column(String)
|
||||||
config_rarfile_location = Column(String, default=None)
|
config_rarfile_location = Column(String, default=None)
|
15
sources/patches/main-web.py.patch
Normal file
15
sources/patches/main-web.py.patch
Normal file
|
@ -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 #########################################################
|
14
tests.toml
Normal file
14
tests.toml
Normal file
|
@ -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.b8f9f95.name = "0.6.19~ynh8"
|
||||||
|
|
Loading…
Add table
Reference in a new issue