aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-08-21 20:20:54 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-08-21 20:20:54 -0400
commitba7c03e54fb2db498b9c95460c5d67af2b136483 (patch)
tree6697da48bfcca1ef418fdefcfdc273a7cd3c8d9a
parent5f0ea81f90fbfd3d0b91a48a2ad4f97be06d8441 (diff)
downloadpaste-ba7c03e54fb2db498b9c95460c5d67af2b136483.tar.gz
paste-ba7c03e54fb2db498b9c95460c5d67af2b136483.tar.xz
Remove binary. Add build.sh and LICENSE
-rw-r--r--LICENSE13
-rwxr-xr-xbuild.sh21
-rwxr-xr-xclient/clientbin7440474 -> 0 bytes
-rw-r--r--client/main.go7
-rw-r--r--main.go8
5 files changed, 49 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2e0cf78
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2021 Mitchell Riedstra
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..eea4a15
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+
+LICENSE="$(cat LICENSE)"
+
+version="$(git log --format="%h %d" -1)
+$(go version)
+Build Date: $(date +%m.%d.%Y)
+Source code can be found here:
+https://git.riedstra.dev/mitch/paste/about
+
+$LICENSE"
+
+if ! git diff-index --quiet HEAD ; then
+ version="dirty: $version"
+fi
+
+export CGO_ENABLED=0
+
+go build -ldflags="-X 'main.Version=$version'" -o paste .
+go build -ldflags="-X 'main.Version=$version'" -o paste-client ./client
diff --git a/client/client b/client/client
deleted file mode 100755
index 5b43e40..0000000
--- a/client/client
+++ /dev/null
Binary files differ
diff --git a/client/main.go b/client/main.go
index 279c88d..d322e84 100644
--- a/client/main.go
+++ b/client/main.go
@@ -14,6 +14,8 @@ import (
"gopkg.in/yaml.v3"
)
+var Version = "Development"
+
var ConfigFn = filepath.Join(os.Getenv("HOME"), ".paste")
var TokenFN = filepath.Join(os.Getenv("HOME"), ".paste-token")
@@ -167,9 +169,14 @@ func main() {
fl.StringVar(&ConfigFn, "c", ConfigFn, "Configuration file")
title := fl.String("t", "", "Optional title for the message")
debug := fl.Bool("d", false, "debugging add information to the logging output DEBUG=true|false controls this as well")
+ version := fl.Bool("v", false, "Print version and exit")
_ = fl.Parse(os.Args[1:])
+ if *version {
+ logger.Fatal(Version)
+ }
+
if d := os.Getenv("DEBUG"); d == "true" || *debug {
logger.SetFlags(log.LstdFlags | log.Llongfile)
}
diff --git a/main.go b/main.go
index 9040a70..c0deb6c 100644
--- a/main.go
+++ b/main.go
@@ -25,6 +25,8 @@ import (
"gopkg.in/yaml.v3"
)
+var Version = "Development"
+
var logger = log.New(os.Stderr, "", 0)
var ID_BYTES = 8
@@ -230,8 +232,14 @@ func main() {
debug := fl.Bool("d", false, "debugging add information to the logging output DEBUG=true|false controls this as well")
storage := fl.String("s", "", "Directory to serve, must be supplied via flag or STORAGE_DIR environment variable")
fl.IntVar(&ID_BYTES, "b", ID_BYTES, "How many random bytes for the id?")
+ version := fl.Bool("v", false, "Print version and exit")
+
_ = fl.Parse(os.Args[1:])
+ if *version {
+ logger.Fatal(Version)
+ }
+
if addr := os.Getenv("LISTEN_ADDR"); addr != "" {
*listen = addr
}