From 5d1e34d35ada65e4355de2b1c6d7005728d1b38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:40:30 +0200 Subject: [PATCH] cleaning --- manifest.toml | 7 ++++--- scripts/install | 45 ++++++++++++++++++--------------------------- scripts/remove | 5 +++-- scripts/restore | 17 +++++++++-------- scripts/upgrade | 31 ++++++++++--------------------- 5 files changed, 44 insertions(+), 61 deletions(-) diff --git a/manifest.toml b/manifest.toml index 0a77046..b291ab3 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Node-RED" description.en = "Flow-based programming for the Internet of Things" description.fr = "Programmation par flux de données pour l'Internet des objets" -version = "3.0.2~ynh3" +version = "3.1.0~ynh1" maintainers = ["tituspijean"] @@ -42,8 +42,9 @@ ram.runtime = "50M" [resources] [resources.sources.main] - url = "https://github.com/node-red/node-red/releases/download/3.0.2/node-red-3.0.2.zip" - sha256 = "6c452646648f9e86622148eff2208fb45d2311b5339481f86b445e9e2fa215c5" + url = "https://github.com/node-red/node-red/archive/refs/tags/3.1.0.tar.gz" + sha256 = "dfb69f620085b4b84226bd1e270de3ad20597c985232fb723132929176c0baeb" + autoupdate.strategy = "latest_github_tag" [resources.system_user] diff --git a/scripts/install b/scripts/install index 1828be5..b1e86ab 100755 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$nodejs_version @@ -23,15 +23,25 @@ ynh_script_progression --message="Setting up source files..." --weight=2 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" +# Set up the settings file +mkdir -p $install_dir/data + +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Low-code programming for event-driven applications" --log="/var/log/$app/$app.log" + #================================================= # SPECIFIC SETUP #================================================= @@ -39,10 +49,8 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Installing $app..." --weight=5 -ynh_use_nodejs -chown -R $app: "$install_dir" - pushd $install_dir + ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --production ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install node-red-dashboard popd @@ -52,36 +60,19 @@ popd #================================================= ynh_script_progression --message="Adding a configuration file..." -# Set up the settings file -mkdir -p $install_dir/data ynh_add_config --template="../conf/settings.js" --destination="$install_dir/data/settings.js" -chmod a-w "$install_dir/data/settings.js" +chmod 400 "$install_dir/data/settings.js" +chown $app:$app "$install_dir/data/settings.js" ynh_add_config --template="../conf/settings.user.js" --destination="$install_dir/data/settings.user.js" +chmod 400 "$install_dir/data/settings.user.js" +chown $app:$app "$install_dir/data/settings.user.js" # Small hack to have the "/" path answer with a 200 code to satisfy the CI if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json" fi -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - -yunohost service add $app --description="Low-code programming for event-driven applications" - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index f0f8ad7..802320b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,10 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 diff --git a/scripts/restore b/scripts/restore index 4834f9c..ea281cc 100755 --- a/scripts/restore +++ b/scripts/restore @@ -17,19 +17,18 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" +chown -R $app:www-data "$data_dir" # Create log directory and apply permissions mkdir -p /var/log/$app chown -R $app: /var/log/$app #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_install_nodejs --nodejs_version=$nodejs_version @@ -38,12 +37,14 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -yunohost service add $app --description="Low-code programming for event-driven applications" +yunohost service add $app --description="Low-code programming for event-driven applications" --log="/var/log/$app/$app.log" #================================================= -# START SYSTEMD SERVICE +# GENERIC FINALIZATION #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +#================================================= +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" diff --git a/scripts/upgrade b/scripts/upgrade index af585ef..7c56c94 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,6 +65,11 @@ ynh_add_nginx_config ynh_install_nodejs --nodejs_version=$nodejs_version +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Low-code programming for event-driven applications" --log="/var/log/$app/$app.log" + #================================================= # Install through npm #================================================= @@ -83,8 +88,13 @@ ynh_script_progression --message="Updating a configuration file..." # Set up the settings file ynh_add_config --template="../conf/settings.js" --destination="$install_dir/data/settings.js" +chmod 400 "$install_dir/data/settings.js" +chown $app:$app "$install_dir/data/settings.js" + if [[ ! -f "$install_dir/data/settings.user.js" ]] ; then ynh_add_config --template="../conf/settings.user.js" --destination="$install_dir/data/settings.user.js" + chmod 400 "$install_dir/data/settings.user.js" + chown $app:$app "$install_dir/data/settings.user.js" fi # Small hack to have the "/" path answer with a 200 code to satisfy the CI @@ -92,27 +102,6 @@ if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json" fi -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - -yunohost service add $app --description="Low-code programming for event-driven applications" - -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" -# make settings.js readonly -chmod a-w "$install_dir/data/settings.js" - #================================================= # START SYSTEMD SERVICE #=================================================