diff --git a/check_process b/check_process index 531867d..b991b3d 100644 --- a/check_process +++ b/check_process @@ -15,12 +15,10 @@ setup_root=1 setup_private=1 setup_public=1 - upgrade=1 from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341 - upgrade=1 from_commit=03bafd5219544c5d317eaf54182e4122ba63a4ad - upgrade_1 from_commit=9e5fa45df7cd840d8a26d25f953857a13d6bc5de + upgrade=1 + upgrade=1 from_commit=11f5b96df7d8850beff47f9904745fa53a6f7ed9 backup_restore=1 multi_instance=1 - incorrect_path=1 port_already_use=1 (8083) change_url=1 #;; Failed upgrade @@ -41,23 +39,11 @@ # setup_root=1 # upgrade=1 from_commit=3b9c5041e4fa73cb965368379f2b83d076c65341 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options -Email= +Email=nicolas@aubonalbanais.ovh Notification=none ;;; Upgrade options - ; commit=3b9c5041e4fa73cb965368379f2b83d076c65341 - name=First in progress release of the app 0.9~ynh1 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& - ; commit=03bafd5219544c5d317eaf54182e4122ba63a4ad - name=Release 0.91~ynh2 + ; commit=11f5b96df7d8850beff47f9904745fa53a6f7ed9 + name=Version 0.96.0~ynh4 manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& \ No newline at end of file diff --git a/conf/app066.src b/conf/app066.src new file mode 100644 index 0000000..f3f4ee7 --- /dev/null +++ b/conf/app066.src @@ -0,0 +1,3 @@ +SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0.6.6.zip +SOURCE_SUM=87633c2817263ed2d12fce67ea292b1c6d042aa949aafb728789c15d495415cc +SOURCE_FORMAT=zip diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index 24690a0..bdbb5cf 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -1,13 +1,5 @@ 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_logfile=\'$LOG_FILE\', config_access_log=1, config_access_logfile=\'$ACCESS_LOG_FILE\', diff --git a/manifest.json b/manifest.json index f8c7a2a..96d001e 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,7 @@ "license": "free", "maintainer": { "name": "Krakinou", - "email": "misterl56@hotmail.com" + "email": "nicolas@aubonalbanais.ovh" }, "requirements": { "yunohost": ">= 3.7.1" @@ -66,6 +66,7 @@ { "name": "language", "optional": true, + "type": "string", "ask": { "en": "Select a default language", "fr": "Choisissez une langue par défaut" diff --git a/scripts/_common.sh b/scripts/_common.sh index 9946035..c694803 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,11 @@ get_db() { 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 } +version_gt() { + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; +} + + #================================================= # EXPERIMENTAL HELPERS # TO BE DELETED WHEN RELEASED diff --git a/scripts/_settings.sh b/scripts/_settings.sh index ef9f822..9baa230 100644 --- a/scripts/_settings.sh +++ b/scripts/_settings.sh @@ -1,6 +1,6 @@ #!/bin/bash -PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick" +PKG_DEPENDENCIES="sqlite3 python-dev libldap2-dev python3-pip imagemagick" DOSSIER_MEDIA=/home/yunohost.multimedia LOG_FILE=/var/log/$app/$app.log ACCESS_LOG_FILE=/var/log/$app/$app-access.log \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 6637d1b..4f57ae1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -81,7 +81,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= ynh_script_progression --message="Backing up data directory..." -ynh_backup --src_path="/home/yunohost.app/${app}/data" --is_big +ynh_backup --src_path="$calibre_dir" --is_big #================================================= diff --git a/scripts/change_url b/scripts/change_url index 369c1b6..dd12d60 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -22,11 +22,27 @@ 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) +#================================================= +# 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 () { + # 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 +71,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 +111,23 @@ 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=1 + +ynh_systemd_action --service_name=$app --action="start" +#================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index ce58bbe..7c6a969 100755 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ source _settings.sh #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +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" @@ -54,7 +54,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=5 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -90,10 +90,10 @@ ynh_setup_source "$final_path" ynh_script_progression --message="Installing package dependencies..." --weight=15 ynh_install_app_dependencies $PKG_DEPENDENCIES -ynh_script_progression --message="Installing pip requirements ..." --weight=30 +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=40 +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 #================================================= @@ -129,7 +129,7 @@ ynh_add_systemd_config #================================================= # CREATE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="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. @@ -169,7 +169,7 @@ chown -R $app:$app /var/log/$app #================================================= # SET SQLITE DATABASE SETTINGS #================================================= -ynh_script_progression --message="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 @@ -227,11 +227,11 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload nginx and start $app..." +ynh_script_progression --message="Reload nginx and start $app..." --weight=5 -t ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" --last -t diff --git a/scripts/remove b/scripts/remove index 0b84378..68341c0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=3 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) @@ -27,7 +27,7 @@ calibre_dir=$(ynh_app_setting_get $app calibre_dir) # 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 - ynh_script_progression --message="Removing $app service..." --time --weight=1 + ynh_script_progression --message="Removing $app service..." --weight=1 yunohost service remove $app fi @@ -38,7 +38,7 @@ fi #================================================= # Remove the dedicated systemd config -ynh_script_progression --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 ynh_remove_systemd_config @@ -48,7 +48,7 @@ ynh_remove_systemd_config #================================================= # Remove metapackage and its dependencies -ynh_script_progression --message="Removing Dependencies..." +ynh_script_progression --message="Removing Dependencies..." --weight=5 ynh_remove_app_dependencies @@ -57,7 +57,7 @@ ynh_remove_app_dependencies #================================================= # Remove the app directory securely -ynh_script_progression --message="Removing $final_path..." +ynh_script_progression --message="Removing $final_path..." --weight=1 ynh_secure_remove --file="$final_path" #================================================= @@ -65,7 +65,7 @@ ynh_secure_remove --file="$final_path" #================================================= # Remove the dedicated nginx config -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 ynh_remove_nginx_config #================================================= @@ -73,7 +73,7 @@ ynh_remove_nginx_config #================================================= # Remove the app-specific logrotate config -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_remove_logrotate #================================================= @@ -82,16 +82,12 @@ ynh_remove_logrotate if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." + ynh_script_progression --message="Closing port $port..." --weight=10 yunohost firewall disallow TCP $port 2>&1 fi -#================================================= -# SPECIFIC REMOVE -#================================================= -ynh_script_progression --message="Removing log and user $app..." - # Remove the log files +ynh_script_progression --message="Removing log file..." --weight=1 ynh_secure_remove "/var/log/$app/" #================================================= @@ -99,8 +95,8 @@ ynh_secure_remove "/var/log/$app/" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 ynh_system_user_delete --username=$app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b8ee15b..6219aab 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) @@ -37,10 +37,24 @@ source _settings.sh #================================================= 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)..." --time --weight=1 +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 () { @@ -51,7 +65,7 @@ ynh_clean_setup () { ynh_abort_if_errors #Stop the app in case database is updated -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=2 ynh_systemd_action --service_name=$app --action="stop" @@ -68,12 +82,24 @@ 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" +#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 + #sleep required on low spec like raspberryPi + sleep 5s + ynh_systemd_action -a 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..." --time --weight=1 - + 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 @@ -81,26 +107,29 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 + +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_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 --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 additionnal requirements..." --weight=40 -pip3 install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/optional-requirements.txt + 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 #================================================= @@ -130,13 +159,13 @@ ynh_script_progression --message="Update database..." --time --weight=1 ### 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 +#set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap & log settings ynh_systemd_action #sleep required on low spec like raspberryPi sleep 5s ynh_systemd_action -a 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. @@ -150,6 +179,7 @@ ynh_store_file_checksum "$final_path/app.db" ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 ynh_use_logrotate --non-append + #================================================= # SETUP SYSTEMD #================================================= @@ -204,3 +234,4 @@ ynh_systemd_action --service_name=$app --action="start" #================================================= ynh_script_progression --message="Upgrade of $app completed" --time --last +