1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/calibreweb_ynh.git synced 2024-09-03 18:16:20 +02:00

Update Restore & Backup

This commit is contained in:
Krakinou 2018-12-24 11:15:52 +01:00
parent 13744daa6f
commit 029fc89e0e
4 changed files with 44 additions and 14 deletions

View file

@ -8,7 +8,7 @@
language="en" language="en"
is_public=0 (PUBLIC|public=1|private=0) is_public=0 (PUBLIC|public=1|private=0)
upload=1 upload=1
password="password" password="] jG?>j-@X}?A1u}DEA dZMKfQS]^r"
# port="8083" (PORT) # port="8083" (PORT)
; Checks ; Checks
pkg_linter=1 pkg_linter=1

View file

@ -25,14 +25,19 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
calibre_dir=$(ynh_app_setting_get $app calibre_dir)
#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")
#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
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
#This will backup the app.db file at the same time
ynh_backup "$final_path" ynh_backup "$final_path"
#================================================= #=================================================
@ -69,5 +74,3 @@ then
else else
echo "Data dir will not be saved, because backup_core_only is set." >&2 echo "Data dir will not be saved, because backup_core_only is set." >&2
fi fi

View file

@ -37,8 +37,6 @@ upload=$7
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -97,7 +95,7 @@ pip install --target $final_path/vendor -r $final_path/requirements.txt
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
#Cannot use empty string for X-script-name #Cannot use empty string for X-script-name, causes an issue in the python prg
if [ $path_url = "/" ] ; then if [ $path_url = "/" ] ; then
ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name /$app;" ../conf/nginx.conf ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name /$app;" ../conf/nginx.conf
fi fi
@ -112,7 +110,6 @@ ynh_add_nginx_config
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create $app
chown -R $app: $final_path chown -R $app: $final_path
#================================================= #=================================================
@ -173,7 +170,7 @@ 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 ') #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 ynh_print_OFF
#had to set it on two lines or package_linter cries... #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) pass=$(python ../conf/generate_password_hash.py "$pass" $final_path/vendor)
sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1" sqlite3 $final_path/app.db "UPDATE user SET password='$pass' WHERE ID=1"
ynh_print_ON ynh_print_ON

View file

@ -26,6 +26,8 @@ domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
calibre_dir=$(ynh_app_setting_get $app calibre_dir) 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)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -41,22 +43,31 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Restore nginx settings"
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # REOPEN PORT
#================================================= #=================================================
ynh_restore_file "$final_path" ynh_print_info "Reopening port $port"
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Restore user $app"
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restore app directory $final_path"
ynh_restore_file "$final_path"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
@ -71,7 +82,9 @@ chown -R $app: $final_path
#================================================= #=================================================
# Define and install dependencies # Define and install dependencies
ynh_print_info "Installing dependencies and pip packages"
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
pip install --target $final_path/vendor -r $final_path/requirements.txt
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
@ -118,11 +131,28 @@ fi
# Remove the option backup_core_only if it's in the settings.yml file # Remove the option backup_core_only if it's in the settings.yml file
ynh_app_setting_delete $app backup_core_only ynh_app_setting_delete $app backup_core_only
#=================================================
# SETUP SSOWAT
#=================================================
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reload nginx and start $app"
systemctl reload nginx systemctl reload nginx
ynh_systemd_action -l "INFO in server: Starting Gevent server" ynh_systemd_action -l "INFO in server: Starting Gevent server"
#=================================================
# WARNING FOR READ ACCESS
#=================================================
ynh_print_warn "Please, give required access to $app user to the $calibre_dir folder."