1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodered_ynh.git synced 2024-09-03 19:46:25 +02:00
This commit is contained in:
Éric Gaspar 2023-10-18 15:40:30 +02:00
parent 0364348fd4
commit 5d1e34d35a
5 changed files with 44 additions and 61 deletions

View file

@ -5,7 +5,7 @@ name = "Node-RED"
description.en = "Flow-based programming for the Internet of Things" description.en = "Flow-based programming for the Internet of Things"
description.fr = "Programmation par flux de données pour l'Internet des objets" 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"] maintainers = ["tituspijean"]
@ -42,8 +42,9 @@ ram.runtime = "50M"
[resources] [resources]
[resources.sources.main] [resources.sources.main]
url = "https://github.com/node-red/node-red/releases/download/3.0.2/node-red-3.0.2.zip" url = "https://github.com/node-red/node-red/archive/refs/tags/3.1.0.tar.gz"
sha256 = "6c452646648f9e86622148eff2208fb45d2311b5339481f86b445e9e2fa215c5" sha256 = "dfb69f620085b4b84226bd1e270de3ad20597c985232fb723132929176c0baeb"
autoupdate.strategy = "latest_github_tag"
[resources.system_user] [resources.system_user]

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..."
ynh_install_nodejs --nodejs_version=$nodejs_version 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" 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 # Create a dedicated NGINX config
ynh_add_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 # SPECIFIC SETUP
#================================================= #=================================================
@ -39,10 +49,8 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Installing $app..." --weight=5 ynh_script_progression --message="Installing $app..." --weight=5
ynh_use_nodejs
chown -R $app: "$install_dir"
pushd $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 --production
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install node-red-dashboard ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install node-red-dashboard
popd popd
@ -52,36 +60,19 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." 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" 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" 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 # Small hack to have the "/" path answer with a 200 code to satisfy the CI
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json" ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json"
fi 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 # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -10,10 +10,11 @@ source _common.sh
source /usr/share/yunohost/helpers 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`) # 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 if ynh_exec_warn_less yunohost service status $app >/dev/null

View file

@ -17,19 +17,18 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir" chown -R $app:www-data "$data_dir"
chown -R $app: "$install_dir"
# Create log directory and apply permissions # Create log directory and apply permissions
mkdir -p /var/log/$app mkdir -p /var/log/$app
chown -R $app: /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 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" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet 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" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"

View file

@ -65,6 +65,11 @@ ynh_add_nginx_config
ynh_install_nodejs --nodejs_version=$nodejs_version 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 # Install through npm
#================================================= #=================================================
@ -83,8 +88,13 @@ ynh_script_progression --message="Updating a configuration file..."
# Set up the settings file # Set up the settings file
ynh_add_config --template="../conf/settings.js" --destination="$install_dir/data/settings.js" 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 if [[ ! -f "$install_dir/data/settings.user.js" ]] ; then
ynh_add_config --template="../conf/settings.user.js" --destination="$install_dir/data/settings.user.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"
fi fi
# Small hack to have the "/" path answer with a 200 code to satisfy the CI # 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" ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json"
fi 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 # START SYSTEMD SERVICE
#================================================= #=================================================