Add install target for make
authorr <r@freesoftwareextremist.com>
Fri, 31 Jan 2020 18:18:31 +0000 (18:18 +0000)
committerr <r@freesoftwareextremist.com>
Fri, 31 Jan 2020 18:18:31 +0000 (18:18 +0000)
- Update default config path accordingly
- Mention use of config file in README

Makefile
README
main.go
service/transport.go

index 780f6e8de46eff7485d446811ab455e4faaf98d1..2ebd9df26e7501670251bf5e58869392a1d94495 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,32 @@
 GO=go
+BINPATH=/usr/local/bin
+DATAPATH=/var/bloat
+ETCPATH=/etc
 
 all: bloat
 
-PHONY:
-
-bloat: main.go PHONY
+bloat: main.go 
        $(GO) build $(GOFLAGS) -o bloat main.go
 
+install: bloat
+       cp bloat $(BINPATH)/bloat
+       chmod 0755 $(BINPATH)/bloat
+       mkdir -p $(DATAPATH)/database
+       cp -r templates $(DATAPATH)/
+       cp -r static $(DATAPATH)/
+       sed -e "s%=database%=$(DATAPATH)/database%g" \
+               -e "s%=templates%=$(DATAPATH)/templates%g" \
+               -e "s%=static%=$(DATAPATH)/static%g" \
+               < bloat.conf > $(ETCPATH)/bloat.conf
+
+uninstall:
+       rm -f $(BINPATH)/bloat
+       rm -fr $(DATAPATH)/templates
+       rm -fr $(DATAPATH)/static
+       rm -f $(ETCPATH)/bloat.conf
+
+clean: 
+       rm -f bloat
+
 run: bloat
        ./bloat
diff --git a/README b/README
index 57bd0e0931ceb5b2da227ece6b659bb2443279bf..8e0bc52b5c0af2af3c9ca4722d69adba2888e3fc 100644 (file)
--- a/README
+++ b/README
@@ -18,17 +18,17 @@ External dependencies:
 
 Building and Installation:
 
-Make sure you have GO installed. Other dependencies will be downloaded 
+Make sure you have Go installed. Other dependencies will be downloaded 
 automatically.
 
 Typing make will build the binary 
 $ make
 
 Edit the provided config file. See the default.conf file for more details.  
-$ ed default.conf
+$ ed bloat.conf
 
 Run the binary
-$ ./bloat
+$ ./bloat -f bloat.conf
 
 You can now access the frontend at http://localhost:8080, which is the default
 listen address. You can also setup a reverse HTTP proxy to serve the frontend over
diff --git a/main.go b/main.go
index 18e474c33b42a24809ddafed68886548c4731dee..a634e348103421566e6c836eef1e38175c52ea45 100644 (file)
--- a/main.go
+++ b/main.go
@@ -20,7 +20,7 @@ import (
 )
 
 var (
-       configFile = "bloat.conf"
+       configFile = "/etc/bloat.conf"
 )
 
 func init() {
index d945e182f907c5725af457ddb935b4cefe295c01..02168e8e31c4ce882c9427d53ab3556a14cfb766 100644 (file)
@@ -6,7 +6,6 @@ import (
        "io"
        "mime/multipart"
        "net/http"
-       "path"
        "strconv"
        "time"
 
@@ -595,7 +594,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
        r.HandleFunc("/fluoride/retweet/{id}", fRetweet).Methods(http.MethodPost)
        r.HandleFunc("/fluoride/unretweet/{id}", fUnretweet).Methods(http.MethodPost)
        r.PathPrefix("/static").Handler(http.StripPrefix("/static",
-               http.FileServer(http.Dir(path.Join(".", staticDir)))))
+               http.FileServer(http.Dir(staticDir))))
 
        return r
 }