summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile8
-rw-r--r--appdata/index.html.tmpl (renamed from index.html.tmpl)0
l---------appdata/webiot.css1
-rw-r--r--config.json3
-rw-r--r--main.go9
l---------webiot.css1
7 files changed, 12 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 3e18ebf..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-private
diff --git a/Makefile b/Makefile
index e258995..c8d409a 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ all:
# some recommended options for Go building:
# https://wiki.archlinux.org/title/Go_package_guidelines
mkdir -p build
- go build -o build/$(PROGRAM) main.go hs100.go
+ go build -o build/$(PROGRAM) *.go
clean:
rm -rf build
@@ -18,11 +18,11 @@ clean:
install: all
install -Dm 755 build/$(PROGRAM) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
install -Dm 644 config.json $(DESTDIR)/etc/$(PROGRAM)/config.json
- install -Dm 644 index.html.tmpl $(DESTDIR)$(PREFIX)/share/$(PROGRAM)/index.html.tmpl
- install -Dm 644 libweb/libweb.css $(DESTDIR)$(PREFIX)/share/$(PROGRAM)/webiot.css
+ install -Dm 644 appdata/index.html.tmpl $(DESTDIR)$(PREFIX)/share/$(PROGRAM)/index.html.tmpl
+ install -Dm 644 appdata/webiot.css $(DESTDIR)$(PREFIX)/share/$(PROGRAM)/webiot.css
install -Dm 644 systemd/$(PROGRAM).service $(DESTDIR)$(PREFIX)/lib/systemd/system/$(PROGRAM).service
install -Dm 644 systemd/$(PROGRAM).sysusers $(DESTDIR)$(PREFIX)/lib/sysusers.d/$(PROGRAM).conf
debug:
- go run main.go hs100.go -c private/config.json
+ go run *.go -c config.json -a appdata
diff --git a/index.html.tmpl b/appdata/index.html.tmpl
index 17c67c1..17c67c1 100644
--- a/index.html.tmpl
+++ b/appdata/index.html.tmpl
diff --git a/appdata/webiot.css b/appdata/webiot.css
new file mode 120000
index 0000000..9dd798c
--- /dev/null
+++ b/appdata/webiot.css
@@ -0,0 +1 @@
+../libweb/libweb.css \ No newline at end of file
diff --git a/config.json b/config.json
index 513e364..9366364 100644
--- a/config.json
+++ b/config.json
@@ -7,6 +7,5 @@
},
"web":{
"listen":"127.0.0.1:9000"
- },
- "appdata":"/usr/share/webiot/"
+ }
}
diff --git a/main.go b/main.go
index 35bacc1..3264134 100644
--- a/main.go
+++ b/main.go
@@ -15,10 +15,11 @@ import (
"text/template"
)
+var appdata string;
+
type RuntimeConfig struct {
Devices DevicesConfig
Web WebConfig
- Appdata string
}
type DevicesConfig struct {
@@ -33,9 +34,9 @@ type WebConfig struct {
func main() {
configPath := parseFlags()
c := parseConfig(configPath)
- http.HandleFunc("/", index(c.Devices, c.Appdata))
+ http.HandleFunc("/", index(c.Devices, appdata))
http.HandleFunc("/api", api())
- http.HandleFunc("/webiot.css", css(c.Appdata))
+ http.HandleFunc("/webiot.css", css(appdata))
fmt.Printf("Serving at http://%s\n", c.Web.Listen)
log.Fatal(http.ListenAndServe(c.Web.Listen.String(), nil))
}
@@ -47,6 +48,8 @@ func parseFlags() string {
flag.StringVar(&r, "c", "/etc/webiot/config.json",
"path to configuration file")
+ flag.StringVar(&appdata, "a", "/usr/share/webiot",
+ "path to static application data")
flag.Parse()
return r
diff --git a/webiot.css b/webiot.css
deleted file mode 120000
index 7efcff2..0000000
--- a/webiot.css
+++ /dev/null
@@ -1 +0,0 @@
-libweb/libweb.css \ No newline at end of file