1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/calibreweb_ynh.git synced 2024-09-03 18:16:20 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:09:54 +02:00 committed by GitHub
commit 99a7445c72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 178 additions and 436 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
*~
*.sw[op]
/check_process
.DS_Store

View file

@ -17,7 +17,8 @@ admindoc = "https://github.com/janeczku/calibre-web/wiki"
code = "https://github.com/janeczku/calibre-web"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = true

View file

@ -5,9 +5,6 @@ log_file=/var/log/$app/$app.log
access_log_file=/var/log/$app/$app-access.log
mach=`uname -m`
case "$mach" in
"armv6l" ) mach="arm"
;;
@ -20,5 +17,6 @@ case "$mach" in
"x86_64" ) mach="64bit"
;;
* ) mach="32bit"
;;
esac

View file

@ -1,44 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#Get settings from database in case it has been changed in the app
calibre_dir=$(sqlite3 $install_dir/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
#Save it in settings so that it can be used back afterward
calibre_dir=${calibre_dir%/}
ynh_app_setting_set $app calibre_dir $calibre_dir
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
#This will backup the app.db file at the same time
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE KEPUBIFY BINARY
#=================================================
ynh_backup --src_path="/opt/kepubify/$app"
ynh_backup "/opt/kepubify/$app"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
@ -46,30 +36,29 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE DATA DIRECTORY
#=================================================
ynh_backup --src_path="$calibre_dir" --is_big
ynh_backup "$calibre_dir"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,63 +1,54 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
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
ynh_script_progression "Backing up the app before changing its url (may take a while)..."
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemctl --service=$app --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
#Cannot use empty string for X-script-name, causes an issue in the python prg
if [ $new_path = "/" ] ; then
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
else
ynh_replace_string "# proxy_set_header X-Script-Name" " proxy_set_header X-Script-Name" ../conf/nginx.conf
# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace "# proxy_set_header X-Script-Name" " proxy_set_header X-Script-Name" ../conf/nginx.conf
fi
if $(ynh_permission_has_user --permission=main --user=visitors); then
ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \
--replace_string="# proxy_set_header X-Remote-User" \
--target_file="../conf/nginx.conf"
ynh_replace --match=" proxy_set_header X-Remote-User" \
--replace="# proxy_set_header X-Remote-User" \
--file="../conf/nginx.conf"
else
ynh_replace_string --match_string="# proxy_set_header X-Remote-User" \
--replace_string=" proxy_set_header X-Remote-User" \
--target_file="../conf/nginx.conf"
ynh_replace --match="# proxy_set_header X-Remote-User" \
--replace=" proxy_set_header X-Remote-User" \
--file="../conf/nginx.conf"
fi
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
ynh_systemctl --service=$app --action="start" --wait_until="Starting Gevent server on" -t 30
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,15 +1,8 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
if [ $public_library -eq 1 ]; then
@ -18,19 +11,17 @@ else # library is private
calibre_dir=$DOSSIER_MEDIA/$admin/eBook
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Installing and patching sources to $install_dir..." --weight=10
ynh_script_progression "Installing and patching sources to $install_dir..."
#Set settings constant initializer of the app
ynh_add_config --template="../sources/patches/main-config_sql.py.patch.src" --destination="../sources/patches/main-config_sql.py.patch"
ynh_add_config --template="../sources/patches/main-ub.py.patch.src" --destination="../sources/patches/main-ub.py.patch"
ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch"
ynh_config_add --template="../patches/main-config_sql.py.patch.src" --destination="../patches/main-config_sql.py.patch"
ynh_config_add --template="../patches/main-ub.py.patch.src" --destination="../patches/main-ub.py.patch"
ynh_config_add --template="../patches/main-constants.py.patch.src" --destination="../patches/main-constants.py.patch"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
@ -41,40 +32,38 @@ if $(ynh_permission_has_user --permission=main --user=visitors); then
fi
#install kepubify converter
ynh_script_progression --message="Installing kepubify..." --weight=1
ynh_script_progression "Installing kepubify..."
ynh_setup_source --dest_dir="/opt/kepubify/$app/" --source_id="kepubify"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
ynh_script_progression --message="Installing pip requirements..." --weight=70
ynh_script_progression "Installing pip requirements..."
# Always recreate everything fresh with current python version
if [ -d "${install_dir}/venv" ] ; then
ynh_secure_remove "${install_dir}/venv"
ynh_safe_rm "${install_dir}/venv"
fi
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${install_dir}/venv"
chown -R "$app:" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir"
#run source in a 'sub shell'
(
set +o nounset
source "${install_dir}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
ynh_exec_as_app $install_dir/venv/bin/python3 -m ensurepip
ynh_exec_as_app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
)
#=================================================
# CREATE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Creating files and directory..." --weight=5
ynh_script_progression "Creating files and directory..."
#build multimedia directory
ynh_multimedia_build_main_dir
@ -91,50 +80,47 @@ ynh_app_setting_set $app calibre_dir $calibre_dir
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Setting up system configuration..." --weight=5
ynh_script_progression "Setting up system configuration..."
#Cannot use empty string for X-script-name, causes an issue in the python prg
#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#nginx
if [ $path = "/" ] ; then
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
fi
#
if $(ynh_permission_has_user --permission=main --user=visitors); then
ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \
--replace_string="# proxy_set_header X-Remote-User" \
--target_file="../conf/nginx.conf"
ynh_replace --match=" proxy_set_header X-Remote-User" \
--replace="# proxy_set_header X-Remote-User" \
--file="../conf/nginx.conf"
fi
# Create a dedicated nginx config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
#=================================================
# SETUP LOGROTATE
#=================================================
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$log_file"
ynh_use_logrotate --logfile="$access_log_file"
chown -R $app:$app /var/log/$app
ynh_config_add_logrotate "$log_file"
ynh_config_add_logrotate "$access_log_file"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app /var/log/$app
#=================================================
# SPECIFIC SETUP
#=================================================
#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files
ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
--target_file="/etc/ImageMagick-6/policy.xml"
ynh_replace --match="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace="<policy domain="coder" rights="read" pattern="PDF" />" \
--file="/etc/ImageMagick-6/policy.xml"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@ -142,22 +128,19 @@ ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern=
yunohost service add $app --description="Browse eBook in the web" --log="$log_file"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R $app: $install_dir
chmod 740 $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 740 $install_dir
chown -R $app: /opt/kepubify/$app
chmod 770 /opt/kepubify/$app/kepubify
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --weight=8
ynh_script_progression "Configuring Fail2Ban..."
# Make sure a log file exists (mostly for CI tests)
if [ ! -f "$log_file" ]; then
@ -166,25 +149,24 @@ if [ ! -f "$log_file" ]; then
fi
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --max_retry=5
ynh_config_add_fail2ban --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Start $app..." --weight=5
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
ynh_script_progression "Start $app..."
ynh_systemctl --service=$app --action="start" --wait_until="Starting Gevent server on" -t 30
#Setting the proxy authentication in case calibre is not open to visitor.
#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source
#We need to update the sso login parameter, but for that the app needs to have run at least once to initialize the tables.
if ! $(ynh_permission_has_user --permission=main --user=visitors); then
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemctl --service=$app --action="stop"
sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;"
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on"
ynh_systemctl --service=$app --action="start" --wait_until="Starting Gevent server on"
fi
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -14,9 +8,9 @@ source /usr/share/yunohost/helpers
#=================================================
# 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
if ynh_hide_warnings yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
ynh_script_progression "Removing $app service..."
yunohost service remove $app
fi
@ -27,9 +21,8 @@ fi
#=================================================
# Remove the dedicated systemd config
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
ynh_remove_systemd_config
ynh_script_progression "Stopping and removing the systemd service..."
ynh_config_remove_systemd
#=================================================
# REMOVE DATA DIR
@ -38,8 +31,8 @@ ynh_remove_systemd_config
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$calibre_dir"
ynh_script_progression "Removing app data directory..."
ynh_safe_rm "$calibre_dir"
fi
#=================================================
@ -47,32 +40,32 @@ fi
#=================================================
# Remove the data directory if --purge option is used
ynh_script_progression --message="Removing kepubify directory..." --weight=1
ynh_secure_remove --file="/opt/kepubify/$app"
ynh_script_progression "Removing kepubify directory..."
ynh_safe_rm "/opt/kepubify/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
ynh_remove_nginx_config
ynh_script_progression "Removing nginx web server configuration..."
ynh_config_remove_nginx
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_remove_logrotate
ynh_script_progression "Removing logrotate configuration..."
ynh_config_remove_logrotate
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8
ynh_script_progression "Removing Fail2Ban configuration..."
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
ynh_config_remove_fail2ban
#=================================================
# CLOSE A PORT
@ -80,25 +73,26 @@ ynh_remove_fail2ban_config
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=10
ynh_script_progression "Closing port $port..."
yunohost firewall disallow TCP $port 2>&1
fi
#Restore Imagick policy
if [ -z /etc/ImageMagick-6/policy.xml ]; then
ynh_replace_string --match_string="<policy domain="coder" rights="read" pattern="PDF" />" \
--replace_string="<policy domain="coder" rights="none" pattern="PDF" />" \
--target_file="/etc/ImageMagick-6/policy.xml"
ynh_replace --match="<policy domain="coder" rights="read" pattern="PDF" />" \
--replace="<policy domain="coder" rights="none" pattern="PDF" />" \
--file="/etc/ImageMagick-6/policy.xml"
fi
ynh_script_progression --message="Removing log file..." --weight=1
ynh_secure_remove "$log_file"
ynh_secure_remove "$access_log_file"
ynh_script_progression "Removing log file..."
ynh_safe_rm "$log_file"
ynh_safe_rm "$access_log_file"
#=================================================
# MESSAGE TO USER
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 0 ]
then

