diff --git a/ct/alpine-node-red.sh b/ct/alpine-node-red.sh new file mode 100644 index 000000000..c9afc6888 --- /dev/null +++ b/ct/alpine-node-red.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://nodered.org + +APP="Alpine-Node-RED" +var_tags="${var_tags:-alpine;automation}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-256}" +var_disk="${var_disk:-1}" +var_os="${var_os:-alpine}" +var_version="${var_version:-3.21}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + msg_info "Updating Alpine Packages" + $STD apk update + $STD apk upgrade + msg_ok "Updated Alpine Packages" + + msg_info "Updating Node.js and npm" + $STD apk upgrade nodejs npm + msg_ok "Updated Node.js and npm" + + msg_info "Updating Node-RED" + $STD npm install -g --unsafe-perm node-red + msg_ok "Updated Node-RED" + + msg_info "Restarting Node-RED" + $STD rc-service nodered restart + msg_ok "Restarted Node-RED" + + exit 0 +} + +start +build_container +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}:1880${CL}" diff --git a/frontend/public/json/node-red.json b/frontend/public/json/node-red.json index 0755b5b15..12ac9ce75 100644 --- a/frontend/public/json/node-red.json +++ b/frontend/public/json/node-red.json @@ -24,6 +24,17 @@ "os": "debian", "version": "12" } + }, + { + "type": "alpine", + "script": "ct/alpine-node-red.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 1, + "os": "alpine", + "version": "3.21" + } } ], "default_credentials": { @@ -32,8 +43,8 @@ }, "notes": [ { - "text": "To install themes, type `update` in the LXC console.", + "text": "To install themes, type `update` in the LXC console. (debian/ubuntu only)", "type": "info" } ] -} \ No newline at end of file +} diff --git a/install/alpine-node-red-install.sh b/install/alpine-node-red-install.sh new file mode 100644 index 000000000..436a6ed08 --- /dev/null +++ b/install/alpine-node-red-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://nodered.org/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add --no-cache \ + gpg \ + git \ + nodejs \ + npm +msg_ok "Installed Dependencies" + +msg_info "Creating Node-RED User" +adduser -D -H -s /sbin/nologin -G users nodered +msg_ok "Created Node-RED User" + +msg_info "Installing Node-RED" +npm install -g --unsafe-perm node-red +msg_ok "Installed Node-RED" + +msg_info "Creating Node-RED Service" +service_path="/etc/init.d/nodered" + +echo '#!/sbin/openrc-run +description="Node-RED Service" + +command="/usr/bin/node-red" +command_args="--max-old-space-size=128 -v" +command_user="nodered" +pidfile="/var/run/nodered.pid" + +depend() { + use net +}' >$service_path + +chmod +x $service_path +$STD rc-update add nodered default +msg_ok "Created Node-RED Service" + +msg_info "Starting Node-RED" +$STD service nodered start +msg_ok "Started Node-RED" + +motd_ssh +customize