Skip to content

Commit

Permalink
add deb script to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilGruber committed Nov 22, 2024
1 parent 0770f27 commit fa00ba3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION=0.2.0
ARCH=amd64

all: client server jquery

Expand All @@ -9,13 +11,29 @@ 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

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
6 changes: 3 additions & 3 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions deb.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: dimmy
Version: $version
Maintainer: Phil Gruber <[email protected]>
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.

0 comments on commit fa00ba3

Please sign in to comment.