View file

@ -1,72 +1,62 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression "Restoring nginx configuration..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$install_dir"
ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
#=================================================
# RESTORE THE KEPUBIFY BINARIES
#=================================================
ynh_script_progression --message="Restoring Kepubify..." --weight=1
ynh_restore_file --origin_path="/opt/kepubify/$app"
ynh_script_progression "Restoring Kepubify..."
ynh_restore "/opt/kepubify/$app"
#=================================================
# RESTORE USER RIGHTS
#=================================================
chown -R $app: $install_dir
chmod 740 $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 740 $install_dir
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
ynh_script_progression --message="Reinstalling pip requirements..." --weight=70
ynh_script_progression "Reinstalling pip requirements..."
# Always recreate everything fresh with current python version
# When reinstalling on a new yunohost, this is required
if [ -d "${install_dir}/venv" ] ; then
ynh_secure_remove "${install_dir}/venv"
ynh_safe_rm "${install_dir}/venv"
fi
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${install_dir}/venv"
chown -R "$app:" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir"
#run source in a 'sub shell'
(
cd "$install_dir"
set +o nounset
source "venv/bin/activate"
set -o nounset
ynh_exec_as $app venv/bin/python3 -m ensurepip
ynh_exec_as $app venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as $app venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
ynh_exec_as_app venv/bin/python3 -m ensurepip
ynh_exec_as_app venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as_app venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as_app venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
)
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_script_progression "Restoring $app's systemd service..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
@ -79,25 +69,25 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# RESTORE THE LOG FILE DIRECTORY
#=================================================
mkdir -p /var/log/$app
chown -R $app:$app /var/log/$app
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app /var/log/$app
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring data directory if required..." --weight=2
ynh_restore_file --origin_path="$calibre_dir" --not_mandatory
ynh_script_progression "Restoring data directory if required..."
ynh_restore "$calibre_dir" || true
#=================================================
# RESTORE THE MULTIMEDIA DIR IF NOT EXISTING
#=================================================
ynh_script_progression --message="Restoring the multimedia directory..." --weight=5
ynh_script_progression "Restoring the multimedia directory..."
ynh_multimedia_build_main_dir
ynh_multimedia_addaccess $app
@ -120,50 +110,47 @@ fi
# SPECIFIC SETUP
#===================================================
#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files
ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
--target_file="/etc/ImageMagick-6/policy.xml"
ynh_replace --match="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace="<policy domain="coder" rights="read" pattern="PDF" />" \
--file="/etc/ImageMagick-6/policy.xml"
# Remove the option backup_core_only if it's in the settings.yml file
ynh_app_setting_delete $app backup_core_only
#=================================================
# RESTORE THE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=7
ynh_script_progression "Restoring the Fail2Ban configuration..."
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
if [ ! -f "$log_file" ]; then
touch "$log_file"
chown $app: "$log_file"
fi
ynh_systemd_action --action=restart --service_name=fail2ban
ynh_systemctl --action=restart --service=fail2ban
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_script_progression "Reloading nginx web server..."
ynh_systemctl --service=nginx --action=reload
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
ynh_systemctl --service=$app --action="start" --wait_until="Starting Gevent server on" -t 30
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"
#=================================================
# WARNING FOR READ ACCESS
#=================================================

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -22,12 +16,6 @@ ynh_app_setting_set $app upload $upload
language=$(sqlite3 $install_dir/app.db "SELECT config_default_locale FROM settings WHERE ID=1")
ynh_app_setting_set $app language $language
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
if [ -f /etc/yunohost/apps/$app/manifest.toml ]; then
current_upstream_package_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.toml") #0.96.0
else
@ -48,35 +36,35 @@ current_upstream_app_version=$(cat $install_dir/cps/constants.py | grep STABLE_V
current_upstream_app_version="${current_upstream_app_version/STABLE_VERSION = \{\'version\': \'/""}"
current_upstream_app_version="${current_upstream_app_version/\'\}/""}"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_clean_check_starting
#Stop the app in case database is updated
ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemctl --service=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Downward Compatibility checks..." --weight=1
ynh_script_progression "Downward Compatibility checks..."
#Close unwanted open port in firewall
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port as it shouldn't be open..."
ynh_script_progression "Closing port $port as it shouldn't be open..."
yunohost firewall disallow TCP $port 2>&1
fi
#LDAP settings were wrongly set in version prior to 0.6.13 and we could not retrieve LDAP users. This will change the settings to correct values
if sqlite3 $install_dir/app.db "SELECT config_ldap_group_object_filter FROM settings" \
| grep -xq "(&(objectClass=posixGroup)(permission=cn=%s.main,ou=permission,dc=yunohost,dc=org))" ; then
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_ldap_group_object_filter='(&(objectClass=posixGroup)(cn=%s.main))' WHERE ID=1\""
fi
#Adding kepubify converter
if [ -z $(sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings") ]; then
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\""
@ -94,24 +82,22 @@ if sqlite3 $install_dir/app.db "SELECT config_kepubifypath FROM settings" | grep
eval sqlite3 $install_dir/app.db "\"UPDATE settings SET config_kepubifypath='/opt/kepubify/$app/kepubify' WHERE ID=1\""
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..." --weight=10
ynh_script_progression "Upgrading source files from $current_upstream_app_version to $new_upstream_package_version..."
#Set settings constant initializer of the app
ynh_add_config --template="../sources/patches/main-config_sql.py.patch.src" --destination="../sources/patches/main-config_sql.py.patch"
ynh_add_config --template="../sources/patches/main-ub.py.patch.src" --destination="../sources/patches/main-ub.py.patch"
ynh_add_config --template="../sources/patches/main-constants.py.patch.src" --destination="../sources/patches/main-constants.py.patch"
ynh_config_add --template="../patches/main-config_sql.py.patch.src" --destination="../patches/main-config_sql.py.patch"
ynh_config_add --template="../patches/main-ub.py.patch.src" --destination="../patches/main-ub.py.patch"
ynh_config_add --template="../patches/main-constants.py.patch.src" --destination="../patches/main-constants.py.patch"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chown -R $app: $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: $install_dir
# Remove the patch for web.py in case visitor are allowed
if $(ynh_permission_has_user --permission=main --user=visitors); then
patch -u /$install_dir/cps/web.py -i ../conf/web.py.revert.patch
@ -123,105 +109,96 @@ fi
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=5
ynh_script_progression "Upgrading nginx web server configuration..."
#Cannot use empty string for X-script-name, causes an issue in the python prg
#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#nginx
if [ $path = "/" ] ; then
ynh_replace_string " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace " proxy_set_header X-Script-Name" "# proxy_set_header X-Script-Name" ../conf/nginx.conf
fi
#Setting the proxy authentication in case calibre is not open to visitor.
#https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy#login-via-header-from-upstream-authentication-source
if $(ynh_permission_has_user --permission=main --user=visitors); then
sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='', config_allow_reverse_proxy_header_login=0 WHERE ID=1;"
ynh_replace_string --match_string=" proxy_set_header X-Remote-User" \
--replace_string="# proxy_set_header X-Remote-User" \
--target_file="../conf/nginx.conf"
ynh_replace --match=" proxy_set_header X-Remote-User" \
--replace="# proxy_set_header X-Remote-User" \
--file="../conf/nginx.conf"
else
sqlite3 $install_dir/app.db "UPDATE settings SET config_reverse_proxy_login_header_name='X-Remote-User', config_allow_reverse_proxy_header_login=1 WHERE ID=1;"
fi
# Create a dedicated nginx config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install
ynh_script_progression --message="Installing pip requirements..." --weight=70
ynh_script_progression "Installing pip requirements..."
# Always recreate everything fresh with current python version
if [ -d "${install_dir}/venv" ] ; then
ynh_secure_remove "${install_dir}/venv"
ynh_safe_rm "${install_dir}/venv"
fi
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${install_dir}/venv"
chown -R "$app:" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir"
#run source in a 'sub shell'
(
set +o nounset
source "${install_dir}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
ynh_exec_as_app $install_dir/venv/bin/python3 -m ensurepip
ynh_exec_as_app $install_dir/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/requirements.txt"
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade -r "$install_dir/optional-requirements.txt"
)
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
#build multimedia directory
#=================================================
ynh_script_progression --message="Create Multimedia dir..." --weight=1
ynh_script_progression "Create Multimedia dir..."
#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
#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files
ynh_script_progression --message="Update Imagick policy..." --weight=1
ynh_replace_string --match_string="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace_string="<policy domain="coder" rights="read" pattern="PDF" />" \
--target_file="/etc/ImageMagick-6/policy.xml"
ynh_script_progression "Update Imagick policy..."
ynh_replace --match="<policy domain="coder" rights="none" pattern="PDF" />" \
--replace="<policy domain="coder" rights="read" pattern="PDF" />" \
--file="/etc/ImageMagick-6/policy.xml"
#=================================================
# SETUP LOGROTATE
#=================================================
# Use logrotate to manage app-specific logfile(s)
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_use_logrotate --logfile="$log_file" --nonappend
ynh_use_logrotate --logfile="$access_log_file" --nonappend
ynh_script_progression "Upgrading logrotate configuration..."
ynh_config_add_logrotate "$log_file"
ynh_config_add_logrotate "$access_log_file"
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_add_systemd_config
ynh_script_progression "Upgrading systemd configuration..."
ynh_config_add_systemd
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R $app: $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: $install_dir
chown -R $app: /opt/kepubify/$app
#=================================================
@ -233,8 +210,7 @@ yunohost service add $app --description="Browse eBook in the web" --log="$log_fi
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..." --weight=8
ynh_script_progression "Configuring Fail2Ban..."
# Make sure a log file exists (mostly for CI tests)
if [ ! -f "$log_file" ]; then
@ -243,17 +219,17 @@ if [ ! -f "$log_file" ]; then
fi
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$" --max_retry=5
ynh_config_add_fail2ban --logpath="$log_file" --failregex="^.*LDAP Login failed for user .* IP-address: <HOST>.*$"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting Gevent server on" -t 30
ynh_systemctl --service=$app --action="start" --wait_until="Starting Gevent server on" -t 30
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"

View file

@ -1,14 +0,0 @@
--- a/cps/templates/admin.html 2022-03-06 16:10:41.000000000 +0100
+++ b/cps/templates/admin.html 2022-03-08 20:59:38.344889625 +0100
@@ -189,11 +189,6 @@
</tbody>
</table>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
- {% if feature_support['updater'] %}
- <div class="hidden" id="update_error"> <span>{{update_error}}</span></div>
- <div class="btn btn-primary" id="check_for_update">{{_('Check for Update')}}</div>
- <div class="btn btn-primary hidden" id="perform_update" data-toggle="modal" data-target="#StatusDialog">{{_('Perform Update')}}</div>
- {% endif %}
</div>
</div>
</div>

View file

@ -1,61 +0,0 @@
--- a/cps/config_sql.py 2023-10-21 12:40:32.000000000 +0200
+++ b/cps/config_sql.py 2023-11-09 23:14:23.774051473 +0100
@@ -67,7 +67,7 @@
mail_server_type = Column(SmallInteger, default=0)
mail_gmail_token = Column(JSON, default={})
- config_calibre_dir = Column(String)
+ config_calibre_dir = Column(String, default='__CALIBRE_DIR__')
config_calibre_uuid = Column(String)
config_port = Column(Integer, default=constants.DEFAULT_PORT)
config_external_port = Column(Integer, default=constants.DEFAULT_PORT)
@@ -83,11 +83,11 @@
config_theme = Column(Integer, default=0)
config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL)
- config_logfile = Column(String, default=logger.DEFAULT_LOG_FILE)
- config_access_log = Column(SmallInteger, default=0)
- config_access_logfile = Column(String, default=logger.DEFAULT_ACCESS_LOG)
+ config_logfile = Column(String, default='__LOG_FILE__')
+ config_access_log = Column(SmallInteger, default=1)
+ config_access_logfile = Column(String, default='__ACCESS_LOG_FILE__')
- config_uploading = Column(SmallInteger, default=0)
+ config_uploading = Column(SmallInteger, default=__UPLOAD__)
config_anonbrowse = Column(SmallInteger, default=0)
config_public_reg = Column(SmallInteger, default=0)
config_remote_login = Column(Boolean, default=False)
@@ -114,11 +114,11 @@
config_goodreads_api_secret_e = Column(String)
config_goodreads_api_secret = Column(String)
config_register_email = Column(Boolean, default=False)
- config_login_type = Column(Integer, default=0)
+ config_login_type = Column(Integer, default=1)
config_kobo_proxy = Column(Boolean, default=False)
- config_ldap_provider_url = Column(String, default='example.org')
+ config_ldap_provider_url = Column(String, default='localhost')
config_ldap_port = Column(SmallInteger, default=389)
config_ldap_authentication = Column(SmallInteger, default=constants.LDAP_AUTH_SIMPLE)
config_ldap_serv_username = Column(String, default='cn=admin,dc=example,dc=org')
@@ -128,15 +128,15 @@
config_ldap_cacert_path = Column(String, default="")
config_ldap_cert_path = Column(String, default="")
config_ldap_key_path = Column(String, default="")
- config_ldap_dn = Column(String, default='dc=example,dc=org')
- config_ldap_user_object = Column(String, default='uid=%s')
+ config_ldap_dn = Column(String, default='dc=yunohost,dc=org')
+ config_ldap_user_object = Column(String, default='(&(objectClass=posixAccount)(permission=cn=calibreweb.main,ou=permission,dc=yunohost,dc=org)(uid=%s))')
config_ldap_member_user_object = Column(String, default='')
config_ldap_openldap = Column(Boolean, default=True)
- config_ldap_group_object_filter = Column(String, default='(&(objectclass=posixGroup)(cn=%s))')
+ config_ldap_group_object_filter = Column(String, default='(&(objectClass=posixGroup)(cn=%s.main))')
config_ldap_group_members_field = Column(String, default='memberUid')
config_ldap_group_name = Column(String, default='calibreweb')
- config_kepubifypath = Column(String, default=None)
+ config_kepubifypath = Column(String, default='/opt/kepubify/__APP__/kepubify')
config_converterpath = Column(String, default=None)
config_calibre = Column(String)
config_rarfile_location = Column(String, default=None)

View file

@ -1,26 +0,0 @@
--- a/cps/constants.py 2022-03-06 16:10:41.000000000 +0100
+++ b/cps/constants.py 2022-03-08 21:06:19.917000241 +0100
@@ -27,7 +27,7 @@
HOME_CONFIG = os.path.isfile(os.path.join(os.path.dirname(os.path.abspath(__file__)), '.HOMEDIR'))
# In executables updater is not available, so variable is set to False there
-UPDATER_AVAILABLE = True
+UPDATER_AVAILABLE = False
# Base dir is parent of current file, necessary if called from different folder
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir))
@@ -124,12 +124,12 @@
DEFAULT_MAIL_SERVER = "mail.example.org"
DEFAULT_PASSWORD = "admin123" # nosec
-DEFAULT_PORT = 8083
+DEFAULT_PORT = __PORT__
env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT)
try:
DEFAULT_PORT = int(env_CALIBRE_PORT)
except ValueError:
- print('Environment variable CALIBRE_PORT has invalid value (%s), faling back to default (8083)' % env_CALIBRE_PORT)
+ print('Environment variable CALIBRE_PORT has invalid value (%s), faling back to default (__PORT__)' % env_CALIBRE_PORT)
del env_CALIBRE_PORT

