From 3b4d9c01094c96c243be349542e18d38309a111f Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 22 May 2022 14:12:32 -0500 Subject: [PATCH] Install mqttdpms The `mqttdpms` tool will allow the screens to be turned off and on using Home Assistant. We'll install it into the rootfs image by copying the artifact from its Jenkins build into the overlay tree before building the image. --- .gitignore | 1 + Makefile | 8 +++++++- ci/Jenkinsfile | 13 ++++++++++++- overlay/etc/systemd/user/mqttdpms.service | 9 +++++++++ overlay/home/user/.config/mqttdpms/config.toml.in | 8 ++++++++ overlay/home/user/.xinitrc | 2 +- 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 overlay/etc/systemd/user/mqttdpms.service create mode 100644 overlay/home/user/.config/mqttdpms/config.toml.in diff --git a/.gitignore b/.gitignore index a485625..397a08a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /_build +overlay/home/user/.config/mqttdpms/config.toml diff --git a/Makefile b/Makefile index 73d15c0..ea43241 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ SHELL ?= /bin/sh .PHONY: rootfs -rootfs: +rootfs: \ + overlay/usr/local/bin/mqttdpms \ + overlay/home/user/.config/mqttdpms/config.toml $(SHELL) mkrootfs.sh _build/rootfs .PHONY: initramfs @@ -15,3 +17,7 @@ _build/rootfs/boot/initramfs.img: \ .PHONY: publish publish: $(SHELL) publish.sh _build/rootfs + +overlay/home/user/.config/mqttdpms/config.toml: \ + overlay/home/user/.config/mqttdpms/config.toml.in + sed "s:@PASSWORD@:${MQTTDPMS_PASSWORD}:" < $< > $@ diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 4ee4e72..4cec73d 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -39,7 +39,18 @@ pipeline { sh 'rm -rf _build' } } - sh 'make rootfs initramfs' + copyArtifacts \ + filter: 'aarch64/mqttdpms', + projectName: 'mqttdpms/master', + selector: lastSuccessful() + sh 'install aarch64/mqttdpms overlay/usr/local/bin/' + withCredentials([usernamePassword( + usernameVariable: 'MQTTDPMS_USERNAME', + passwordVariable: 'MQTTDPMS_PASSWORD', + credentialsId: 'mqttdpms-basementhud', + )]) { + sh 'make rootfs initramfs' + } } } diff --git a/overlay/etc/systemd/user/mqttdpms.service b/overlay/etc/systemd/user/mqttdpms.service new file mode 100644 index 0000000..971642c --- /dev/null +++ b/overlay/etc/systemd/user/mqttdpms.service @@ -0,0 +1,9 @@ +[Unit] +Description=MQTT DPMS Control + +[Service] +ExecStart=/usr/local/bin/mqttdpms +Environment=RUST_LOG=info +Restart=always +StandardInput=null +StandardOutput=journal diff --git a/overlay/home/user/.config/mqttdpms/config.toml.in b/overlay/home/user/.config/mqttdpms/config.toml.in new file mode 100644 index 0000000..bcbd988 --- /dev/null +++ b/overlay/home/user/.config/mqttdpms/config.toml.in @@ -0,0 +1,8 @@ +name = "Basement HUD" + +[mqtt] +host = 'homeassistant.pyrocufflink.blue' +port = 8883 +tls = true +username = 'basementhud' +password = "@PASSWORD@" diff --git a/overlay/home/user/.xinitrc b/overlay/home/user/.xinitrc index a423cce..7142a7b 100644 --- a/overlay/home/user/.xinitrc +++ b/overlay/home/user/.xinitrc @@ -7,6 +7,6 @@ TZ="$(curl https://ipapi.co/timezone)" export TZ systemctl --user import-environment DISPLAY TZ -systemctl --user start firefox-marionette.socket firefox +systemctl --user start firefox-marionette.socket firefox mqttdpms exec openbox-session