From 79e9fd911c955055877a6baef628029f4668ec8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Fri, 21 Mar 2025 17:57:08 +0100 Subject: [PATCH] GoMFT: Fix build dependencies (#3313) * Fix dependency * Fix dependency * Update install * Formatting --- ct/gomft.sh | 83 +++++++++++++++++++++------------------- install/gomft-install.sh | 23 ++++++----- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/ct/gomft.sh b/ct/gomft.sh index aba25e05a..02bd2f520 100644 --- a/ct/gomft.sh +++ b/ct/gomft.sh @@ -20,48 +20,51 @@ color catch_errors function update_script() { - header_info - check_container_storage - check_container_resources + header_info + check_container_storage + check_container_resources - if [[ ! -d "/opt/gomft" ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_info "Stopping $APP" - systemctl stop gomft - msg_ok "Stopped $APP" - - msg_info "Updating $APP to ${RELEASE}" - rm -f /opt/gomft/gomft - temp_file=$(mktemp) - wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file - tar -xzf $temp_file - cp -rf GoMFT-${RELEASE}/* /opt/gomft - cd /opt/gomft - $STD go mod download - $STD go build -o gomft - $STD $HOME/go/bin/templ generate - chmod +x /opt/gomft/gomft - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to ${RELEASE}" - - msg_info "Cleaning Up" - rm -f $temp_file - rm -rf GoMFT-${RELEASE} - msg_ok "Cleanup Complete" - - msg_info "Starting $APP" - systemctl start gomft - msg_ok "Started $APP" - - msg_ok "Update Successful" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" - fi + if [[ ! -d "/opt/gomft" ]]; then + msg_error "No ${APP} Installation Found!" exit + fi + RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop gomft + msg_ok "Stopped $APP" + + msg_info "Updating $APP to ${RELEASE}" + rm -f /opt/gomft/gomft + temp_file=$(mktemp) + wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file + tar -xzf $temp_file + cp -rf GoMFT-${RELEASE}/* /opt/gomft + cd /opt/gomft + $STD go mod download + $STD go install github.com/a-h/templ/cmd/templ@latest + $STD $HOME/go/bin/templ generate + export CGO_ENABLED=1 + export GOOS=linux + $STD go build -o gomft + chmod +x /opt/gomft/gomft + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + + msg_info "Cleaning Up" + rm -f $temp_file + rm -rf GoMFT-${RELEASE} + msg_ok "Cleanup Complete" + + msg_info "Starting $APP" + systemctl start gomft + msg_ok "Started $APP" + + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit } start diff --git a/install/gomft-install.sh b/install/gomft-install.sh index d398cad9e..a9596a891 100644 --- a/install/gomft-install.sh +++ b/install/gomft-install.sh @@ -15,13 +15,14 @@ update_os msg_info "Installing Dependencies" $STD apt-get install -y \ - curl \ - sudo \ - mc \ - sqlite3 \ - rclone \ - tzdata \ - ca-certificates + curl \ + sudo \ + mc \ + sqlite3 \ + rclone \ + tzdata \ + ca-certificates \ + build-essential msg_ok "Installed Dependencies" msg_info "Setting up Golang" @@ -34,7 +35,7 @@ ln -sf /usr/local/go/bin/go /usr/local/bin/go set -o pipefail msg_ok "Setup Golang" -msg_info "Setup ${APPLICATION}" +msg_info "Setup ${APPLICATION} (Patience)" temp_file=$(mktemp) RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file @@ -42,10 +43,12 @@ tar -xzf $temp_file mv GoMFT-${RELEASE}/ /opt/gomft cd /opt/gomft $STD go mod download -$STD go build -o gomft -chmod +x gomft $STD go install github.com/a-h/templ/cmd/templ@latest $STD $HOME/go/bin/templ generate +export CGO_ENABLED=1 +export GOOS=linux +$STD go build -o gomft +chmod +x /opt/gomft/gomft JWT_SECRET_KEY=$(openssl rand -base64 24 | tr -d '/+=') cat </opt/gomft/.env