Skip to content

Commit 79e9fd9

Browse files
authored
GoMFT: Fix build dependencies (#3313)
* Fix dependency * Fix dependency * Update install * Formatting
1 parent f7762da commit 79e9fd9

File tree

2 files changed

+53
-47
lines changed

2 files changed

+53
-47
lines changed

ct/gomft.sh

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,51 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
23+
header_info
24+
check_container_storage
25+
check_container_resources
2626

27-
if [[ ! -d "/opt/gomft" ]]; then
28-
msg_error "No ${APP} Installation Found!"
29-
exit
30-
fi
31-
RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
33-
msg_info "Stopping $APP"
34-
systemctl stop gomft
35-
msg_ok "Stopped $APP"
27+
if [[ ! -d "/opt/gomft" ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
33+
msg_info "Stopping $APP"
34+
systemctl stop gomft
35+
msg_ok "Stopped $APP"
3636

37-
msg_info "Updating $APP to ${RELEASE}"
38-
rm -f /opt/gomft/gomft
39-
temp_file=$(mktemp)
40-
wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
41-
tar -xzf $temp_file
42-
cp -rf GoMFT-${RELEASE}/* /opt/gomft
43-
cd /opt/gomft
44-
$STD go mod download
45-
$STD go build -o gomft
46-
$STD $HOME/go/bin/templ generate
47-
chmod +x /opt/gomft/gomft
48-
echo "${RELEASE}" >/opt/${APP}_version.txt
49-
msg_ok "Updated $APP to ${RELEASE}"
37+
msg_info "Updating $APP to ${RELEASE}"
38+
rm -f /opt/gomft/gomft
39+
temp_file=$(mktemp)
40+
wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
41+
tar -xzf $temp_file
42+
cp -rf GoMFT-${RELEASE}/* /opt/gomft
43+
cd /opt/gomft
44+
$STD go mod download
45+
$STD go install github.com/a-h/templ/cmd/templ@latest
46+
$STD $HOME/go/bin/templ generate
47+
export CGO_ENABLED=1
48+
export GOOS=linux
49+
$STD go build -o gomft
50+
chmod +x /opt/gomft/gomft
51+
echo "${RELEASE}" >/opt/${APP}_version.txt
52+
msg_ok "Updated $APP to ${RELEASE}"
5053

51-
msg_info "Cleaning Up"
52-
rm -f $temp_file
53-
rm -rf GoMFT-${RELEASE}
54-
msg_ok "Cleanup Complete"
54+
msg_info "Cleaning Up"
55+
rm -f $temp_file
56+
rm -rf GoMFT-${RELEASE}
57+
msg_ok "Cleanup Complete"
5558

56-
msg_info "Starting $APP"
57-
systemctl start gomft
58-
msg_ok "Started $APP"
59+
msg_info "Starting $APP"
60+
systemctl start gomft
61+
msg_ok "Started $APP"
5962

60-
msg_ok "Update Successful"
61-
else
62-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
63-
fi
64-
exit
63+
msg_ok "Update Successful"
64+
else
65+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
66+
fi
67+
exit
6568
}
6669

6770
start

install/gomft-install.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ update_os
1515

1616
msg_info "Installing Dependencies"
1717
$STD apt-get install -y \
18-
curl \
19-
sudo \
20-
mc \
21-
sqlite3 \
22-
rclone \
23-
tzdata \
24-
ca-certificates
18+
curl \
19+
sudo \
20+
mc \
21+
sqlite3 \
22+
rclone \
23+
tzdata \
24+
ca-certificates \
25+
build-essential
2526
msg_ok "Installed Dependencies"
2627

2728
msg_info "Setting up Golang"
@@ -34,18 +35,20 @@ ln -sf /usr/local/go/bin/go /usr/local/bin/go
3435
set -o pipefail
3536
msg_ok "Setup Golang"
3637

37-
msg_info "Setup ${APPLICATION}"
38+
msg_info "Setup ${APPLICATION} (Patience)"
3839
temp_file=$(mktemp)
3940
RELEASE=$(curl -s https://api.github.com/repos/StarFleetCPTN/GoMFT/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
4041
wget -q "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
4142
tar -xzf $temp_file
4243
mv GoMFT-${RELEASE}/ /opt/gomft
4344
cd /opt/gomft
4445
$STD go mod download
45-
$STD go build -o gomft
46-
chmod +x gomft
4746
$STD go install github.com/a-h/templ/cmd/templ@latest
4847
$STD $HOME/go/bin/templ generate
48+
export CGO_ENABLED=1
49+
export GOOS=linux
50+
$STD go build -o gomft
51+
chmod +x /opt/gomft/gomft
4952
JWT_SECRET_KEY=$(openssl rand -base64 24 | tr -d '/+=')
5053

5154
cat <<EOF >/opt/gomft/.env

0 commit comments

Comments
 (0)