View file

@ -1,39 +0,0 @@
--- a/optional-requirements.txt 2024-07-06 04:29:16.000000000 +0200
+++ b/optional-requirements.txt 2024-07-09 23:27:11.250122853 +0200
@@ -1,19 +1,5 @@
# GDrive Integration
-google-api-python-client>=1.7.11,<2.200.0
gevent>20.6.0,<24.3.0
-greenlet>=0.4.17,<3.1.0
-httplib2>=0.9.2,<0.23.0
-oauth2client>=4.0.0,<4.1.4
-uritemplate>=3.0.0,<4.2.0
-pyasn1-modules>=0.0.8,<0.5.0
-pyasn1>=0.1.9,<0.7.0
-PyDrive2>=1.3.1,<1.20.0
-PyYAML>=3.12,<6.1
-rsa>=3.4.2,<4.10.0
-
-# Gmail
-google-auth-oauthlib>=0.4.3,<1.3.0
-google-api-python-client>=1.7.11,<2.200.0
# goodreads
goodreads>=0.3.2,<0.4.0
@@ -23,9 +9,6 @@
python-ldap>=3.0.0,<3.5.0
Flask-SimpleLDAP>=1.4.0,<2.1.0
-# oauth
-Flask-Dance>=2.0.0,<7.1.0
-SQLAlchemy-Utils>=0.33.5,<0.42.0
# metadata extraction
rarfile>=3.2,<5.0
@@ -43,6 +26,3 @@
# Kobo integration
jsonschema>=3.2.0,<4.23.0
-
-# Hide console Window on Windows
-pywin32>=220,<310 ; sys_platform == 'win32'

