From 759239bc7cf0fb426e0704c1b771122b29bf5b69 Mon Sep 17 00:00:00 2001 From: Tobias <96661824+CrazyWolf13@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:33:51 +0200 Subject: [PATCH] n8n: refactor environmentfile (#6297) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * n8n: add config path * n8n: refactor servicefile to seperate env * n8n: refactor envfile * Update n8n.sh * Update n8n.json --------- Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com> --- ct/n8n.sh | 14 +++++++++++++- frontend/public/json/n8n.json | 9 +++++++-- install/n8n-install.sh | 13 +++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ct/n8n.sh b/ct/n8n.sh index bd542d17e..c23b4a79c 100644 --- a/ct/n8n.sh +++ b/ct/n8n.sh @@ -34,6 +34,18 @@ function update_script() { echo "Installed NPM..." fi fi + if [ ! -f /opt/n8n.env ]; then + sed -i 's|^Environment="N8N_SECURE_COOKIE=false"$|EnvironmentFile="/opt/n8n.env"|' /etc/systemd/system/n8n.service + HOST_IP=$(hostname -I | awk '{print $1}') + mkdir -p /opt + cat </opt/n8n.env +N8N_SECURE_COOKIE=false +N8N_PORT=5678 +N8N_PROTOCOL=http +N8N_HOST=$HOST_IP +EOF + fi + msg_info "Updating ${APP} LXC" $STD npm update -g n8n systemctl restart n8n @@ -48,4 +60,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5678${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5678${CL}" diff --git a/frontend/public/json/n8n.json b/frontend/public/json/n8n.json index 7ab0ed00b..3dbff38c0 100644 --- a/frontend/public/json/n8n.json +++ b/frontend/public/json/n8n.json @@ -12,7 +12,7 @@ "documentation": "https://docs.n8n.io/", "website": "https://n8n.io/", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/n8n.webp", - "config_path": "", + "config_path": "/opt/n8n.env", "description": "n8n is a workflow automation tool that enables users to automate various tasks and processes by connecting various data sources, systems, and services. It provides a visual interface for building workflows, allowing users to easily define and automate complex sequences of actions, such as data processing, conditional branching, and API calls. n8n supports a wide range of integrations, making it a versatile tool for automating a variety of use cases, from simple data processing workflows to complex business processes. With its extendable architecture, n8n is designed to be easily customizable and can be adapted to meet the specific needs of different users and industries.", "install_methods": [ { @@ -31,5 +31,10 @@ "username": null, "password": null }, - "notes": [] + "notes": [ + { + "text": "You may need to configure the `WEBHOOK_URL` in the config file when using a domain.", + "type": "info" + } + ] } diff --git a/install/n8n-install.sh b/install/n8n-install.sh index 7496a8595..3d83f1928 100644 --- a/install/n8n-install.sh +++ b/install/n8n-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) +# Author: tteck (tteckster) | Co-Author: CrazyWolf13 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://n8n.io/ @@ -26,13 +26,22 @@ $STD npm install --global n8n msg_ok "Installed n8n" msg_info "Creating Service" +HOST_IP=$(hostname -I | awk '{print $1}') +mkdir -p /opt +cat </opt/n8n.env +N8N_SECURE_COOKIE=false +N8N_PORT=5678 +N8N_PROTOCOL=http +N8N_HOST=$HOST_IP +EOF + cat </etc/systemd/system/n8n.service [Unit] Description=n8n [Service] Type=simple -Environment="N8N_SECURE_COOKIE=false" +EnvironmentFile="/opt/n8n.env" ExecStart=n8n start [Install] WantedBy=multi-user.target