From 2c11085e5e1325bcd333afc144ca0af019708842 Mon Sep 17 00:00:00 2001 From: Miraty Date: Sat, 10 Feb 2024 19:00:59 +0100 Subject: [PATCH] Better installation script sftpgo.sh --- mkosi.extra/root/sftpgo.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mkosi.extra/root/sftpgo.sh b/mkosi.extra/root/sftpgo.sh index 607ff88..1b427aa 100755 --- a/mkosi.extra/root/sftpgo.sh +++ b/mkosi.extra/root/sftpgo.sh @@ -1,22 +1,25 @@ -#!/usr/bin/bash +#!/usr/bin/env bash source /etc/os-release set -euo pipefail -export GO=/usr/bin/go -if [[ $ID = "debian" ]]; then - export GO=/usr/lib/go-1.19/bin/go -fi - -if [[ -d "sftpgo" ]]; then +# Download latest release +if [[ ! -d "sftpgo-src" ]]; then git clone https://github.com/drakkan/sftpgo sftpgo-src fi cd sftpgo-src +git checkout main git pull origin HEAD git checkout $(git tag | tail -n 1) + +# Prepare cp -r openapi ./internal/bundle/openapi cp -r templates ./internal/bundle/templates cp -r static ./internal/bundle/static -$GO build -tags nogcs,nos3,noazblob,nobolt,nomysql,nopgsql,nosqlite,noportable,nometrics,bundle -o sftpgo -mv sftpgo /usr/local/bin/ + +# Build +go build -tags nogcs,nos3,noazblob,nobolt,nomysql,nopgsql,nosqlite,noportable,nometrics,bundle -o sftpgo strip /usr/local/bin/sftpgo + +# Install +mv sftpgo /usr/local/bin/