View file

@ -1,22 +0,0 @@
--- a/cps/ub.py 2023-03-27 19:49:57.000000000 +0200
+++ b/cps/ub.py 2023-04-08 15:48:09.987725888 +0200
@@ -235,7 +235,7 @@
kindle_mail = Column(String(120), default="")
shelf = relationship('Shelf', backref='user', lazy='dynamic', order_by='Shelf.name')
downloads = relationship('Downloads', backref='user', lazy='dynamic')
- locale = Column(String(2), default="en")
+ locale = Column(String(2), default="__LANGUAGE__")
sidebar_view = Column(Integer, default=1)
default_language = Column(String(3), default="all")
denied_tags = Column(String, default="")
@@ -796,8 +796,8 @@
# Generate User admin with admin123 password, and access to everything
def create_admin_user(_session):
user = User()
- user.name = "admin"
- user.email = "admin@example.org"
+ user.name = "__ADMIN__"
+ user.email = "__ADMIN_MAIL__"
user.role = constants.ADMIN_USER_ROLES
user.sidebar_view = constants.ADMIN_USER_SIDEBAR

View file

@ -1,15 +0,0 @@
--- a/cps/web.py 2023-03-27 19:49:57.000000000 +0200
+++ b/cps/web.py 2023-08-05 11:58:20.353503437 +0200
@@ -1411,7 +1411,11 @@
if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3):
logout_oauth_user()
log.debug("User logged out")
- return redirect(url_for('web.login'))
+# return redirect(url_for('web.login'))
+ if config.config_login_type == constants.LOGIN_LDAP:
+ return redirect(request.host_url + '/yunohost/sso/?action=logout')
+ else:
+ return redirect(url_for('web.login'))
# ################################### Users own configuration #########################################################