mirror of
https://github.com/YunoHost-Apps/calibreweb_ynh.git
synced 2024-09-03 18:16:20 +02:00
convert v2 : initial commit
This commit is contained in:
parent
30f2c9dcf8
commit
42ee0808da
29 changed files with 219 additions and 1003 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"?>
|
||||
<projectDescription>
|
||||
<name>calibre_ynh</name>
|
||||
<name>calibreweb_ynh</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</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>
|
|
@ -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\'
|
|
@ -11,11 +11,11 @@ location __PATH__ {
|
|||
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
proxy_set_header X-Script-Name __PATH__;
|
||||
# proxy_set_header X-Remote-User $remote_user;
|
||||
proxy_set_header X-Remote-User $remote_user;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
|
||||
### Post install
|
||||
|
||||
Users having the calibreweb.main authorization group can be automatically sync from within the app, by using the "Import LDAP user" function.
|
||||
Deletion of a Yunohost User will delete the according calibreweb-user.
|
||||
|
||||
|
||||
### Library management
|
||||
|
||||
* **Library** will be placed in `/home/yunohost.multimedia/share/eBook` folder except if both :
|
||||
- calibreweb is set as a private application
|
||||
- calibreweb library is set as a public library
|
||||
|
||||
In this case the library will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. Library folder can always be changed manually in the application settings by the administrator.
|
||||
|
||||
* By default, Yunohost backup process **will backup** Calibreweb library.
|
||||
You may deactivate backup of the library with
|
||||
```
|
||||
|
@ -48,17 +35,5 @@ Version number in Yunohost is different from the upstream Calibre-web app : vers
|
|||
### Known Limitations
|
||||
|
||||
* Do not use a Nextcloud folder. It's all right if the folder is an external storage in Nextcloud but not if it's an internal one : Changing the data in the library will cause trouble with the sync
|
||||
* "Magic link feature is not yet available
|
||||
* Change to library made outside Calibreweb are not automatically updated in Calibreweb. It is required to disconnect and reconnect to see the changes : Do not open a database both in Calibre & Calibreweb!
|
||||
* Kobo Sync doesn’t work when Calibreweb is installed on a subdomain. This issue is caused by nginx. However, it works great when installed on a path e.g. `https://domain.tld/calibreweb`
|
||||
|
||||
### Todo
|
||||
- [ ] Update mail settings with yunohost settings
|
||||
- [ ] enable magic link
|
||||
- [ ] Add cronjob to reload database (for nextcloud integration)
|
||||
- [ ] Add config-panel option to trigger do_not_backup_data
|
||||
- [ ] Add config-panel to manage max upload size
|
||||
- [ ] Add action to restart the server
|
||||
- [ ] Add action to synchronize users
|
||||
- [ ] Add action to deactivate LDAP et retrieve admin password
|
||||
- [ ] Use internal updater to update version?
|
|
@ -1,18 +1,7 @@
|
|||
|
||||
### Post installation
|
||||
|
||||
Les utilisateurs appartenant au groupe d'autorisation calibreweb.main peuvent être synchronisé automatiquement depuis l'application en utilisant la fonction "Importer les utilisateurs LDAP".
|
||||
Lorsque les utilisateurs sont supprimés dans Yunohost, ils sont également supprimés dans Calibreweb.
|
||||
|
||||
|
||||
### Gestion de la bibliothèque
|
||||
|
||||
* La **bibliothèque** sera placée dans `/home/yunohost.multimedia/share/eBook` sauf si simultanément :
|
||||
- Calibreweb est paramétré comme une application privée
|
||||
- La bibliothèque Calibreweb est paramétrée comme une bilbiothèque privée
|
||||
|
||||
Dans ce cas, la bibliothèque sera placée dans `/home/yunohost.multimedia/[admin]/eBook`. Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur.
|
||||
|
||||
* Par défaut, le processus de backup de Yunohost **archivera** la bibliothèque Calibreweb.
|
||||
Vous pouvez le désactiver avec cette commande:
|
||||
```
|
||||
|
@ -47,18 +36,6 @@ La numérotation est modifiée dans yunohost par rapport à Calibre-web: la vers
|
|||
|
||||
### Problèmes connus
|
||||
|
||||
* Ne pas utiliser un répertoire Nextcloud pour y installer la bibliothèque: Cela fonctionnera s'il s'agit d'un stockage externe à Nextcloud, mais pas dans le cas d'un répertoire interne qui causerait des problèmes lors des synchronisations.
|
||||
* La fonction "Magic link" n'est pas disponible
|
||||
* Ne pas utiliser un répertoire Nextcloud pour y installer la bibliothèque: Cela fonctionnera s'il s'agit d'un stockage externe à Nextcloud, mais pas dans le cas d'un répertoire interne qui causerait des problèmes lors des synchronisations.
|
||||
* Les changements fait à la bibliothèque en dehors de Calibreweb ne sont pas automatiquement vu par Calibreweb : Il est nécessaire de se déconnecter puis reconnecter ou redémarrer le service pour que les modifications soient visibles : N'utilisez donc pas simultanément Calibre et Calibreweb sur la même bibliothèque!
|
||||
* La synchronisation Kobo ne fonctionne pas quand Calibreweb est installée dans un sous-domaine. Ce problème est causé par nginx. Par contre, cela fonctionne très bien quand installé dans un répertoire, par exemple `https://domain.tld/calibreweb`
|
||||
|
||||
## Todo
|
||||
- [ ] Mise à jour des réglages mails
|
||||
- [ ] Activation de magic link
|
||||
- [ ] Add cronjob to reload database (for nextcloud integration)
|
||||
- [ ] Add config-panel option to trigger do_not_backup_data
|
||||
- [ ] Add config-panel to manage max upload size
|
||||
- [ ] Add action to restart the server
|
||||
- [ ] Add action to synchronize users
|
||||
- [ ] Add action to deactivate LDAP et retrieve admin password
|
||||
- [ ] Use internal updater to update version?
|
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.
|
3
doc/PRE_INSTALL.md
Normal file
3
doc/PRE_INSTALL.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
If calibreweb library is set as a public library, it will be placed in `/home/yunohost.multimedia/share/eBook`
|
||||
If not, it will be set in `/home/yunohost.multimedia/[admin]/eBook` folder.
|
||||
Library folder can always be changed manually in the application settings by the administrator.
|
3
doc/PRE_INSTALL_fr.md
Normal file
3
doc/PRE_INSTALL_fr.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Si la bibliothèque Calibreweb est paramétrée comme une bilbiothèque publique, elle sera placée dans `/home/yunohost.multimedia/share/eBook`.
|
||||
Si non, elle sera placée dans `/home/yunohost.multimedia/[admin]/eBook`.
|
||||
Le répertoire de la bibliothèque peut ensuite être déplacé directement dans l'application par l'administrateur.
|
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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
101
manifest.toml
Normal file
101
manifest.toml
Normal file
|
@ -0,0 +1,101 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "calibreweb"
|
||||
name = "Calibre-web"
|
||||
description.en = "Browsing, reading and downloading eBooks using a Calibre database"
|
||||
description.fr = "Explorer, lire et télécharger des eBooks à partir d'une base de données Calibre"
|
||||
|
||||
version = "0.6.20~ynh1"
|
||||
|
||||
maintainers = ["Krakinou"]
|
||||
|
||||
[upstream]
|
||||
license = "GPL-3.0-only"
|
||||
admindoc = "https://github.com/janeczku/calibre-web/wiki"
|
||||
code = "https://github.com/janeczku/calibre-web"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 4.3.0"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = true
|
||||
sso = true
|
||||
disk = "400M"
|
||||
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
type = "path"
|
||||
default = "/calibre"
|
||||
|
||||
[install.admin]
|
||||
type = "user"
|
||||
|
||||
[install.language]
|
||||
ask.en = "Select a default language"
|
||||
ask.fr = "Choisissez une langue par défaut"
|
||||
help.en = "You may change it later in the app"
|
||||
help.fr = "Vous pourrez la changer ultérieurement dans l'application"
|
||||
type = "select"
|
||||
optional = true
|
||||
choices = ["fr", "en", "es", "de"]
|
||||
default = "fr"
|
||||
|
||||
[install.upload]
|
||||
ask.en = "Do you want to allow uploading of books?"
|
||||
ask.fr = "Voulez vous autoriser le téléversement de livres?"
|
||||
help.en = "You may change it later in the app"
|
||||
help.fr = "Vous pourrez le changer ultérieurement dans l'application"
|
||||
type = "boolean"
|
||||
optional = true
|
||||
default = false
|
||||
|
||||
[install.public_library]
|
||||
ask.en = "Do you want to allow access to the library to all Yunohost users? "
|
||||
ask.fr = "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?"
|
||||
help.en = "Yes will set the library in /home/yunohost.multimedia/share/eBook"
|
||||
help.fr = "Oui parametrera la bibliothèque pour /home/yunohost.multimedia/share/eBook"
|
||||
type = "boolean"
|
||||
optional = true
|
||||
default = true
|
||||
|
||||
[resources]
|
||||
[resources.sources]
|
||||
[resources.sources.main]
|
||||
url = "https://github.com/janeczku/calibre-web/releases/download/0.6.20/calibre-web-0.6.20.zip"
|
||||
sha256 = "2f1f8a5ae06f182986193a90796fa96a7b0b5c61fdd29971969b49245b1aaf24"
|
||||
|
||||
autoupdate.strategy = "latest_github_release"
|
||||
autoupdate.asset = "calibre-web-.*.zip"
|
||||
|
||||
[resources.sources.kepubify]
|
||||
arm64.url = "https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-arm64"
|
||||
arm64.sha256="5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3"
|
||||
armhf.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-arm"
|
||||
armhf.sha256="07f23275c4e674093443f01a591aa0980b0b87dbb0a10986d5001e9d56b0e1e7"
|
||||
i386.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-32bit"
|
||||
i386.sha256="3365a848ce06d43fca8f1999eb69c6c8e0e20a56b6b8658a8466b9726adef0f5"
|
||||
amd64.url="https://github.com/pgaskin/kepubify/releases/download/v4.0.4/kepubify-linux-64bit"
|
||||
amd64.sha256="37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5"
|
||||
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
||||
kobo.url= "/kobo"
|
||||
kobo.show_tile= false
|
||||
kobo.allowed= "visitors"
|
||||
|
||||
[resources.ports]
|
||||
main.default = 8083
|
||||
|
||||
[resources.apt]
|
||||
packages = [ "sqlite3", "imagemagick", "libldap2-dev", "libsasl2-dev", "python3-venv", "python3-dev", "python3-lxml", "libjpeg-dev", "zlib1g-dev", "libffi-dev" ]
|
||||
|
|
@ -1,42 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
PKG_DEPENDENCIES="sqlite3 imagemagick libldap2-dev libsasl2-dev python3-venv python3-dev python3-lxml libjpeg-dev zlib1g-dev libffi-dev"
|
||||
#PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick"
|
||||
|
||||
DOSSIER_MEDIA=/home/yunohost.multimedia
|
||||
|
||||
#These var are used in init_calibre_db_settings conf file
|
||||
log_file=/var/log/$app/$app.log
|
||||
access_log_file=/var/log/$app/$app-access.log
|
||||
|
||||
|
||||
mach=`uname -m`
|
||||
|
||||
sha256_32bit=3365a848ce06d43fca8f1999eb69c6c8e0e20a56b6b8658a8466b9726adef0f5
|
||||
sha256_64bit=37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5
|
||||
sha256_arm=07f23275c4e674093443f01a591aa0980b0b87dbb0a10986d5001e9d56b0e1e7
|
||||
sha256_arm64=5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3
|
||||
sha256_armv6=7912901dc7b6f51e119f59cfd1f3f8ac2a5c64c42efba9d69ebf2ea8c3a7a2c9
|
||||
|
||||
|
||||
|
||||
case "$mach" in
|
||||
"armv6l" ) mach="arm"
|
||||
sha256=$sha256_arm
|
||||
;;
|
||||
"armv7l" ) mach="arm"
|
||||
sha256=$sha256_arm
|
||||
;;
|
||||
"armv8l" ) mach="arm64"
|
||||
sha256=$sha256_arm64
|
||||
;;
|
||||
"aarch64" ) mach="arm64"
|
||||
sha256=$sha256_arm64
|
||||
;;
|
||||
"x86_64" ) mach="64bit"
|
||||
sha256=$sha256_64bit
|
||||
;;
|
||||
* ) mach="32bit"
|
||||
sha256=$sha256_32bit
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -9,26 +9,9 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
#Get settings from database in case it has been changed in the app
|
||||
calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
|
||||
calibre_dir=$(sqlite3 $install_dir/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
|
||||
#Save it in settings so that it can be used back afterward
|
||||
calibre_dir=${calibre_dir%/}
|
||||
ynh_app_setting_set $app calibre_dir $calibre_dir
|
||||
|
@ -43,7 +26,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
#=================================================
|
||||
|
||||
#This will backup the app.db file at the same time
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE KEPUBIFY BINARY
|
||||
|
|
|
@ -8,27 +8,6 @@
|
|||
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script
|
||||
#when initializing the conf file of the app
|
||||
source _common.sh
|
||||
|
||||
#=================================================
|
||||
|
@ -36,44 +15,6 @@ source _common.sh
|
|||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=10
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
@ -86,35 +27,8 @@ ynh_systemd_action --service_name=$app --action="stop"
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
#Cannot use empty string for X-script-name, causes an issue in the python prg
|
||||
if [ $path_url = "/" ] ; then
|
||||
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||
fi
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
@ -125,13 +39,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
175
scripts/install
175
scripts/install
|
@ -6,84 +6,27 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
upload=$YNH_APP_ARG_UPLOAD
|
||||
public_library=$YNH_APP_ARG_PUBLIC_LIBRARY
|
||||
|
||||
#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script
|
||||
#when initializing the conf file of the app
|
||||
source _common.sh
|
||||
|
||||
#if app is public, we assume library is public
|
||||
if [ $is_public -eq 1 ]; then
|
||||
public_library=1
|
||||
fi
|
||||
|
||||
if [ $is_public -eq 1 ]; then #app is public, library is public
|
||||
if [ $public_library -eq 1 ]; then
|
||||
calibre_dir=$DOSSIER_MEDIA/share/eBook
|
||||
elif [ $is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public
|
||||
calibre_dir=$DOSSIER_MEDIA/share/eBook
|
||||
else #app is private, library is private
|
||||
else # library is private
|
||||
calibre_dir=$DOSSIER_MEDIA/$admin/eBook
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=5
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=5
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app admin $admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AN AVAILABLE PORT
|
||||
#=================================================
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port 8083)
|
||||
ynh_script_progression --message="Setting port $port..." --weight=5
|
||||
ynh_app_setting_set $app port $port
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Downloading sources to $final_path..." --weight=10
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_script_progression --message="Downloading sources to $install_dir..." --weight=10
|
||||
#REMOVEME? ynh_app_setting_set $app install_dir $install_dir
|
||||
|
||||
#Set settings constant initializer of the app
|
||||
ynh_add_config --template="../sources/patches/app-config_sql.py.patch.src" --destination="../sources/patches/app-config_sql.py.patch"
|
||||
|
@ -91,50 +34,55 @@ ynh_add_config --template="../sources/patches/app-ub.py.patch.src" --destination
|
|||
ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
#install kepubify converter
|
||||
ynh_script_progression --message="Installing kepubify..." --weight=1
|
||||
ynh_add_config --template="../conf/appkepubify.src.default" --destination="../conf/appkepubify.src"
|
||||
ynh_setup_source --dest_dir="/opt/kepubify" --source_id="appkepubify"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
# Create a system user
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||
ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify"
|
||||
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installing package dependencies..." --weight=80
|
||||
ynh_install_app_dependencies $PKG_DEPENDENCIES
|
||||
|
||||
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
|
||||
ynh_script_progression --message="Installing pip requirements..." --weight=70
|
||||
# Always recreate everything fresh with current python version
|
||||
if [ -d "${final_path}/venv" ] ; then
|
||||
ynh_secure_remove "${final_path}/venv"
|
||||
if [ -d "${install_dir}/venv" ] ; then
|
||||
ynh_secure_remove "${install_dir}/venv"
|
||||
fi
|
||||
|
||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||
python3 -m venv --without-pip "${final_path}/venv"
|
||||
chown -R "$app:" "$final_path"
|
||||
python3 -m venv --without-pip "${install_dir}/venv"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#run source in a 'sub shell'
|
||||
(
|
||||
set +o nounset
|
||||
source "${final_path}/venv/bin/activate"
|
||||
source "${install_dir}/venv/bin/activate"
|
||||
set -o nounset
|
||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt"
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
|
||||
)
|
||||
|
||||
#=================================================
|
||||
# CREATE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating files and directory..." --weight=5
|
||||
|
||||
#build multimedia directory
|
||||
ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
#Check if metadata.db file exists. If not create it (empty library)
|
||||
if [ ! -e "$calibre_dir"/metadata.db ]; then
|
||||
cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db
|
||||
chown $app:$app $calibre_dir/*
|
||||
fi
|
||||
|
||||
ynh_app_setting_set $app calibre_dir $calibre_dir
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -143,7 +91,7 @@ chown -R "$app:" "$final_path"
|
|||
ynh_script_progression --message="Setting up system configuration..." --weight=5
|
||||
|
||||
|
||||
if [ $path_url = "/" ] ; then
|
||||
if [ $path = "/" ] ; then
|
||||
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||
fi
|
||||
|
||||
|
@ -158,32 +106,9 @@ ynh_add_nginx_config
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# CREATE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating files and directory..." --weight=5
|
||||
#Logic is as follow : if app is set to be publicly accessible, we will assume that the library should be set in "Share" multimedia directory
|
||||
# If app is set to be private but access is requested for all user, we will assume the same
|
||||
# If app is set to be private but access is limited to the admin user, we will set it inside his own multimedia directory.
|
||||
# Access to the app is managed in the SSOwat part of the script.
|
||||
|
||||
#build multimedia directory
|
||||
ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
|
||||
#Check if metadata.db file exists. If not create it (empty library)
|
||||
if [ ! -e "$calibre_dir"/metadata.db ]; then
|
||||
cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db
|
||||
chown $app:$app $calibre_dir/*
|
||||
fi
|
||||
|
||||
ynh_app_setting_set $app calibre_dir $calibre_dir
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --logfile="$log_file"
|
||||
ynh_use_logrotate --logfile="/var/log/$app/$access_log_file"
|
||||
|
@ -193,21 +118,11 @@ chown -R $app:$app /var/log/$app
|
|||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
||||
#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files
|
||||
ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern="PDF" />" \
|
||||
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
|
||||
--target_file="/etc/ImageMagick-6/policy.xml"
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
#ynh_store_file_checksum "${final_path}/app.db"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -221,8 +136,8 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown -R $app: $final_path
|
||||
chmod 740 $final_path
|
||||
chown -R $app: $install_dir
|
||||
chmod 740 $install_dir
|
||||
chown -R $app: /opt/kepubify
|
||||
chmod 770 /opt/kepubify/kepubify-linux-$mach
|
||||
|
||||
|
@ -240,29 +155,11 @@ fi
|
|||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reload nginx and start $app..." --weight=5
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_script_progression --message="Start $app..." --weight=5
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -9,18 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=3
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
calibre_dir=$(ynh_app_setting_get $app calibre_dir)
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
|
@ -43,24 +31,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
|||
ynh_remove_systemd_config
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_script_progression --message="Removing Dependencies..." --weight=25
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_script_progression --message="Removing $final_path..." --weight=1
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DATA DIR
|
||||
#=================================================
|
||||
|
@ -125,15 +95,6 @@ fi
|
|||
ynh_script_progression --message="Removing log file..." --weight=1
|
||||
ynh_secure_remove "/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
# Delete a system user
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# MESSAGE TO USER
|
||||
#=================================================
|
||||
|
|
|
@ -6,38 +6,9 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
calibre_dir=$(ynh_app_setting_get $app calibre_dir)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script
|
||||
#when initializing the conf file of the app
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path || ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -47,27 +18,11 @@ test ! -d $final_path || ynh_die "There is already a directory: $final_path "
|
|||
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# REOPEN PORT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="reopening port $port..." --weight=5
|
||||
ynh_app_setting_set $app port $port
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE KEPUBIFY BINARIES
|
||||
|
@ -79,40 +34,30 @@ ynh_restore_file --origin_path="/opt/kepubify"
|
|||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
chown -R $app: $final_path
|
||||
chmod 740 $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=15
|
||||
ynh_install_app_dependencies $PKG_DEPENDENCIES
|
||||
chown -R $app: $install_dir
|
||||
chmod 740 $install_dir
|
||||
|
||||
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
|
||||
ynh_script_progression --message="Reinstalling pip requirements..." --weight=70
|
||||
# Always recreate everything fresh with current python version
|
||||
# When reinstalling on a new yunohost, this is required
|
||||
if [ -d "${final_path}/venv" ] ; then
|
||||
ynh_secure_remove "${final_path}/venv"
|
||||
if [ -d "${install_dir}/venv" ] ; then
|
||||
ynh_secure_remove "${install_dir}/venv"
|
||||
fi
|
||||
|
||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||
python3 -m venv --without-pip "${final_path}/venv"
|
||||
chown -R "$app:" "$final_path"
|
||||
python3 -m venv --without-pip "${install_dir}/venv"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#run source in a 'sub shell'
|
||||
(
|
||||
set +o nounset
|
||||
source "${final_path}/venv/bin/activate"
|
||||
source "${install_dir}/venv/bin/activate"
|
||||
set -o nounset
|
||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt"
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
|
||||
)
|
||||
|
||||
#=================================================
|
||||
|
@ -146,11 +91,7 @@ chown -R $app:$app /var/log/$app
|
|||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoring data directory if required..." --weight=2
|
||||
# The data directory will be restored only if it exists in the backup archive
|
||||
# So only if it was backup previously.
|
||||
#if [ -d "$YNH_BACKUP_DIR/apps/$app/backup/$calibre_dir" ] && [ ! tail "$calibre_dir" | grep "yunohost.multimedia" ]; then
|
||||
ynh_restore_file --origin_path="$calibre_dir" --not_mandatory
|
||||
#fi
|
||||
ynh_restore_file --origin_path="$calibre_dir" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MULTIMEDIA DIR IF NOT EXISTING
|
||||
|
|
148
scripts/upgrade
148
scripts/upgrade
|
@ -9,33 +9,17 @@ version_gt() {
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
language=$(ynh_app_setting_get $app language)
|
||||
|
||||
#Source common.sh required to be after var initialization as some variables are updated in it that are then used in the script
|
||||
#when initializing the conf file of the app
|
||||
source _common.sh
|
||||
|
||||
#Get settings from database in case it has been changed in the app and save it in settings so that it can be used back afterward
|
||||
calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
|
||||
calibre_dir=$(sqlite3 $install_dir/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
|
||||
calibre_dir=${calibre_dir%/}
|
||||
ynh_app_setting_set $app calibre_dir $calibre_dir
|
||||
|
||||
upload=$(sqlite3 $final_path/app.db "SELECT config_uploading FROM settings WHERE ID=1")
|
||||
upload=$(sqlite3 $install_dir/app.db "SELECT config_uploading FROM settings WHERE ID=1")
|
||||
ynh_app_setting_set $app upload $upload
|
||||
|
||||
#=================================================
|
||||
|
@ -50,31 +34,19 @@ current_upstream_package_version="${current_upstream_package_version/".96"/".6"}
|
|||
new_upstream_package_version=$(ynh_app_upstream_version) #0.96.0
|
||||
new_upstream_package_version="${new_upstream_package_version/".96"/".6"}" #0.6.0
|
||||
|
||||
if [ -f $final_path/cps/constants.py ]; then #on est dans une version postérieur à la 0.6.0
|
||||
current_upstream_app_version=$(cat $final_path/cps/constants.py | grep STABLE_VERSION)
|
||||
current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}"
|
||||
current_upstream_app_version="${current_upstream_app_version/\'\}/""}"
|
||||
else #on est encore en 0.6.0
|
||||
current_upstream_app_version='0.6.0'
|
||||
fi
|
||||
#if [ -f $install_dir/cps/constants.py ]; then #on est dans une version postérieur à la 0.6.0
|
||||
# current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_VERSION)
|
||||
# current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}"
|
||||
# current_upstream_app_version="${current_upstream_app_version/\'\}/""}"
|
||||
#else #on est encore en 0.6.0
|
||||
# current_upstream_app_version='0.6.0'
|
||||
#fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
|
||||
ynh_clean_check_starting
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
ynh_clean_check_starting
|
||||
|
||||
#Stop the app in case database is updated
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
||||
|
@ -92,71 +64,27 @@ then
|
|||
yunohost firewall disallow TCP $port 2>&1
|
||||
fi
|
||||
|
||||
# If language was set delete it
|
||||
if [ ! -z "$language" ]; then
|
||||
ynh_app_setting_delete --app=$app --key=language
|
||||
fi
|
||||
|
||||
#binaries version is 0.6.0, we need to go throught upgrade to 0.6.6 so that app.db is correctly updated, otherwise database is corrupted
|
||||
#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap & log settings
|
||||
if version_gt "0.6.6" "$current_upstream_app_version" && [ "$current_upstream_package_version" == "0.6.0" ] && [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
||||
ynh_script_progression --message="Upgrading from $current_upstream_app_version to 0.6.6..." --weight=50
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="app066"
|
||||
pip install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/requirements.txt
|
||||
chown -R $app: $final_path
|
||||
#set database settings as per conf file : restart server so that app.db is regenerated
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server" --log_path="$final_path/calibre-web.log" -t 30
|
||||
#sleep required on low spec like raspberryPi
|
||||
sleep 2s
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\""
|
||||
eval sqlite3 $final_path/app.db "$conf"
|
||||
current_upstream_app_version="0.6.6"
|
||||
fi
|
||||
|
||||
#LDAP settings were wrongly set in version prior to 0.6.13 and we could not retrieve LDAP users. This will change the settings to correct values
|
||||
if sqlite3 $final_path/app.db "SELECT config_ldap_group_object_filter FROM settings" \
|
||||
if sqlite3 $install_dir/app.db "SELECT config_ldap_group_object_filter FROM settings" \
|
||||
| grep -xq "(&(objectClass=posixGroup)(permission=cn=%s.main,ou=permission,dc=yunohost,dc=org))" ; then
|
||||
eval sqlite3 $final_path/app.db "\"UPDATE settings SET config_ldap_group_object_filter='(&(objectClass=posixGroup)(cn=%s.main))' WHERE ID=1\""
|
||||
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_ldap_group_object_filter='(&(objectClass=posixGroup)(cn=%s.main))' WHERE ID=1\""
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#Adding kepubify converter
|
||||
if [ -z $(sqlite3 $final_path/app.db "SELECT config_kepubifypath FROM settings") ]; then
|
||||
eval sqlite3 $final_path/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\""
|
||||
if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings") ]; then
|
||||
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/kepubify-linux-$mach' WHERE ID=1\""
|
||||
fi
|
||||
if [ ! -d /opt/kepubify ]; then
|
||||
ynh_add_config --template="../conf/appkepubify.src.default" --destination="../conf/appkepubify.src"
|
||||
ynh_setup_source --dest_dir="/opt/kepubify" --source_id="appkepubify"
|
||||
ynh_setup_source --dest_dir="/opt/kepubify" --source_id="kepubify"
|
||||
chmod 770 /opt/kepubify/kepubify-linux-$mach
|
||||
fi
|
||||
|
||||
# Create the permission "kobo_sync" only if it doesn't exist.
|
||||
if ! ynh_permission_exists --permission="Kobo sync"
|
||||
then
|
||||
# API Authorization with dedicated URL
|
||||
ynh_print_warn --message="This version has now a dedicated Kobo sync authorization, please review group and permission"
|
||||
ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true"
|
||||
else
|
||||
##TO BE DELETED - error in testing has led to bad permission settings
|
||||
ynh_permission_delete --permission="Kobo sync"
|
||||
ynh_permission_create --permission="Kobo sync" --label="Kobo Sync" --url="$domain$path_url/kobo" --allowed="visitors" "all_users" --show_tile="false" --protected="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..." --weight=10
|
||||
|
@ -167,7 +95,8 @@ then
|
|||
ynh_add_config --template="../sources/patches/app-constants.py.patch.src" --destination="../sources/patches/app-constants.py.patch"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
chown -R $app: $install_dir
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -175,21 +104,12 @@ fi
|
|||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5
|
||||
if [ $path_url = "/" ] ; then
|
||||
if [ $path = "/" ] ; then
|
||||
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
|
||||
fi
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||
# Set permissions on app files (required to be able to update database)
|
||||
chown -R $app: $final_path
|
||||
|
||||
|
||||
#=================================================
|
||||
|
@ -198,30 +118,27 @@ chown -R $app: $final_path
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Installing package dependencies..." --weight=15
|
||||
ynh_install_app_dependencies $PKG_DEPENDENCIES
|
||||
|
||||
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
|
||||
ynh_script_progression --message="Installing pip requirements..." --weight=70
|
||||
# Always recreate everything fresh with current python version
|
||||
if [ -d "${final_path}/venv" ] ; then
|
||||
ynh_secure_remove "${final_path}/venv"
|
||||
if [ -d "${install_dir}/venv" ] ; then
|
||||
ynh_secure_remove "${install_dir}/venv"
|
||||
fi
|
||||
|
||||
|
||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||
python3 -m venv --without-pip "${final_path}/venv"
|
||||
chown -R "$app:" "$final_path"
|
||||
python3 -m venv --without-pip "${install_dir}/venv"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#run source in a 'sub shell'
|
||||
(
|
||||
set +o nounset
|
||||
source "${final_path}/venv/bin/activate"
|
||||
source "${install_dir}/venv/bin/activate"
|
||||
set -o nounset
|
||||
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt"
|
||||
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
|
||||
)
|
||||
fi
|
||||
|
||||
|
@ -270,7 +187,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
chown -R $app: $install_dir
|
||||
chown -R $app: /opt/kepubify
|
||||
|
||||
#=================================================
|
||||
|
@ -294,13 +211,6 @@ fi
|
|||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <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
|
||||
#=================================================
|
||||
|
|
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.30f2c9d.name = "Upgrade from 0.6.20~ynh1"
|
||||
|
Loading…
Add table
Reference in a new issue