From 24e355cfe42c34c9132d27e01c4a3fc480461171 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 9 Jan 2022 02:44:36 +0100 Subject: dayled --- files/files/etc/config/dayled.sops | 21 +++++++++++++++++++++ files/files/etc/hotplug.d/ntp/99-dayled | 7 +++++++ files/files/etc/init.d/dayled | 11 +++++++++++ files/files/usr/local/sbin/dayled.sh | 22 ++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 files/files/etc/config/dayled.sops create mode 100644 files/files/etc/hotplug.d/ntp/99-dayled create mode 100755 files/files/etc/init.d/dayled create mode 100644 files/files/usr/local/sbin/dayled.sh (limited to 'files') diff --git a/files/files/etc/config/dayled.sops b/files/files/etc/config/dayled.sops new file mode 100644 index 0000000..ad89426 --- /dev/null +++ b/files/files/etc/config/dayled.sops @@ -0,0 +1,21 @@ +{ + "data": "ENC[AES256_GCM,data:hOZtsaVLwayRsA1vSdN0Rp6V6shQe0sQp1mGnKiwhR3SsSitYmGohzt+sfXER4YKRaMjE1QwdeSFcX3kjthvgHiOqscirKBdodTxYQvwrr8iog1FgmWCLlNAy4ymu4w=,iv:boQ8RbTFCUPAmzr6dW/q2mg6/Hj8Z3oN9y79gdSMLvQ=,tag:f/suZzHXTpS7RWVQQw1D/g==,type:str]", + "sops": { + "kms": null, + "gcp_kms": null, + "azure_kv": null, + "hc_vault": null, + "age": null, + "lastmodified": "2022-01-09T01:15:26Z", + "mac": "ENC[AES256_GCM,data:hwXoKGTfNQAydB1dW5z8OOIngWPtgpuoNA/cUE7Fp7pk0qfepkasAI3Ia5pbnTelwEdEA8WIUkspsWMTsHSsSfGCaK1nlUoJaFEPp2WfAlYMlv72hpYSPCMliEqzZlVEKErHEntzmKEKkzIEZgvRdcXlKkuaoVqw4BLOq7D7GMY=,iv:oUhIWjYBRp+IG/CGQ0Di53O9p1IThTUZZFtOnyrC210=,tag:6URfy7eJE7UyfLfo5cw6Ng==,type:str]", + "pgp": [ + { + "created_at": "2022-01-09T01:06:05Z", + "enc": "-----BEGIN PGP MESSAGE-----\n\nhF4DXxoViZlp6dISAQdAsk0uQt1Z6ZLFOIk7wnRrGAvqKX6heGmm1lT/H0Tmq1sw\nbPoi/dET8FwNNuAMnzZ2tDvFK9EPc5JUsVUJQj1UovnX8C7LOB4sj6d5r5QX8ESy\n0l4BobggGBHcNiHymFSkDpnCcR/16twE+HWNGvqDKtjMDncgLgrsB3ost4sGDLVI\nZxVgSSFcEfi2wUOToI/A9jjPAk4Kg80nTHHZrWvAYBDkkh6+fcLyI42JGrhklNqv\n=IXR/\n-----END PGP MESSAGE-----\n", + "fp": "30D3453B8CD02FE2A3E7C78C0FB536FB87AE8F51" + } + ], + "unencrypted_suffix": "_unencrypted", + "version": "3.7.1" + } +} \ No newline at end of file diff --git a/files/files/etc/hotplug.d/ntp/99-dayled b/files/files/etc/hotplug.d/ntp/99-dayled new file mode 100644 index 0000000..6dcaadc --- /dev/null +++ b/files/files/etc/hotplug.d/ntp/99-dayled @@ -0,0 +1,7 @@ +[ "$ACTION" = "stratum" ] || exit 0 + +/etc/init.d/dayled stop + +/usr/local/sbin/dayled.sh poll + +/etc/init.d/dayled start \ No newline at end of file diff --git a/files/files/etc/init.d/dayled b/files/files/etc/init.d/dayled new file mode 100755 index 0000000..79a9c59 --- /dev/null +++ b/files/files/etc/init.d/dayled @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common + +USE_PROCD=1 +NAME=dayled + +start_service() { + procd_open_instance $NAME + procd_set_param command /usr/local/sbi/dayled.sh + procd_set_param respawn 3600 1 0 + procd_close_instance +} diff --git a/files/files/usr/local/sbin/dayled.sh b/files/files/usr/local/sbin/dayled.sh new file mode 100644 index 0000000..8a30b4e --- /dev/null +++ b/files/files/usr/local/sbin/dayled.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +local latitude="$(uci get dayled.@dayled[0].latitude)" +local longitude="$(uci get dayled.@dayled[0].longitude)" +local offset="$(uci get dayled.@dayled[0].offset)" + +function act() { + sunwait $1 $offset $latitude $longitude >/dev/null + local state=$? + if [ "$state" -eq 2 ]; then + cat /sys/class/leds/blue\:dome/max_brightness > /sys/class/leds/blue\:dome/brightness + elif [ "$state" -eq 3 ]; then + echo 0 > /sys/class/leds/blue\:dome/brightness + fi +} + +while + act "${1:-wait}" + [ "${1:-wait}" = "wait" ] +do :; done + act wait +done -- cgit v1.2.3