From a5f77f23e9d0d80e9295c6f8332f0c68098ced1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:10:24 +0100 Subject: [PATCH] New Script: TasmoCompiler (#2235) * add tasmocompiler script * bunch of script fixes * remove typo * Update json/tasmocompiler.json Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> * Update ct/tasmocompiler.sh Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> * Update json/tasmocompiler.json Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> * Update ct/tasmocompiler.sh Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> --------- Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> --- ct/tasmocompiler.sh | 71 ++++++++++++++++++++++++++ install/tasmocompiler-install.sh | 87 ++++++++++++++++++++++++++++++++ json/tasmocompiler.json | 34 +++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 ct/tasmocompiler.sh create mode 100644 install/tasmocompiler-install.sh create mode 100644 json/tasmocompiler.json diff --git a/ct/tasmocompiler.sh b/ct/tasmocompiler.sh new file mode 100644 index 000000000..2917227a9 --- /dev/null +++ b/ct/tasmocompiler.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/benzino77/tasmocompiler + +APP="TasmoCompiler" +TAGS="compiler" +var_cpu="2" +var_ram="2048" +var_disk="10" +var_os="debian" +var_version="12" +var_unprivileged="1" + +header_info "$APP" +base_settings + +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/tasmocompiler ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/benzino77/tasmocompiler/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping $APP" + systemctl stop tasmocompiler + msg_ok "Stopped $APP" + msg_info "Updating $APP to v${RELEASE}" + cd /opt + rm -rf /opt/tasmocompiler + RELEASE=$(curl -s https://api.github.com/repos/benzino77/tasmocompiler/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + wget -q https://github.com/benzino77/tasmocompiler/archive/refs/tags/v${RELEASE}.tar.gz + tar xzf v${RELEASE}.tar.gz + mv tasmocompiler-${RELEASE}/ /opt/tasmocompiler/ + cd /opt/tasmocompiler + yarn install &> /dev/null + export NODE_OPTIONS=--openssl-legacy-provider + npm i &> /dev/null + yarn build &> /dev/null + msg_ok "Updated $APP to v${RELEASE}" + msg_info "Starting $APP" + systemctl start tasmocompiler + msg_ok "Started $APP" + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_info "Cleaning up" + rm -r "/opt/v${RELEASE}.tar.gz" + msg_ok "Cleaned" + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit +} + +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}:3000${CL}" diff --git a/install/tasmocompiler-install.sh b/install/tasmocompiler-install.sh new file mode 100644 index 000000000..452d56e8a --- /dev/null +++ b/install/tasmocompiler-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/benzino77/tasmocompiler + +# Import Functions und Setup +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies. Patience" +$STD apt-get install -y \ + curl \ + sudo \ + mc \ + gnupg \ + git +msg_ok "Installed Dependencies" + +msg_info "Setup Python3" +$STD apt-get install python3-venv +msg_ok "Setup Python3" + +msg_info "Setup Node.js & yarn" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g yarn +msg_ok "Setup Node.js & yarn" + +msg_info "Setup Platformio" +curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py +$STD python3 get-platformio.py +msg_ok "Setup Platformio" + +msg_info "Setup TasmoCompiler" +mkdir /tmp/Tasmota +RELEASE=$(curl -s https://api.github.com/repos/benzino77/tasmocompiler/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q https://github.com/benzino77/tasmocompiler/archive/refs/tags/v${RELEASE}.tar.gz -O /tmp/v${RELEASE}.tar.gz +cd /tmp +tar xzf /tmp/v${RELEASE}.tar.gz +mv tasmocompiler-${RELEASE}/ /opt/tasmocompiler/ +cd /opt/tasmocompiler +$STD yarn install +export NODE_OPTIONS=--openssl-legacy-provider +$STD npm i +$STD yarn build +mkdir -p /usr/local/bin +ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio +ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio +ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb +echo "${RELEASE}" >"/opt/tasmocompiler_version.txt" +msg_ok "Setup TasmoCompiler" + +msg_info "Creating Service" +cat </etc/systemd/system/tasmocompiler.service +[Unit] +Description=TasmoCompiler Service +After=multi-user.target + +[Service] +Type=simple +User=root +ExecStart=/usr/bin/node /opt/tasmocompiler/server/app.js + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now tasmocompiler +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f /tmp/v${RELEASE}.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/json/tasmocompiler.json b/json/tasmocompiler.json new file mode 100644 index 000000000..be7400407 --- /dev/null +++ b/json/tasmocompiler.json @@ -0,0 +1,34 @@ +{ + "name": "TasmoCompiler", + "slug": "tasmocompiler", + "categories": [ + 16 + ], + "date_created": "2025-02-10", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://github.com/benzino77/tasmocompiler/blob/master/README.md", + "website": "https://github.com/benzino77/tasmocompiler", + "logo": "https://github.com/benzino77/tasmocompiler/raw/master/docs/logo/tasmocompiler-symbol.svg", + "description": "TasmoCompiler is a simple web GUI which allows you to compile fantastic Tasmota firmware with your own settings.", + "install_methods": [ + { + "type": "default", + "script": "ct/tasmocompiler.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 10, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file