Browse Source

add picopublish build script for the greenhouse installer

main
forest 2 months ago
parent
commit
91dca98bd7
4 changed files with 46 additions and 16 deletions
  1. +4
    -1
      .gitignore
  2. +8
    -4
      main.go
  3. +34
    -0
      picopublish.sh
  4. +0
    -11
      setup.sh

+ 4
- 1
.gitignore View File

@ -1 +1,4 @@
greenhouse-daemon
greenhouse-daemon
.picopublish-auth
build/*
build

+ 8
- 4
main.go View File

@ -225,16 +225,16 @@ func main() {
useUnixSockets = true
}
thresholdExecutable := "threshold"
thresholdExecutable := "greenhouse-threshold"
if runtime.GOOS == "windows" {
thresholdExecutable = "threshold.exe"
thresholdExecutable = "greenhouse-threshold.exe"
}
thresholdExecutable = path.Join(daemonPath, thresholdExecutable)
thresholdArguments := []string{"-mode", "client", "-configFile", "threshold-config.json"}
caddyExecutable := "caddy"
caddyExecutable := "greenhouse-caddy"
if runtime.GOOS == "windows" {
caddyExecutable = "caddy.exe"
caddyExecutable = "greenhouse-caddy.exe"
}
caddyExecutable = path.Join(daemonPath, caddyExecutable)
caddyArguments := []string{"run", "-config", "caddy-config.json"}
@ -442,6 +442,10 @@ func main() {
func (daemon *DaemonAPI) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) {
switch path.Clean(request.URL.Path) {
case "/ping":
responseWriter.Header().Set("Content-Type", "text/plain")
responseWriter.Write([]byte("pong\n"))
case "/logs":
service := request.URL.Query().Get("service")
countString := request.URL.Query().Get("count")


+ 34
- 0
picopublish.sh View File

@ -0,0 +1,34 @@
#!/bin/bash -e
function build() {
GOOS=$1
GOARCH=$2
tag="0.0.0"
if git describe --tags --abbrev=0 > /dev/null 2>&1 ; then
tag="$(git describe --tags --abbrev=0)"
fi
version="$tag-$(git rev-parse --short HEAD)-$(hexdump -n 2 -ve '1/1 "%.2x"' /dev/urandom)"
echo "building version: $version"
rm -rf build
mkdir build
go build -tags 'osusergo netgo' -ldflags='-extldflags=-static' -o build/greenhouse-daemon
sha256sum build/greenhouse-daemon
gzip_file_name="greenhouse-daemon-$version-$GOOS-$GOARCH.gz"
gzip --stdout build/greenhouse-daemon > "build/$gzip_file_name"
curl -X POST "https://picopublish.sequentialread.com/files/$gzip_file_name" \
-H 'Content-Type: application/x-gzip' -H "Authorization: Basic $(cat .picopublish-auth)" \
--data-binary "@build/$gzip_file_name"
echo "https://picopublish.sequentialread.com/files/$gzip_file_name"
}
#build arm
build linux amd64
#build arm64

+ 0
- 11
setup.sh View File

@ -1,11 +0,0 @@
#!/bin/sh
echo "creating greenhouse-daemon user and group"
useradd greenhouse-daemon
usermod -a -G greenhouse-daemon greenhouse-daemon
echo "establishing greenhouse-daemon folder"
mkdir /opt/greenhouse-daemon
chown greenhouse-daemon:greenhouse-daemon /opt/greenhouse-daemon
chmod 700 /opt/greenhouse-daemon

Loading…
Cancel
Save