diff --git a/README.md b/README.md index 4032202..43515cd 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Kresus is an open-source libre self-hosted personal finance manager. It allows you to safely track your banking history, check your overall balance and know exactly how you are spending money using categories! -**Shipped version:** 0.18.1~ynh6 +**Shipped version:** 0.18.1~ynh7 *(:warning: This is the `upgrade` branch. The [`master` branch](https://github.com/YunoHost-Apps/kresus_ynh/tree/master) used in the catalog is currently on version 0.18.1\~ynh6.)* ## Screenshots diff --git a/README_fr.md b/README_fr.md index 206ed26..8378148 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Kresus est un gestionnaire de finances personnelles gratuit et libre qui tourne sur votre serveur. Il récupère automatiquement et quotidiennement toutes vos nouvelles transactions bancaires et vous permet de les catégoriser, étudier via des graphiques, et établir un budget. -**Version incluse :** 0.18.1~ynh6 +**Version incluse :** 0.18.1~ynh7 *(:warning: Il s'agit de la branche `upgrade`. La [branche `master`](https://github.com/YunoHost-Apps/kresus_ynh/tree/master) utilisée dans le catalogue est actuellement en 0.18.1\~ynh6.)* ## Captures d'écran diff --git a/check_process b/check_process index 90cf11b..17ae5b8 100644 --- a/check_process +++ b/check_process @@ -12,10 +12,12 @@ upgrade=1 # 0.16.0~ynh4 upgrade=1 from_commit=bd7259e916130f933f6ecdc8d6362e1fa7164d8f + # 0.18.1~ynh6 + upgrade=1 from_commit=c5d4c9a728365771f5536bdac3830b86d75d895a backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email= -Notification=all +Notification=none diff --git a/conf/config.ini b/conf/config.ini index cb1f93a..570a1ff 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -4,13 +4,13 @@ ; [kresus] -; This is where Kresus stores additional data, as the latest bank scrapping -; modules. It should be writeable by the user which launches the Kresus -; executable. +; This is where Kresus stores additional data, as the latest bank +; scrapping modules. It should be writeable by the user which launches +; the Kresus executable. ; Can be removed; defaults to HOME_DIR/.kresus. -; Overridden by the KRESUS_DIR environment variable, if it's set. +; Overriden by the KRESUS_DIR environment variable, if it's set. ; Example: -; dataDir=/home/ben/.kresus +; datadir=/home/ben/.kresus datadir=__FINALPATH__/data/ ; A user id obtained from using the "kresus create-user" command. @@ -39,10 +39,10 @@ port=__PORT__ ; host=127.0.0.1 host=127.0.0.1 -; The executable version of Python that is going to get used when interacting -; with Python scripts. This can be python, python2 or python3. -; Can be removed; defaults to "python2". -; Overridden by the KRESUS_PYTHON_EXEC environment variable, if it's set. +; The executable version of Python that is going to get used when +; interacting with Python scripts. This can be python or python3. +; Can be removed; defaults to python3. +; Overriden by the KRESUS_PYTHON_EXEC environment variable, if it's set. ; Example: ; python_exec=python3 python_exec=__FINALPATH__/venv/bin/python @@ -73,7 +73,7 @@ salt=__SALT__ ; is still possible to try Kresus in demo mode, even if this is not set ; to true. Setting this to true will *force* demo mode, and prevent users ; from leaving this mode. -; Can be removed; defaults to "false". +; Can be removed; defaults to false. ; Overriden by the KRESUS_FORCE_DEMO_MODE environment variable, if it's set. ; Example: ; force_demo_mode=true @@ -120,11 +120,11 @@ sources_list= ; transport=smtp transport=sendmail -; The path to the sendmail executable to use. -; Can be removed; defaults to "", which means defaults to "sendmail" -; executable. -; Overridden by the KRESUS_EMAIL_SENDMAIL_BIN environment variable, if it's -; set. +; The path to the sendmail executable to use. If empty, indicates +; that the default sendmail executable will be used. +; Overriden by the KRESUS_EMAIL_SENDMAIL_BIN environment variable, if it's set. +; Example: +; sendmail_bin=/usr/bin/sendmail sendmail_bin= ; The email address from which email alerts will be sent. Make sure @@ -217,7 +217,7 @@ type=postgres ; - all: will log every SQL query, including queries causing errors. ; - error (default value): will only log SQL queries resulting in errors. This is useful for debugging purposes. ; - none: nothing will be logged. -; Can be removed; defaults to "error". +; Can be removed; defaults to error. ; Overriden by the KRESUS_DB_LOG environment variable, if it's set. ; Example: ; log=error @@ -263,8 +263,9 @@ username=__DB_USER__ password=__DB_PWD__ ; Database name to use. Required for postgres. -; Can be removed; defaults to "kresus". +; Can be removed; defaults to kresus. ; Overriden by the KRESUS_DB_NAME environment variable, if it's set. ; Example: ; name=kresus name=__DB_NAME__ + diff --git a/manifest.json b/manifest.json index 9bd89a9..f328fdb 100644 --- a/manifest.json +++ b/manifest.json @@ -6,10 +6,10 @@ "en": "Personal finance manager", "fr": "Outil personnel de gestion de finances" }, - "version": "0.18.1~ynh6", + "version": "0.18.1~ynh7", "url": "https://framagit.org/kresusapp/kresus", "upstream": { - "license": "free", + "license": "AGPL-3.0-only", "website": "https://framagit.org/kresusapp/kresus", "admindoc": "https://kresus.org/en/doc.html", "code": "https://framagit.org/kresusapp/kresus" diff --git a/scripts/_common.sh b/scripts/_common.sh index b3c3f86..413e868 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,10 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="build-essential dh-autoreconf python3-pip python3-dev python3-lxml python3-pillow virtualenv postgresql libffi-dev libopenjp2-7" +# dependencies used by the app (must be on a single line) +pkg_dependencies="locales git python3 python3-dev python3-pip python3-selenium libffi-dev libxml2-dev libxslt-dev libyaml-dev libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev libwebp-dev build-essential gcc g++ wget unzip mupdf-tools libnss3-tools python3-nss virtualenv postgresql" -nodejs_version=14 +nodejs_version=16 #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..e1b881d --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,145 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +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=$app --key=final_path) + +# Add settings here as needed by your application +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +port=$(ynh_app_setting_get --app=$app --key=port) +salt=$(ynh_app_setting_get --app=$app --key=salt) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# 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 WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" + +#================================================= +# 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 + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +domain=$new_domain +path=$new_path +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" + +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +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 7e5b528..65b67cd 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -25,7 +25,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -architecture=$YNH_ARCH app=$YNH_APP_INSTANCE_NAME @@ -34,10 +33,10 @@ salt=$(ynh_string_random --length=40) #================================================= # 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=1 # Check machine architecture (in particular, we don't support ARM and 32bit machines) -if [ $architecture == "i386" ]; +if [ $YNH_ARCH == "i386" ]; then ynh_die --message="Sorry, because of nodejs framework, this app can't be installed on i386 (32 bits) machine." fi @@ -51,7 +50,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -62,7 +61,7 @@ ynh_app_setting_set --app=$app --key=salt --value=$salt #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." +ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port port=$(ynh_find_port --port=9876) @@ -71,15 +70,16 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" @@ -87,7 +87,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -99,7 +99,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -114,7 +114,7 @@ chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -124,35 +124,46 @@ ynh_add_nginx_config #================================================= # INSTALL WOOB WITH PIP #================================================= -ynh_script_progression --message="Installing woob..." +ynh_script_progression --message="Installing woob..." --weight=1 -virtualenv --python=python3 --system-site-packages "${final_path}/venv" +locale-gen C.UTF-8 +update-locale C.UTF-8 +ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${final_path}/venv" ( set +o nounset source "${final_path}/venv/bin/activate" set -o nounset - pip install --upgrade pip - pip install woob html2text simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six --ignore-installed + ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' + export PATH="$final_path/.cargo/bin:$PATH" + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed + ynh_secure_remove --file="$final_path/.cargo" + ynh_secure_remove --file="$final_path/.rustup" + ynh_secure_remove --file="$final_path/.cache" + ynh_secure_remove --file="$final_path/.local" ) -chown -R $app:www-data "$final_path" #================================================= -# INTSALL KRESUS WITH NPM +# INSTALL KRESUS WITH NPM #================================================= -ynh_script_progression --message="Installing app..." +ynh_script_progression --message="Installing app..." --weight=1 ynh_use_nodejs ( cd "$final_path" - ynh_exec_warn_less $ynh_npm install --production --unsafe-perm + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn build:prod + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all + ynh_secure_remove --file="$final_path/.cache" + ynh_secure_remove --file="$final_path/.yarn" ) -chown -R $app:www-data "$final_path" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" @@ -162,7 +173,7 @@ chown $app:$app "$final_path/config.ini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -172,7 +183,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=1 mkdir -p "/var/log/$app/" touch "/var/log/$app/$app.log" @@ -183,14 +194,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" @@ -198,13 +209,14 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND README TO ADMIN #================================================= +ynh_script_progression --message="Sending ReadMe to admin..." --weight=1 message=" Domain: $domain @@ -226,4 +238,4 @@ ynh_send_readme_to_admin "$message" # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 62bcce7..574f696 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,14 +31,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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 integration..." + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -46,7 +46,7 @@ ynh_remove_systemd_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -54,7 +54,7 @@ ynh_remove_logrotate #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -62,7 +62,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -70,7 +70,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -78,7 +78,7 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_nodejs @@ -89,7 +89,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression --message="Removing various files..." --weight=1 # Remove the log files ynh_secure_remove --file="/var/log/$app" @@ -99,7 +99,7 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app @@ -108,4 +108,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index ff44581..a791b42 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -37,11 +37,11 @@ salt=$(ynh_app_setting_get --app=$app --key=salt) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 architecture=$YNH_ARCH # Check machine architecture (in particular, we don't support ARM and 32bit machines) -if [ $architecture == "i386" ] +if [ $YNH_ARCH == "i386" ] then ynh_die --message="Sorry, because of nodejs framework, this app can't be installed on i386 (32 bits) machine." fi @@ -54,7 +54,7 @@ test ! -d $final_path \ #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -62,7 +62,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" @@ -78,23 +78,24 @@ chown $app:$app "$final_path/config.ini" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 ynh_psql_test_if_first_run db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) @@ -104,7 +105,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -112,7 +113,7 @@ systemctl enable $app.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 mkdir -p "/var/log/$app/" touch "/var/log/$app/$app.log" @@ -122,14 +123,14 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" @@ -138,7 +139,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -146,4 +147,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 867e097..d2ba0fa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -28,19 +28,18 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # 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 } @@ -52,14 +51,14 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Previous versions did not set the DB name as a setting, so we need to set it now (will be used on # remove). @@ -89,10 +88,12 @@ then ynh_app_setting_set "$app" salt "$salt" fi +usermod -d $final_path $app + #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -103,19 +104,19 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 - # Remove previous build files to ensure there is no conflict (obsolete helpers.js file - # called instead of helpers/index.js for ex.) - ynh_secure_remove --file="$final_path/build" + tmpdir="$(mktemp -d)" + cp "$final_path/config.ini" "$tmpdir/config.ini" + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" - if [ -z "$final_path/data" ] - then - mkdir "$final_path/data" - fi + cp "$tmpdir/config.ini" "$final_path/config.ini" + ynh_secure_remove --file="$tmpdir" + + mkdir -p "$final_path/data" fi chmod 750 "$final_path" @@ -125,10 +126,11 @@ chown -R $app:www-data "$final_path" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" # Now that postgresql is installed, check the db exists and the user is set up if [ -z "$db_pwd" ] @@ -142,7 +144,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -152,24 +154,32 @@ ynh_add_nginx_config #================================================= # INSTALL WOOB WITH PIP #================================================= -ynh_script_progression --message="Installing woob..." +ynh_script_progression --message="Installing woob..." --weight=1 +locale-gen C.UTF-8 +update-locale C.UTF-8 ynh_secure_remove --file="${final_path}/venv" -virtualenv --python=python3 --system-site-packages "${final_path}/venv" +ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${final_path}/venv" ( set +o nounset source "${final_path}/venv/bin/activate" set -o nounset - pip install --upgrade pip - pip install woob html2text simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six --ignore-installed + ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' + export PATH="$final_path/.cargo/bin:$PATH" + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed + ynh_secure_remove --file="$final_path/.cargo" + ynh_secure_remove --file="$final_path/.rustup" + ynh_secure_remove --file="$final_path/.cache" + ynh_secure_remove --file="$final_path/.local" ) -chown -R $app:www-data "$final_path" #================================================= # INSTALL KRESUS WITH NPM #================================================= -ynh_script_progression --message="Installing app..." +ynh_script_progression --message="Installing app..." --weight=1 ynh_use_nodejs ( @@ -179,14 +189,17 @@ ynh_use_nodejs # linked to modules compiled for the previous version. ynh_secure_remove --file="$final_path/node_modules" - ynh_exec_warn_less $ynh_npm install --production --unsafe-perm + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn build:prod + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all + ynh_secure_remove --file="$final_path/.cache" + ynh_secure_remove --file="$final_path/.yarn" ) -chown -R $app:www-data "$final_path" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" @@ -196,7 +209,7 @@ chown $app:$app "$final_path/config.ini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -206,7 +219,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 mkdir -p "/var/log/$app/" touch "/var/log/$app/$app.log" @@ -217,27 +230,28 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND README TO ADMIN #================================================= +ynh_script_progression --message="Sending ReadMe to admin..." --weight=1 message=" Kresus was successfully updated! @@ -258,4 +272,4 @@ ynh_send_readme_to_admin "$message" # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --last