diff --git a/Makefile b/Makefile index 7e928ac..c67353e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +VERSION=0.2.0 +ARCH=amd64 all: client server jquery @@ -9,6 +11,7 @@ server: jquery server.go devices/* core/* html/* clean: rm dimmy dimmyd html/assets/jquery.js + rm -rf deb jquery: wget https://code.jquery.com/jquery-3.4.1.min.js -O html/assets/jquery.js @@ -16,6 +19,21 @@ jquery: install: cp dimmy /usr/bin cp dimmyd /usr/bin - test -f /etc/dimmyd.conf.yaml || cp dimmyd.conf.yaml.example /etc/dimmyd.conf.yaml + test -f /etc/dimmy/dimmyd.conf.yaml || cp dimmyd.conf.yaml.example /etc/dimmy/dimmyd.conf.yaml mkdir -p /usr/share/dimmy cp -R html/* /usr/share/dimmy + +deb: all + rm -rf deb + mkdir -p deb/dimmy/usr/bin + mkdir -p deb/dimmy/etc/dimmy + mkdir -p deb/dimmy/usr/share/dimmy + mkdir deb/dimmy/DEBIAN + cp deb.control deb/dimmy/DEBIAN/control + sed -i "s/\$version/$(VERSION)/" deb/dimmy/DEBIAN/control + cp dimmy deb/dimmy/usr/bin + cp dimmyd deb/dimmy/usr/bin + cp dimmyd.conf.yaml.example deb/dimmy/etc/dimmy/dimmyd.conf.yaml + cp -R html/* deb/dimmy/usr/share/dimmy + dpkg-deb --build deb/dimmy + mv deb/dimmy.deb dimmy_$(VERSION)_$(ARCH).deb diff --git a/core/config.go b/core/config.go index 2244d4f..7670afa 100644 --- a/core/config.go +++ b/core/config.go @@ -10,12 +10,12 @@ import ( func LoadConfig() (*ServerConfig, error) { var filename string - if _, err := os.Stat("/etc/dimmyd.conf.yaml"); err == nil { - filename = "/etc/dimmyd.conf.yaml" + if _, err := os.Stat("/etc/dimmy/dimmyd.conf.yaml"); err == nil { + filename = "/etc/dimmy/dimmyd.conf.yaml" } else if _, err := os.Stat("dimmyd.conf.yaml"); err == nil { filename = "dimmyd.conf.yaml" } else { - return nil, errors.New("could not find config file /etc/dimmyd.conf.yaml") + return nil, errors.New("could not find config file /etc/dimmy/dimmyd.conf.yaml") } log.Println("Loading config file " + filename) diff --git a/deb.control b/deb.control new file mode 100644 index 0000000..5c70f0e --- /dev/null +++ b/deb.control @@ -0,0 +1,5 @@ +Package: dimmy +Version: $version +Maintainer: Phil Gruber +Architecture: $arch +Description: dimmy is a small home automation system. It can control lights, blinds, and other devices via MQTT. It contains a daemon, a CLI client, a JSON API and a web interface.