mirror of
https://github.com/YunoHost-Apps/calibreweb_ynh.git
synced 2024-09-03 18:16:20 +02:00
Merge pull request #33 from YunoHost-Apps/develop-6.7
Move to 0.6.7Beta
This commit is contained in:
commit
810352e715
23 changed files with 450 additions and 568 deletions
14
README.md
14
README.md
|
@ -52,6 +52,7 @@ chmod o+rw path/to/library
|
|||
* Do not use a Nextcloud folder. It's all right if the folder is an external storage in Nextcloud but not if it's an internal one : Changing the data in the library will cause trouble with the sync
|
||||
* "Magic link feature is not yet available
|
||||
* Change to library made outside calibreweb are not automatically updated in calibreweb. It is required to disconnect and reconnect to see the changes
|
||||
* OPDS is not yet working
|
||||
|
||||
## Links
|
||||
|
||||
|
@ -77,14 +78,17 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre
|
|||
## 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
|
||||
- [X] Disable internal update
|
||||
- [ ] Check email send
|
||||
- [ ] enable OPDS feed
|
||||
- [ ] Add cronjob to reload database (for nextcloud integration)
|
||||
- [ ] OPDS activation
|
||||
- [ ] Add action to restart the server
|
||||
- [ ] Add action to synchronize users
|
||||
- [ ] Add action to deactivate LDAP et retrieve admin password
|
||||
|
||||
|
||||
|
||||
## LICENSE
|
||||
|
|
|
@ -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&
|
|
@ -1,3 +1,3 @@
|
|||
SOURCE_URL=https://github.com/janeczku/calibre-web/archive/d81cb2927abcba3c4d198ecce9dca78550f676e1.zip
|
||||
SOURCE_SUM=e9c8a9a63ceb509f8482d73ed6d044eca8e96961c485fd395e73e93b8ea09a68
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0297823bda98de2dcfecf7fb5d3a612938f88ea3.zip
|
||||
SOURCE_SUM=776fbee7906217f70ea1f84e0ce467a2a793750b4890f460add96e22e1bc253e
|
||||
SOURCE_FORMAT=zip
|
||||
|
|
3
conf/app066.src
Normal file
3
conf/app066.src
Normal file
|
@ -0,0 +1,3 @@
|
|||
SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0.6.6.zip
|
||||
SOURCE_SUM=87633c2817263ed2d12fce67ea292b1c6d042aa949aafb728789c15d495415cc
|
||||
SOURCE_FORMAT=zip
|
|
@ -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)
|
|
@ -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\'
|
||||
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\'
|
|
@ -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\'
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -3,10 +3,10 @@
|
|||
"id": "calibreweb",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Clean interface for browsing, reading and downloading eBooks",
|
||||
"fr": "Interface simplifié pour parcourir, lire et charger des eBooks"
|
||||
"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~ynh4",
|
||||
"version": "0.96.7beta~ynh4",
|
||||
"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": [
|
||||
|
@ -67,6 +67,7 @@
|
|||
"name": "language",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Select a default language",
|
||||
"fr": "Choisissez une langue par défaut"
|
||||
|
|
|
@ -1,105 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
PKG_DEPENDENCIES="sqlite3 python-pip imagemagick"
|
||||
PKG_DEPENDENCIES="sqlite3 python-dev libldap2-dev libsasl2-dev libssl-dev python3-pip 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
|
||||
#=================================================
|
||||
|
|
|
@ -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..."
|
||||
|
||||
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
|
||||
ynh_backup --src_path="$calibre_dir" --is_big
|
||||
|
||||
|
||||
#=================================================
|
||||
# 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 20
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
|
@ -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 20
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
|
103
scripts/install
103
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,22 @@ 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
|
||||
|
||||
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 +133,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 +173,22 @@ 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
|
||||
|
||||
#sleep required on low spec like raspberryPi
|
||||
sleep 2s
|
||||
sleep 5s
|
||||
ynh_systemd_action -a 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 +210,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 +220,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 -l "server on :$port" -t 20
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -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!!!"
|
||||
|
|
|
@ -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,48 @@ 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
|
||||
#=================================================
|
||||
|
||||
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 +149,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 +157,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 20
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
#=================================================
|
||||
# WARNING FOR READ ACCESS
|
||||
#=================================================
|
||||
|
|
125
scripts/upgrade
125
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
|
||||
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
|
||||
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,60 @@ 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="server on " --log_path="$final_path/calibre-web.log" -t 20
|
||||
#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
|
||||
|
||||
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 +155,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 +163,22 @@ 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 20
|
||||
else
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="server on :$port" -t 20
|
||||
fi
|
||||
#sleep required on low spec like raspberryPi
|
||||
sleep 2s
|
||||
ynh_systemd_action -a stop
|
||||
sleep 3s
|
||||
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 +189,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 +218,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 +233,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 20
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
|
11
sources/patches/app-admin.html.patch
Normal file
11
sources/patches/app-admin.html.patch
Normal file
|
@ -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 @@
|
||||
</table>
|
||||
|
||||
<div class="hidden" id="update_error"> <span>{{update_error}}</span></div>
|
||||
- <div class="btn btn-default" id="check_for_update">{{_('Check for Update')}}</div>
|
||||
- <div class="btn btn-default hidden" id="perform_update" data-toggle="modal" data-target="#StatusDialog">{{_('Perform Update')}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,24 +0,0 @@
|
|||
--- a/cps/templates/config_edit.html 2019-01-12 09:01:08.000000000 +0100
|
||||
+++ b/cps/templates/config_edit.html 2019-01-13 11:21:11.000000000 +0100
|
||||
@@ -162,6 +162,21 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
+ <div class="form-group">
|
||||
+ <input type="checkbox" id="config_use_ldap" name="config_use_ldap" data-control="ldap-settings" {% if content.config_use_ldap %}checked{% endif %}>
|
||||
+ <label for="config_use_ldap">{{_('Use')}} LDAP Authentication</label>
|
||||
+ </div>
|
||||
+ <div data-related="ldap-settings">
|
||||
+ <div class="form-group">
|
||||
+ <label for="config_ldap_provider_url">{{_('LDAP Provider URL')}}</label>
|
||||
+ <input type="text" class="form-control" id="config_ldap_provider_url" name="config_ldap_provider_url" value="{% if content.config_use_ldap != None %}{{ content.config_ldap_provider_url }}{% endif %}" autocomplete="off">
|
||||
+ </div>
|
||||
+ <div class="form-group">
|
||||
+ <label for="config_ldap_dn">{{_('LDAP Distinguished Name (DN)')}}</label>
|
||||
+ <input type="text" class="form-control" id="config_ldap_dn" name="config_ldap_dn" value="{% if content.config_use_ldap != None %}{{ content.config_ldap_dn }}{% endif %}" autocomplete="off">
|
||||
+ </div>
|
||||
+ </div>
|
||||
+ </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
12
sources/patches/app-main.js.patch
Normal file
12
sources/patches/app-main.js.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
--- a/cps/static/js/main.js 2020-04-18 11:48:34.000000000 +0200
|
||||
+++ b/cps/static/js/main.js 2020-04-18 17:39:49.405631791 +0200
|
||||
@@ -308,7 +308,8 @@
|
||||
$.ajax({
|
||||
method:"get",
|
||||
dataType: "json",
|
||||
- url: path + "/../../import_ldap_users",
|
||||
+ url: window.location.pathname + "/../../import_ldap_users",
|
||||
+// url: path + "/../../import_ldap_users",
|
||||
success: function success(data) {
|
||||
$("#spinner2").hide();
|
||||
ResultText = data.text;
|
40
sources/patches/app-optionnal-requirements.patch
Normal file
40
sources/patches/app-optionnal-requirements.patch
Normal file
|
@ -0,0 +1,40 @@
|
|||
--- a/optional-requirements.txt 2020-04-15 22:03:21.000000000 +0200
|
||||
+++ b/optional-requirements.txt 2020-04-16 20:44:43.371235411 +0200
|
||||
@@ -1,17 +1,3 @@
|
||||
-# GDrive Integration
|
||||
-google-api-python-client==1.7.11,<1.8.0
|
||||
-gevent>=1.2.1,<1.6.0
|
||||
-greenlet>=0.4.12,<0.5.0
|
||||
-httplib2>=0.9.2,<0.18.0
|
||||
-oauth2client>=4.0.0,<4.14.0
|
||||
-uritemplate>=3.0.0,<3.1.0
|
||||
-pyasn1-modules>=0.0.8,<0.3.0
|
||||
-pyasn1>=0.1.9,<0.5.0
|
||||
-PyDrive>=1.3.1,<1.4.0
|
||||
-PyYAML>=3.12
|
||||
-rsa==3.4.2,<4.1.0
|
||||
-six>=1.10.0,<1.15.0
|
||||
-
|
||||
# goodreads
|
||||
goodreads>=0.3.2,<0.4.0
|
||||
python-Levenshtein>=0.12.0,<0.13.0
|
||||
@@ -20,19 +6,11 @@
|
||||
python_ldap>=3.0.0,<3.3.0
|
||||
flask-simpleldap>=1.4.0,<1.5.0
|
||||
|
||||
-#oauth
|
||||
-flask-dance>=1.4.0,<3.1.0
|
||||
-sqlalchemy_utils>=0.33.5,<0.37.0
|
||||
-
|
||||
# extracting metadata
|
||||
lxml>=3.8.0,<4.6.0
|
||||
Pillow>=4.0.0,<7.2.0
|
||||
rarfile>=2.7
|
||||
|
||||
-# other
|
||||
-natsort>=2.2.0,<7.1.0
|
||||
-git+https://github.com/OzzieIsaacs/comicapi.git@ad8bfe5a1c31db882480433f86db2c5c57634a3f#egg=comicapi
|
||||
-
|
||||
#Kobo integration
|
||||
jsonschema>=3.2.0,<3.3.0
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
--- a/cps/ub.py 2019-01-16 17:50:51.000000000 +0100
|
||||
+++ b/cps/ub.py 2019-01-30 22:23:29.709075421 +0100
|
||||
@@ -148,6 +148,16 @@
|
||||
def __repr__(self):
|
||||
return '<User %r>' % self.nickname
|
||||
|
||||
+#Yunohost Integration - 1
|
||||
+ #Login via LDAP method
|
||||
+ @staticmethod
|
||||
+ def try_login(username, password):
|
||||
+ conn = get_ldap_connection()
|
||||
+ conn.simple_bind_s(
|
||||
+ config.config_ldap_dn.replace("%s", username),
|
||||
+ password
|
||||
+ )
|
||||
+#END Yunohost Integration - 1
|
||||
|
||||
# Baseclass for Users in Calibre-Web, settings which are depending on certain users are stored here. It is derived from
|
||||
# User Base (all access methods are declared there)
|
||||
@@ -268,8 +278,8 @@
|
||||
domain = Column(String)
|
||||
|
||||
def __repr__(self):
|
||||
- return u"<Registration('{0}')>".format(self.domain)
|
||||
-
|
||||
+ return u"<Registration('{0}')>".format(self.domain)
|
||||
+
|
||||
|
||||
# Baseclass for representing settings in app.db with email server settings and Calibre database settings
|
||||
# (application settings)
|
||||
@@ -306,6 +316,11 @@
|
||||
config_use_goodreads = Column(Boolean)
|
||||
config_goodreads_api_key = Column(String)
|
||||
config_goodreads_api_secret = Column(String)
|
||||
+#Yunohost Integration - 2
|
||||
+ config_use_ldap = Column(Boolean)
|
||||
+ config_ldap_provider_url = Column(String)
|
||||
+ config_ldap_dn = Column(String)
|
||||
+#END Yunohost Integration - 2
|
||||
config_mature_content_tags = Column(String)
|
||||
config_logfile = Column(String)
|
||||
config_ebookconverter = Column(Integer, default=0)
|
||||
@@ -379,6 +394,11 @@
|
||||
self.config_use_goodreads = data.config_use_goodreads
|
||||
self.config_goodreads_api_key = data.config_goodreads_api_key
|
||||
self.config_goodreads_api_secret = data.config_goodreads_api_secret
|
||||
+#Yunohost Integration - 3
|
||||
+ self.config_use_ldap = data.config_use_ldap
|
||||
+ self.config_ldap_provider_url = data.config_ldap_provider_url
|
||||
+ self.config_ldap_dn = data.config_ldap_dn
|
||||
+#END Yunohost Integration - 3
|
||||
if data.config_mature_content_tags:
|
||||
self.config_mature_content_tags = data.config_mature_content_tags
|
||||
else:
|
||||
@@ -555,7 +575,7 @@
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_use_google_drive` INTEGER DEFAULT 0")
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''")
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''")
|
||||
- session.commit()
|
||||
+ session.commit()
|
||||
try:
|
||||
session.query(exists().where(Settings.config_columns_to_ignore)).scalar()
|
||||
except exc.OperationalError:
|
||||
@@ -624,6 +644,16 @@
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_goodreads_api_key` String DEFAULT ''")
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_goodreads_api_secret` String DEFAULT ''")
|
||||
try:
|
||||
+#Yunohost Integration - 4
|
||||
+ session.query(exists().where(Settings.config_use_ldap)).scalar()
|
||||
+ except exc.OperationalError:
|
||||
+ conn = engine.connect()
|
||||
+ conn.execute("ALTER TABLE Settings ADD column `config_use_ldap` INTEGER DEFAULT 0")
|
||||
+ conn.execute("ALTER TABLE Settings ADD column `config_ldap_provider_url` String DEFAULT ''")
|
||||
+ conn.execute("ALTER TABLE Settings ADD column `config_ldap_dn` String DEFAULT ''")
|
||||
+ session.commit()
|
||||
+ try:
|
||||
+#END Yunohost Integration - 4
|
||||
session.query(exists().where(Settings.config_mature_content_tags)).scalar()
|
||||
except exc.OperationalError:
|
||||
conn = engine.connect()
|
||||
@@ -668,7 +698,6 @@
|
||||
conn.execute("ALTER TABLE Settings ADD column `config_theme` INTEGER DEFAULT 0")
|
||||
session.commit()
|
||||
|
||||
-
|
||||
# Remove login capability of user Guest
|
||||
conn = engine.connect()
|
||||
conn.execute("UPDATE user SET password='' where nickname = 'Guest' and password !=''")
|
||||
@@ -778,6 +807,14 @@
|
||||
migrate_Database()
|
||||
clean_database()
|
||||
|
||||
+#Yunohost Integration - 5
|
||||
+#get LDAP connection
|
||||
+def get_ldap_connection():
|
||||
+ import ldap
|
||||
+ conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
|
||||
+ return conn
|
||||
+#END Yunohost Integration - 5
|
||||
+
|
||||
# Generate global Settings Object accessible from every file
|
||||
config = Config()
|
||||
searched_ids = {}
|
|
@ -1,85 +1,52 @@
|
|||
--- a/cps/web.py 2019-01-27 08:32:26.000000000 +0100
|
||||
+++ b/cps/web.py 2019-02-02 12:38:12.364323004 +0100
|
||||
@@ -78,6 +78,9 @@
|
||||
import server
|
||||
from reverseproxy import ReverseProxied
|
||||
from updater import updater_thread
|
||||
+#Yunohost LDAP integration - 1
|
||||
+vlogout = 0
|
||||
+#END Yunohost LDAP integration -1
|
||||
--- a/cps/web.py 2020-05-01 13:54:41.755888435 +0200
|
||||
+++ b/cps/web.py" 2020-05-01 14:03:01.337768210 +0200
|
||||
@@ -281,6 +281,10 @@
|
||||
if not config.db_configured and request.endpoint not in (
|
||||
'admin.basic_configuration', 'login') and '/static/' not in request.path:
|
||||
return redirect(url_for('admin.basic_configuration'))
|
||||
+#Début Modif Yunohost 1/4
|
||||
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
|
||||
+ import_ldap_users()
|
||||
+#Fin Modif Yunohost 1/4
|
||||
|
||||
try:
|
||||
from googleapiclient.errors import HttpError
|
||||
@@ -2256,10 +2259,36 @@
|
||||
return redirect(url_for('basic_configuration'))
|
||||
|
||||
@app.route('/import_ldap_users')
|
||||
@@ -313,7 +317,10 @@
|
||||
log.warning("Could Not Parse LDAP User: %s", user)
|
||||
continue
|
||||
if ub.session.query(ub.User).filter(ub.User.nickname == user.lower()).first():
|
||||
- log.warning("LDAP User: %s Already in Database", user)
|
||||
+# Début Modif Yunohost 2/4
|
||||
+# log.warning("LDAP User: %s Already in Database", user)
|
||||
+ log.debug("LDAP User: %s Already in Database", user)
|
||||
+#Fin Modif Yunohost 2/4
|
||||
continue
|
||||
user_data = services.ldap.get_object_details(user=user,
|
||||
group=None,
|
||||
@@ -1216,6 +1223,10 @@
|
||||
if not config.db_configured:
|
||||
log.debug(u"Redirect to initial configuration")
|
||||
return redirect(url_for('admin.basic_configuration'))
|
||||
+#Début Modif Yunohost 3/4
|
||||
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
|
||||
+ import_ldap_users()
|
||||
+#Fin Modif Yunohost 3/4
|
||||
if current_user is not None and current_user.is_authenticated:
|
||||
return redirect(url_for('index'))
|
||||
+#Yunohost integration - 2
|
||||
+ auth_user = request.headers.get('X-Remote-User')
|
||||
+ global vlogout
|
||||
+ if auth_user and config.config_use_ldap and not vlogout:
|
||||
+ vlogout = 0
|
||||
+ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first()
|
||||
+ login_user(user, remember=True)
|
||||
+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
+ return redirect(url_for("index"))
|
||||
+#END Yunohost integration - 2
|
||||
if request.method == "POST":
|
||||
form = request.form.to_dict()
|
||||
user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first()
|
||||
- if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
+#Yunohost integration - 3
|
||||
+# if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
+#END Yunohost integration - 3
|
||||
+#Yunohost Integration - 4
|
||||
+ if config.config_use_ldap and user:
|
||||
+ import ldap
|
||||
+ try:
|
||||
+ ub.User.try_login(form['username'], form['password'])
|
||||
+ login_user(user, remember=True)
|
||||
+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
+ return redirect_back(url_for("index"))
|
||||
+ except ldap.INVALID_CREDENTIALS:
|
||||
+ ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
+ app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress)
|
||||
+ flash(_(u"Wrong Username or Password"), category="error")
|
||||
+ elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
+#End Yunohost Integration - 4
|
||||
login_user(user, remember=True)
|
||||
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
return redirect_back(url_for("index"))
|
||||
@@ -2280,6 +2309,10 @@
|
||||
@login_required
|
||||
def logout():
|
||||
if current_user is not None and current_user.is_authenticated:
|
||||
+#Yunohost Integration - 5
|
||||
+ global vlogout
|
||||
+ vlogout = 1
|
||||
+#End Yunohost integration - 5
|
||||
logout_user()
|
||||
return redirect(url_for('login'))
|
||||
return redirect(url_for('web.index'))
|
||||
if config.config_login_type == constants.LOGIN_LDAP and not services.ldap:
|
||||
@@ -1290,8 +1301,13 @@
|
||||
if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3):
|
||||
logout_oauth_user()
|
||||
log.debug(u"User logged out")
|
||||
- return redirect(url_for('web.login'))
|
||||
-
|
||||
+#Début Modif Yunohost 4/4
|
||||
+# return redirect(url_for('web.login'))
|
||||
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
|
||||
+ return redirect(request.host_url)
|
||||
+ else:
|
||||
+ return redirect(url_for('web.login'))
|
||||
+#Fin Modif Yunohost 4/4
|
||||
|
||||
@@ -2987,6 +3020,23 @@
|
||||
if "config_ebookconverter" in to_save:
|
||||
content.config_ebookconverter = int(to_save["config_ebookconverter"])
|
||||
|
||||
+#Yunohost Integration - 6
|
||||
+ #LDAP configuration,
|
||||
+ if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on":
|
||||
+ if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save:
|
||||
+ ub.session.commit()
|
||||
+ flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
||||
+ return render_title_template("config_edit.html", content=config, origin=origin,
|
||||
+ gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError,
|
||||
+ goodreads=goodreads_support, title=_(u"Basic Configuration"),
|
||||
+ page="config")
|
||||
+ else:
|
||||
+ content.config_use_ldap = 1
|
||||
+ content.config_ldap_provider_url = to_save["config_ldap_provider_url"]
|
||||
+ content.config_ldap_dn = to_save["config_ldap_dn"]
|
||||
+ db_change = True
|
||||
+#END Yunohost integration - 6
|
||||
+
|
||||
# Remote login configuration
|
||||
content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on")
|
||||
if not content.config_remote_login:
|
||||
@web.route('/remote/login')
|
||||
@remote_login_required
|
||||
|
|
Loading…
Add table
Reference in a new issue