diff --git a/.project b/.project
index 18e8b1c..0675d93 100644
--- a/.project
+++ b/.project
@@ -5,7 +5,13 @@
+
+ org.python.pydev.PyDevBuilder
+
+
+
+ org.python.pydev.pythonNature
diff --git a/.pydevproject b/.pydevproject
new file mode 100644
index 0000000..d001f0a
--- /dev/null
+++ b/.pydevproject
@@ -0,0 +1,5 @@
+
+
+Default
+python interpreter
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..8e4e3b8
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//conf/generate_password_hash.py=utf-8
diff --git a/README.md b/README.md
index 87bb001..0625610 100644
--- a/README.md
+++ b/README.md
@@ -15,8 +15,9 @@ Calibre-Web is a web app providing a clean interface for browsing, reading and d
Alternatively, you may use [COPS](https://github.com/YunoHost-Apps/cops_ynh) which also allows access to your Calibre Library, but in read-only mode.
-**Shipped version:** The shipped version 0.6.0, but as the numbering changed in the calibre-web app, it is numbered as 0.96.0 in yunohost
+**Shipped version:** The shipped version is 0.6.7, but as the numbering changed in the calibre-web app, it is numbered as 0.96.7 in yunohost.
+Users will be synchronized with authorized Yunohost users (having the calibreweb.main authorization group) automatically. In case of issue you may force the sync in the app itself.
Library will be placed in `/home/yunohost.multimedia/share/eBook` folder except if both :
- calibreweb is set as a private application
@@ -24,25 +25,30 @@ Library will be placed in `/home/yunohost.multimedia/share/eBook` folder except
In this case the library will be set in `/home/yunohost.multimedia/[admin]/eBook` folder. Library folder can always be changed manually in the application settings by the administrator.
-This app support http authentification.
-
## Screenshots

+## Security
+The default admin password of the app (admin123) is kept during the installation process. It is used as a fallback password in case of LDAP issue.
+You should change it to something more secure in the app :)
+
+## 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)).
+
## Backup library
-By default, backup process will not backup Calibre library ([backup_core_only logic](https://yunohost.org/#/backup_fr)).
-You may activate backup of the library with
+By default, Yunohost backup process **will backup** Calibre library.
+You may deactivate backup of the library with
```
-yunohost app setting calibreweb backup_core_only -v 0
+yunohost app setting calibreweb do_not_backup_data -v 1
```
-By default, removing the app will **never** delete the library.
+By default, removing the app will **never** delete the library.
## Known Limitations
-* Partial LDAP support : user existing both in Yunohost and calibreweb can use their Yunohost password to log in, but user existing previously to the application installation will not be duplicated in the database automatically
* Authorization access to library to be done manually after install if Calibre library was already existing, for example :
```
chown -R calibreweb: path/to/library
@@ -51,12 +57,12 @@ chmod o+rw path/to/library
```
* Do not use a Nextcloud folder. It's all right if the folder is an external storage in Nextcloud but not if it's an internal one : Changing the data in the library will cause trouble with the sync
* "Magic link feature is not yet available
-* Change to library made outside calibreweb are not automatically updated in calibreweb. It is required to disconnect and reconnect to see the changes
-* OPDS is not yet working
+* 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!
+* Yunohost install use the Tornado server which limits the upload size of a single file to 200Mo.
## Links
- * Report a bug: https://github.com/YunoHost-Apps/calibre_ynh/issues
+ * Report a bug: https://github.com/YunoHost-Apps/calibreweb_ynh/issues
* App website: https://github.com/janeczku/calibre-web
* YunoHost website: https://yunohost.org/
@@ -65,25 +71,32 @@ chmod o+rw path/to/library
Developers info
----------------
-Please do your pull request to the [testing branch](https://github.com/Yunohost-Apps/calibre_ynh/tree/Testing).
+Please do your pull request to the [testing branch](https://github.com/Yunohost-Apps/calibreweb_ynh/tree/Testing).
To try the testing branch, please proceed like that.
```
-sudo yunohost app install https://github.com/Yunohost-Apps/calibre_ynh/tree/Testing --debug
+sudo yunohost app install https://github.com/Yunohost-Apps/calibreweb_ynh/tree/Testing --debug
or
-sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre_ynh/tree/Testing --debug
+sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibreweb_ynh/tree/Testing --debug
```
## Todo
- [X] Multiinstance
- [X] Better Multimedia integration : Integrate in Yunohost.multimedia
-- [X] User and possibly LDAP integration, http auth
+- [X] rework LDAP integration to create user automatically
- [X] Package_check integration
- [X] On backup/remove/upgrade : check for database location to update settings
+- [ ] Update mail settings with yunohost settings
- [ ] enable magic link
-- [ ] Add cronjob to reload database
-- [ ] OPDS activation
+- [ ] Add cronjob to reload database (for nextcloud integration)
+- [X] OPDS activation
+- [ ] Add config-panel option to trigger do_not_backup_data
+- [ ] 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?
+
## LICENSE
diff --git a/check_process b/check_process
index 531867d..b991b3d 100644
--- a/check_process
+++ b/check_process
@@ -15,12 +15,10 @@
setup_root=1
setup_private=1
setup_public=1
- upgrade=1 from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341
- upgrade=1 from_commit=03bafd5219544c5d317eaf54182e4122ba63a4ad
- upgrade_1 from_commit=9e5fa45df7cd840d8a26d25f953857a13d6bc5de
+ upgrade=1
+ upgrade=1 from_commit=11f5b96df7d8850beff47f9904745fa53a6f7ed9
backup_restore=1
multi_instance=1
- incorrect_path=1
port_already_use=1 (8083)
change_url=1
#;; Failed upgrade
@@ -41,23 +39,11 @@
# setup_root=1
# upgrade=1 from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341
;;; Levels
- Level 1=auto
- Level 2=auto
- Level 3=auto
- Level 4=1
Level 5=auto
- Level 6=auto
- Level 7=auto
- Level 8=0
- Level 9=0
- Level 10=0
;;; Options
-Email=
+Email=nicolas@aubonalbanais.ovh
Notification=none
;;; Upgrade options
- ; commit=3b9c5041e4fa73cb965368379f2b83d076c65341
- name=First in progress release of the app 0.9~ynh1
- manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1&
- ; commit=03bafd5219544c5d317eaf54182e4122ba63a4ad
- name=Release 0.91~ynh2
+ ; commit=11f5b96df7d8850beff47f9904745fa53a6f7ed9
+ name=Version 0.96.0~ynh4
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1&
\ No newline at end of file
diff --git a/conf/app.src b/conf/app.src
index a7a76d1..9723afd 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,3 +1,3 @@
-SOURCE_URL=https://github.com/janeczku/calibre-web/archive/d81cb2927abcba3c4d198ecce9dca78550f676e1.zip
-SOURCE_SUM=e9c8a9a63ceb509f8482d73ed6d044eca8e96961c485fd395e73e93b8ea09a68
-SOURCE_FORMAT=zip
\ No newline at end of file
+SOURCE_URL=https://github.com/janeczku/calibre-web/releases/download/0.6.7/calibre-web-0.6.7.zip
+SOURCE_SUM=0c803df4b49993987a7f317c47ba38e680e45712b49da3cb7eb6c66f57379f30
+SOURCE_FORMAT=zip
diff --git a/conf/app066.src b/conf/app066.src
new file mode 100644
index 0000000..f3f4ee7
--- /dev/null
+++ b/conf/app066.src
@@ -0,0 +1,3 @@
+SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0.6.6.zip
+SOURCE_SUM=87633c2817263ed2d12fce67ea292b1c6d042aa949aafb728789c15d495415cc
+SOURCE_FORMAT=zip
diff --git a/conf/generate_password_hash.py b/conf/generate_password_hash.py
deleted file mode 100644
index 4778e8c..0000000
--- a/conf/generate_password_hash.py
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Permet de générer le hash pour le password
-#Plus utilisé depuis la MAJ 0.92~ynh3 avec LDAP
-import sys
-path=sys.argv[2]
-sys.path.append(path)
-from werkzeug.security import generate_password_hash
-password=sys.argv[1]
-print generate_password_hash(password)
diff --git a/conf/init_calibre_db_ldap_settings b/conf/init_calibre_db_ldap_settings
index d16c8e9..6c01f4d 100644
--- a/conf/init_calibre_db_ldap_settings
+++ b/conf/init_calibre_db_ldap_settings
@@ -1,3 +1,10 @@
-config_use_ldap=1,
-config_ldap_provider_url=\'localhost:389\',
-config_ldap_dn=\'uid=%s,ou=users,dc=yunohost,dc=org\'
\ No newline at end of file
+config_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\)\(permission=cn=%s.main,ou=permission,dc=yunohost,dc=org\)\)\',
+config_ldap_group_members_field=\'memberUid\',
+config_ldap_group_name=\'calibreweb\'
\ No newline at end of file
diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings
index b54e177..bdbb5cf 100644
--- a/conf/init_calibre_db_settings
+++ b/conf/init_calibre_db_settings
@@ -1,11 +1,6 @@
config_calibre_dir=\'$calibre_dir\',
config_port=$port,
-config_certfile=\'\',
-config_keyfile=\'\',
-config_use_google_drive=0,
-config_remote_login=0,
-config_use_goodreads=0,
-config_logfile=\'\',
-config_converterpath=\'\',
-config_calibre=\'\',
-config_uploading=\'$upload\',
+config_logfile=\'$LOG_FILE\',
+config_access_log=1,
+config_access_logfile=\'$ACCESS_LOG_FILE\',
+config_uploading=\'$upload\'
\ No newline at end of file
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 64bc976..51f712c 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,5 +1,5 @@
location __PATH__ {
- client_max_body_size 20M;
+ client_max_body_size 200M;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
@@ -10,8 +10,8 @@ location __PATH__ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name __PATH__;
- proxy_set_header X-Remote-User $remote_user;
+# proxy_set_header X-Remote-User $remote_user;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
-}
+}
\ No newline at end of file
diff --git a/conf/systemd.service b/conf/systemd.service
index 2fbfa40..d166c60 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
-ExecStart=/bin/sh -c '/usr/bin/python __FINALPATH__/cps.py >> /var/log/__APP__/__APP__.log 2>&1'
+ExecStart=/bin/sh -c '/usr/bin/python3.5 __FINALPATH__/cps.py'
[Install]
WantedBy=multi-user.target
diff --git a/hooks/post_user_create b/hooks/post_user_create
deleted file mode 100644
index e3a7820..0000000
--- a/hooks/post_user_create
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-# Source YunoHost helpers
-source /usr/share/yunohost/helpers
-
-#pour récupérer l'app_id, on prend le nom du fichier puis on retire les 3 premiers caratères
-app=`basename "$0"`
-app=${app:3}
-source /etc/yunohost/apps/$app/scripts/_common.sh
-
-
-username=$1
-mail=$2
-pass_clear=$3
-final_path=$(ynh_app_setting_get $app final_path)
-
-public_library=$(ynh_app_setting_get "$app" public_library)
-#User are duplicated in the database only if library is public
-if [ $public_library -eq 1 ]; then
- ######################################
- #1 get admin user and id from database
- ######################################
- #we take the admin user as we're sure there is at least this one
-
- admin=$(ynh_app_setting_get $app admin)
- admin_id=$(sqlite3 $final_path/app.db "SELECT id FROM user WHERE nickname='$admin'")
-
- ######################################
- #get user table structure
- ######################################
- table_schema=$(get_db "user")
-
- ######################################
- #Build new entry for user
- ######################################
- insert_user=$table_schema
- insert_user="${insert_user/id/null}" #so that a new entry is created
- insert_user="${insert_user/nickname/\'$username\'}"
- insert_user="${insert_user/role/0}" #standard role
- pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor)
- insert_user="${insert_user/password/\'$pass_hash\'}" #we get the same pass even if it's not thanks to LDAP, ones never knows...
- insert_user="${insert_user/email/\'$mail\'}"
-
- #######################################
- # Insert New entry in database
- #######################################
-
- sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = $admin_id;"
-fi
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 3c0ebb7..9387bc0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"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.96.0~ynh3",
+ "version": "0.96.7~ynh5",
"url": "https://github.com/janeczku/calibre-web",
"license": "free",
"maintainer": {
@@ -14,7 +14,7 @@
"email": "misterl56@hotmail.com"
},
"requirements": {
- "yunohost": ">= 3.0.0"
+ "yunohost": ">= 3.7.1"
},
"multi_instance": true,
"services": [
@@ -65,6 +65,7 @@
},
{
"name": "language",
+ "type": "string",
"optional": true,
"ask": {
"en": "Select a default language",
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 6d2551a..af50676 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,105 +1,17 @@
#!/bin/bash
-PKG_DEPENDENCIES="sqlite3 python-pip imagemagick"
+PKG_DEPENDENCIES="sqlite3 libldap2-dev libsasl2-dev python3-dev imagemagick"
+#PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick"
DOSSIER_MEDIA=/home/yunohost.multimedia
-create_dir=0
+LOG_FILE=/var/log/$app/$app.log
+ACCESS_LOG_FILE=/var/log/$app/$app-access.log
-get_db() {
- # $1 = nom de la table
- # cette ligne de malade :
- # 1/ Recupere le schém de la table user
- # 2/ En extrait les noms de champs (en prenant le premier mot après la tabulation)
- # 3/ en supprime les clé UNIQUE, PRIMARY et CHECK dont on ne veut pas
- # 4/ remplace la liste avec retour à la ligne par une liste séparé par des virgules
- # 5/ Enlève la dernière virgule
- sqlite3 $final_path/app.db ".schema $1" | awk '/\t/ {print $1}' | grep -v -e "UNIQUE" -e "PRIMARY" -e "CHECK" -e "FOREIGN" | awk '{printf "%s, ", $0}' | head -c -2
-}
#=================================================
# EXPERIMENTAL HELPERS
# TO BE DELETED WHEN RELEASED
#=================================================
-#=================================================
-#YNH_SYSTEMD_ACTION
-#=================================================
-
-# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
-#
-# usage: ynh_system_reload service_name [action]
-# | arg: -n, --service_name= - Name of the service to reload. Default : $app
-# | arg: -a, --action= - Action to perform with systemctl. Default: start
-# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
-# If not defined it don't wait until the service is completely started.
-# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
-# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
-# | arg: -e, --length= - Length of the error log : Default : 20
-ynh_systemd_action() {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
- local service_name
- local action
- local line_match
- local length
- local log_path
- local timeout
-
- # Manage arguments with getopts
- ynh_handle_getopts_args "$@"
-
- local service_name="${service_name:-$app}"
- local action=${action:-start}
- local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
- local length=${length:-20}
- local timeout=${timeout:-300}
- local wait_starting=true
-
- if [[ -z "${line_match:-}" ]]
- then
- wait_starting=false
- fi
-
- ynh_clean_check_starting () {
- # Stop the execution of tail.
- kill -s 15 $pid_tail 2>&1
- ynh_secure_remove "$templog" 2>&1
- }
-
- echo "Starting of $service_name" >&2
- systemctl $action $service_name || ( journalctl --lines=$length -u $service_name >&2 && false)
-
- if $wait_starting
- then
- # Following the starting of the app in its log
- local templog="$(mktemp)"
- tail -F -n1 "$log_path" > "$templog" &
- # Get the PID of the tail command
- local pid_tail=$!
-
- local i=0
- for i in $(seq 1 $timeout)
- do
- # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
- if grep --quiet "$line_match" "$templog"
- then
- echo "The service $service_name has correctly started." >&2
- break
- fi
- echo -n "." >&2
- sleep 1
- done
- if [ $i -eq $timeout ]
- then
- echo "The service $service_name didn't fully started before the timeout." >&2
- journalctl --lines=$length -u $service_name >&2
- fi
-
- echo ""
- ynh_clean_check_starting
- fi
-}
-
-
#=================================================
#YNH_MULTIMEDIA
#=================================================
diff --git a/scripts/backup b/scripts/backup
index ec08995..d434683 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -5,12 +5,8 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-source _common.sh
+
+
source /usr/share/yunohost/helpers
#=================================================
@@ -23,12 +19,13 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..." --weight=1
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")
@@ -36,19 +33,34 @@ calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM setting
calibre_dir=${calibre_dir%/}
ynh_app_setting_set $app calibre_dir $calibre_dir
+source ../settings/scripts/_common.sh
+
+
#=================================================
# STANDARD BACKUP STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="stop"
+
+
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
+
+ynh_script_progression --message="Backing up the main app directory..." --weight=1
#This will backup the app.db file at the same time
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
+
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
@@ -56,26 +68,34 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
-
-ynh_backup "/etc/logrotate.d/$app"
+ynh_script_progression --message="Backing up logrotate configuration..." --weight=1
+ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
-
-ynh_backup "/etc/systemd/system/$app.service"
+ynh_script_progression --message="Backing up systemd configuration..." --weight=1
+ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE DATA DIRECTORY
#=================================================
+ynh_script_progression --message="Backing up data directory..."
+ynh_print_info "Data directory will be backup up only if BACKUP_CORE_ONLY is unset"
+ynh_backup --src_path="$calibre_dir" --is_big
-backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
-# If backup_core_only have any value in the settings.yml file, do not backup the data directory
-if [ ! -z $backup_core_only ]
-then
- ynh_print_info "Backing up the library folder $calibre_dir"
- ynh_backup "$calibre_dir"
-else
- ynh_print_info "Data dir will not be saved, because backup_core_only is set." >&2
-fi
+
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=5
+
+ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 30
+
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
\ No newline at end of file
diff --git a/scripts/change_url b/scripts/change_url
index 369c1b6..cbed4c2 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
-source _common.sh
+
source /usr/share/yunohost/helpers
#=================================================
@@ -22,11 +22,29 @@ 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
+#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+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
@@ -55,9 +73,17 @@ fi
#=================================================
# STANDARD MODIFICATIONS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
+
+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
@@ -87,16 +113,24 @@ then
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
-#=================================================
-# SPECIFIC MODIFICATIONS
-#=================================================
-# ...
-#=================================================
-
#=================================================
# GENERIC FINALISATION
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 30
+
#=================================================
# RELOAD NGINX
#=================================================
+ynh_script_progression --message="Reloading nginx web server..." --weight=1
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Change of URL completed for $app" --last
diff --git a/scripts/install b/scripts/install
index 7aebc70..d971e61 100755
--- a/scripts/install
+++ b/scripts/install
@@ -6,16 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
-source _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
-
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
@@ -32,10 +24,25 @@ public_library=$7
if [ $is_public -eq 1 ]; then
public_library=1
fi
+source _common.sh
+
+
+
+source _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
+
#=================================================
# 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"
@@ -51,6 +58,7 @@ ynh_webpath_register $app $domain $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
@@ -67,16 +75,15 @@ ynh_app_setting_set $app is_public $is_public
# Find a free port
port=$(ynh_find_port 8083)
# Open this port
-ynh_print_info "Opening port $port"
+ynh_script_progression --message="Opening port $port..." --weight=5
yunohost firewall allow --no-upnp TCP $port 2>&1
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_print_info "Downloading sources to $final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
@@ -84,14 +91,26 @@ ynh_setup_source "$final_path"
# INSTALL DEPENDENCIES
#=================================================
-ynh_print_info "Installing dependencies and pip packages"
+ynh_script_progression --message="Installing package dependencies..." --weight=15
ynh_install_app_dependencies $PKG_DEPENDENCIES
-pip install --target $final_path/vendor -r $final_path/requirements.txt
+
+#use latest version of pip as per documentation in https://github.com/pypa/get-pip
+#cannot use helper as maintaining the checksum would be a pain in the a***
+curl https://bootstrap.pypa.io/get-pip.py | python3
+
+ynh_script_progression --message="Installing pip requirements..." --weight=50
+pip3 install --no-cache-dir --target $final_path/vendor -r $final_path/requirements.txt
+
+ynh_script_progression --message="Installing pip additionnal requirements..." --weight=60
+pip3 install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/optional-requirements.txt
#=================================================
# 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
+
+
if [ $path_url = "/" ] ; then
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
fi
@@ -118,7 +137,7 @@ ynh_add_systemd_config
#=================================================
# CREATE FILES AND DIRECTORIES
#=================================================
-ynh_print_info "Creating files and directory"
+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.
@@ -158,57 +177,23 @@ chown -R $app:$app /var/log/$app
#=================================================
# SET SQLITE DATABASE SETTINGS
#=================================================
-
-ynh_print_info "Setting up database and settings"
+ynh_script_progression --message="Setting up database and settings..." --weight=5
#we need to start and stop the service so that initial app.db file is created and that we can set default data
-ynh_systemd_action -l "INFO in server: Starting Gevent server"
-
+ynh_systemd_action --service_name=$app --action="start" --line_match="server on :$port" --log_path="$final_path/calibre-web.log" -t 30
#sleep required on low spec like raspberryPi
sleep 2s
-ynh_systemd_action -a stop
+#remove unwanted calibre-web.log
+ynh_secure_remove --file="$final_path/calibre-web.log"
+ynh_systemd_action --service_name=$app --action="stop"
#set database settings as per conf file
-conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\""
+conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\""
eval sqlite3 $final_path/app.db "$conf"
conf="\"UPDATE user SET $(. <(echo -E echo $(<../conf/init_calibre_db_user))) WHERE ID=1\""
eval sqlite3 $final_path/app.db "$conf"
-#mise à jour du mot de passe (je ne sais pas pourquoi, je n'arrive pas à l'intégrer dans le fichier de conf, pb de " et ')
-#ynh_print_OFF
-#had to set it on two lines or package_linter cries like a baby...
-#pass=$(python ../conf/generate_password_hash.py "$pass" $final_path/vendor)
-#sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1"
-#ynh_print_ON
-
-#Creation des autres utilisateurs
-if [ $public_library -eq 1 ]; then
- table_schema=$(get_db "user")
-
- for i in $(ynh_user_list); do
- if [ $i = $admin ]; then continue; fi
- mail=$(ynh_user_get_info $i 'mail')
- ######################################
- #Build new entry for user
- ######################################
- insert_user=$table_schema
- insert_user="${insert_user/id/null}" #so that a new entry is created
- insert_user="${insert_user/nickname/\'$i\'}"
- insert_user="${insert_user/role/0}" #standard role
- # pass_hash=$(python /etc/yunohost/apps/$app/conf/generate_password_hash.py "$pass_clear" $final_path/vendor)
- # insert_user="${insert_user/password/\'$pass_hash\'}" #we get the same pass even if it's not thanks to LDAP, ones never knows...
- insert_user="${insert_user/email/\'$mail\'}"
-
- #######################################
- # Insert New entry in database
- #######################################
-
- sqlite3 $final_path/app.db "INSERT INTO user ($table_schema) SELECT $insert_user FROM user WHERE ID = 1;"
-
- done
-fi
-
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@@ -230,7 +215,7 @@ ynh_store_file_checksum "${final_path}/app.db"
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
-yunohost service add $app --log "/var/log/$app/$app.log"
+yunohost service add $app --description "Browse eBook in the web" --log "/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
@@ -240,17 +225,22 @@ yunohost service add $app --log "/var/log/$app/$app.log"
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
- ynh_app_setting_set $app unprotected_uris "/"
+ #ynh_app_setting_set $app unprotected_uris "/"
+ ynh_permission_update --permission "main" --add visitors
fi
if [ $public_library -eq 0 ]; then
yunohost app addaccess $app -u $admin
fi
-
#=================================================
# RELOAD NGINX
#=================================================
-ynh_print_info "Reload nginx and start $app"
-systemctl reload nginx
-ynh_systemd_action -l "INFO in server: Starting Gevent server"
+ynh_script_progression --message="Reload nginx and start $app..." --weight=5
+ynh_systemd_action --service_name=nginx --action=reload
+ynh_systemd_action --service_name=$app --action="start" --line_match="server on :$port" -t 30
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+ynh_script_progression --message="Installation of $app completed" --last
diff --git a/scripts/remove b/scripts/remove
index 63bfe68..33e2e6b 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -6,12 +6,13 @@
# IMPORT GENERIC HELPERS
#=================================================
-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)
@@ -19,14 +20,16 @@ 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)
+source _common.sh
+
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
-# Remove a service from the admin panel, added by `yunohost service add`
-if yunohost service status | grep -q $app
+# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
+if ynh_exec_warn_less yunohost service status $app >/dev/null
then
- echo "Remove $app service"
+ ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
fi
@@ -37,7 +40,7 @@ fi
#=================================================
# Remove the dedicated systemd config
-ynh_print_info "Removing systemd"
+ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
ynh_remove_systemd_config
@@ -47,7 +50,7 @@ ynh_remove_systemd_config
#=================================================
# Remove metapackage and its dependencies
-ynh_print_info "Removing dependencies"
+ynh_script_progression --message="Removing Dependencies..." --weight=5
ynh_remove_app_dependencies
@@ -56,15 +59,15 @@ ynh_remove_app_dependencies
#=================================================
# Remove the app directory securely
-ynh_print_info "Removing $final_path"
-ynh_secure_remove "$final_path"
+ynh_script_progression --message="Removing $final_path..." --weight=1
+ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
-ynh_print_info "Removing nginx config"
+ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
ynh_remove_nginx_config
#=================================================
@@ -72,6 +75,7 @@ ynh_remove_nginx_config
#=================================================
# Remove the app-specific logrotate config
+ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_remove_logrotate
#=================================================
@@ -80,16 +84,12 @@ ynh_remove_logrotate
if yunohost firewall list | grep -q "\- $port$"
then
- ynh_print_info "Removing open port $port"
- echo "Close port $port" >&2
+ ynh_script_progression --message="Closing port $port..." --weight=10
yunohost firewall disallow TCP $port 2>&1
fi
-#=================================================
-# SPECIFIC REMOVE
-#=================================================
-
# Remove the log files
+ynh_script_progression --message="Removing log file..." --weight=1
ynh_secure_remove "/var/log/$app/"
#=================================================
@@ -97,12 +97,12 @@ ynh_secure_remove "/var/log/$app/"
#=================================================
# REMOVE DEDICATED USER
#=================================================
-
# Delete a system user
-ynh_system_user_delete $app
+ynh_script_progression --message="Removing the dedicated system user..." --weight=1
+ynh_system_user_delete --username=$app
#=================================================
# MESSAGE TO USER
#=================================================
-
+ynh_script_progression --message="Removal of $app completed" --last
ynh_print_warn "!!!The library folder $calibre_dir was not deleted. Delete it manually if required!!!"
diff --git a/scripts/restore b/scripts/restore
index 4f9c05f..bdcbcac 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,12 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-source _common.sh
source /usr/share/yunohost/helpers
#=================================================
@@ -24,7 +18,7 @@ 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)
@@ -33,11 +27,12 @@ final_path=$(ynh_app_setting_get $app final_path)
calibre_dir=$(ynh_app_setting_get $app calibre_dir)
is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app port)
+source ../settings/scripts/_common.sh
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
-
+ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
@@ -48,14 +43,14 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
-ynh_print_info "Restore nginx settings"
+ynh_script_progression --message="Restoring nginx configuration..." --weight=1
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# REOPEN PORT
#=================================================
-ynh_print_info "Reopening port $port"
+ynh_script_progression --message="reopening port $port..." --weight=5
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
@@ -63,15 +58,17 @@ ynh_app_setting_set $app port $port
# RECREATE THE DEDICATED USER
#=================================================
-ynh_print_info "Restore user $app"
+ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
+
# Create the dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
-ynh_print_info "Restore app directory $final_path"
-ynh_restore_file "$final_path"
+ynh_script_progression --message="Restoring the app main directory..." --weight=1
+
+ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE USER RIGHTS
@@ -87,44 +84,53 @@ chown -R $app: $final_path
#=================================================
# Define and install dependencies
-ynh_print_info "Installing dependencies and pip packages"
+ynh_script_progression --message="Reinstalling dependencies..." --weight=15
ynh_install_app_dependencies $PKG_DEPENDENCIES
-pip install --target $final_path/vendor -r $final_path/requirements.txt
-#=================================================
-# ADVERTISE SERVICE IN ADMIN PANEL
-#=================================================
+#use latest version of pip as per documentation in https://github.com/pypa/get-pip
+#cannot use helper as maintaining the checksum would be a pain in the a***
+curl https://bootstrap.pypa.io/get-pip.py | python3
-yunohost service add $app --log "/var/log/$app/$app.log"
+#pip package not required as already in app directory
+#pip install --target $final_path/vendor -r $final_path/requirements.txt
#=================================================
# RESTORE SYSTEMD
#=================================================
+ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
-ynh_restore_file "/etc/systemd/system/$app.service"
+ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
+#=================================================
+# INTEGRATE SERVICE IN YUNOHOST
+#=================================================
+
+yunohost service add $app --description "Browse eBook in the web" --log "/var/log/$app/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
-ynh_restore_file "/etc/logrotate.d/$app"
-if [ ! -e /var/log/$app ]; then
- mkdir /var/log/$app
-fi
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
+
+#=================================================
+# RESTORE THE LOG FILE DIRECTORY
+#=================================================
+mkdir -p /var/log/$app
chown -R $app:$app /var/log/$app
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
-
+ynh_script_progression --message="Restoring data directory..." --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" ]
then
- ynh_restore_file "$calibre_dir"
+ ynh_restore_file --origin_path="$calibre_dir" --not_mandatory
else
if [ ! -e "$calibre_dir" ]; then
ynh_print_info "Create calibre library folder $calibre_dir"
@@ -148,7 +154,7 @@ ynh_app_setting_delete $app backup_core_only
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
#=================================================
@@ -156,10 +162,21 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
-ynh_print_info "Reload nginx and start $app"
-systemctl reload nginx
-ynh_systemd_action -l "INFO in server: Starting Gevent server"
+ynh_script_progression --message="Reloading nginx web server..." --weight=1
+ynh_systemd_action --service_name=nginx --action=reload
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 30
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Restoration completed for $app" --last
#=================================================
# WARNING FOR READ ACCESS
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index 0c037a6..d330989 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -1,43 +1,72 @@
#!/bin/bash
+version_gt() {
+ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
+}
+
#=================================================
# GENERIC START
#=================================================
# 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)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
language=$(ynh_app_setting_get $app language)
-#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 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")
-#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
-port=$(ynh_app_setting_get $app port)
+upload=$(sqlite3 $final_path/app.db "SELECT config_uploading FROM settings WHERE ID=1")
+ynh_app_setting_set $app upload $upload
+source _common.sh
+
+#=================================================
+# CHECK VERSION
+#=================================================
+
+upgrade_type=$(ynh_check_app_version_changed)
+
+current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json") #0.96.0
+current_upstream_package_version="${current_upstream_package_version/".96"/".6"}" #0.6.0
+
+new_upstream_package_version=$(ynh_app_upstream_version) #0.96.0
+new_upstream_package_version="${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
#=================================================
# 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
}
@@ -45,7 +74,9 @@ ynh_clean_setup () {
ynh_abort_if_errors
#Stop the app in case database is updated
-ynh_systemd_action -a stop
+ynh_script_progression --message="Stopping a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# CHECK THE PATH
@@ -60,33 +91,64 @@ path_url=$(ynh_normalize_url_path $path_url)
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
-# Download, check integrity, uncompress and patch the source from app.src
-ynh_print_info "Download and install new sources"
-ynh_setup_source "$final_path"
+#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
+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"
+ current_upstream_app_version="0.6.6"
+ #remove unwanted entry in settings db
+fi
+
+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
+ # Download, check integrity, uncompress and patch the source from app.src
+ ynh_setup_source --dest_dir="$final_path"
+fi
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5
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
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
-ynh_print_info "Download and install dependencies"
-ynh_install_app_dependencies $PKG_DEPENDENCIES
-pip install --target $final_path/vendor -r $final_path/requirements.txt
+if [ "$upgrade_type" == "UPGRADE_APP" ]
+then
+ ynh_script_progression --message="Installing package dependencies..." --weight=15
+ ynh_install_app_dependencies $PKG_DEPENDENCIES
+
+ #use latest version of pip as per documentation in https://github.com/pypa/get-pip
+ #cannot use helper as maintaining the checksum would be a pain in the a***
+ curl https://bootstrap.pypa.io/get-pip.py | python3
+
+ ynh_script_progression --message="Installing pip requirements ..." --weight=30
+ pip3 install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/requirements.txt
+
+ ynh_script_progression --message="Installing pip additionnal requirements..." --weight=40
+ pip3 install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/optional-requirements.txt
+fi
#=================================================
# 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 $app
# Set permissions on app files (required to be able to update database)
@@ -97,7 +159,7 @@ chown -R $app: $final_path
#=================================================
#build multimedia directory
#=================================================
-
+ynh_script_progression --message="Create Multimedia dir..." --weight=1
#Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice.
ynh_multimedia_build_main_dir
ynh_multimedia_addaccess $app
@@ -105,18 +167,24 @@ ynh_multimedia_addaccess $app
#=================================================
#Update database structure
#=================================================
-
+ynh_script_progression --message="Update database..." --weight=1
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different "$final_path/app.db"
-#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap settings
-ynh_systemd_action -l "INFO in server: Starting Gevent server"
+#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap & log settings
+if [ "$current_upstream_app_version" == '0.6.6' ]; then
+ ynh_systemd_action --service_name=$app --action="start" --line_match="server on " --log_path="$final_path/calibre-web.log" -t 30
+else
+ ynh_systemd_action --service_name=$app --action="start" --line_match="server on :$port" -t 30
+fi
#sleep required on low spec like raspberryPi
sleep 2s
-ynh_systemd_action -a stop
+#remove unwanted calibre-web.log
+ynh_secure_remove --file="$final_path/calibre-web.log"
+ynh_systemd_action --service_name=$app --action="stop"
-conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\""
+conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\""
eval sqlite3 $final_path/app.db "$conf"
# Recalculate and store the checksum of the file for the next upgrade.
@@ -127,13 +195,16 @@ ynh_store_file_checksum "$final_path/app.db"
#=================================================
# Use logrotate to manage app-specific logfile(s)
+ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_use_logrotate --non-append
+
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
+ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_add_systemd_config
#=================================================
@@ -153,7 +224,8 @@ chown -R $app: $final_path
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
- ynh_app_setting_set $app unprotected_uris "/"
+ #ynh_app_setting_set $app unprotected_uris "/"
+ ynh_permission_update --permission "main" --add visitors
fi
#=================================================
@@ -167,6 +239,19 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
+ynh_script_progression --message="Reloading nginx web server..." --weight=1
+
+ynh_systemd_action --service_name=nginx --action=reload
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 30
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Upgrade of $app completed" --last
-systemctl reload nginx
-ynh_systemd_action -a restart -l "INFO in server: Starting Gevent server"
diff --git a/sources/patches/app-admin.html.patch b/sources/patches/app-admin.html.patch
new file mode 100644
index 0000000..4a8f42b
--- /dev/null
+++ b/sources/patches/app-admin.html.patch
@@ -0,0 +1,11 @@
+--- a/cps/templates/admin.html 2020-04-18 11:48:34.000000000 +0200
++++ b/cps/templates/admin.html 2020-04-18 18:21:39.272422475 +0200
+@@ -149,8 +149,6 @@
+
+
+