1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodered_ynh.git synced 2024-09-03 19:46:25 +02:00

[fix] Implement upgrade and fix node_js handling

This commit is contained in:
tituspijean 2019-10-13 10:30:35 +00:00
parent 69ab6f05e8
commit 567fc94358
3 changed files with 24 additions and 16 deletions

View file

@ -7,7 +7,6 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
ExecStartPre=__NODEJS__
Environment="PATH=__ENV_PATH__"
ExecStart=__FINALPATH__/bin/node-red-pi -p __PORT__ -u __FINALPATH__/data >> /var/log/__APP__/__APP__.log 2>&1

View file

@ -151,15 +151,14 @@ mkdir -p $final_path/data
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
# Set the systemd service settings
ynh_replace_string "__PORT__" "$port" "../conf/systemd.service"
ynh_replace_string "__NODEJS__" "$nodejs_version" "../conf/systemd.service"
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
# Set the systemd service settings
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
ynh_replace_string "__NODEJS__" "$nodejs_use_version" "/etc/systemd/system/$app.service"
ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service"
systemctl daemon-reload
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -19,6 +19,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
@ -105,6 +108,16 @@ then
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# Install through npm
#=================================================
ynh_script_progression --message="Installing node-red..." --time --weight=2
pushd $final_path
ynh_use_nodejs
npm install --production -g
popd
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -148,25 +161,22 @@ ynh_use_logrotate --non-append
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
# Set the systemd service settings
ynh_replace_string "__PORT__" "$port" "../conf/systemd.service"
ynh_replace_string "__NODEJS__" "$nodejs_version" "../conf/systemd.service"
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1
# Create a dedicated fail2ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT