Add install target for make

- Update default config path accordingly
- Mention use of config file in README
This commit is contained in:
r 2020-01-31 18:18:31 +00:00
parent a981085260
commit cd9306294d
4 changed files with 29 additions and 9 deletions

View File

@ -1,11 +1,32 @@
GO=go GO=go
BINPATH=/usr/local/bin
DATAPATH=/var/bloat
ETCPATH=/etc
all: bloat all: bloat
PHONY: bloat: main.go
bloat: main.go PHONY
$(GO) build $(GOFLAGS) -o 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 run: bloat
./bloat ./bloat

6
README
View File

@ -18,17 +18,17 @@ External dependencies:
Building and Installation: 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. automatically.
Typing make will build the binary Typing make will build the binary
$ make $ make
Edit the provided config file. See the default.conf file for more details. Edit the provided config file. See the default.conf file for more details.
$ ed default.conf $ ed bloat.conf
Run the binary Run the binary
$ ./bloat $ ./bloat -f bloat.conf
You can now access the frontend at http://localhost:8080, which is the default 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 listen address. You can also setup a reverse HTTP proxy to serve the frontend over

View File

@ -20,7 +20,7 @@ import (
) )
var ( var (
configFile = "bloat.conf" configFile = "/etc/bloat.conf"
) )
func init() { func init() {

View File

@ -6,7 +6,6 @@ import (
"io" "io"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"path"
"strconv" "strconv"
"time" "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/retweet/{id}", fRetweet).Methods(http.MethodPost)
r.HandleFunc("/fluoride/unretweet/{id}", fUnretweet).Methods(http.MethodPost) r.HandleFunc("/fluoride/unretweet/{id}", fUnretweet).Methods(http.MethodPost)
r.PathPrefix("/static").Handler(http.StripPrefix("/static", r.PathPrefix("/static").Handler(http.StripPrefix("/static",
http.FileServer(http.Dir(path.Join(".", staticDir))))) http.FileServer(http.Dir(staticDir))))
return r return r
} }