From 130283c92f9be4fc7d6a7a86aeb591dc05a7bf6c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 May 2018 14:34:56 -0400 Subject: update --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Property/SiteSpecific') diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 9d7423d7..e3619c2a 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -915,7 +915,8 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro & Apache.installed & Apt.installed ["python", "python-pymodbus", "rrdtool", "rsync"] & File.ownerGroup "/var/www/html" user (userGroup user) - & Git.cloned user "git://git.kitenet.net/joey/homepower" d Nothing + & Git.cloned user "https://git.joeyh.name/git/joey/homepower.git" d Nothing + & Git.cloned user "https://git.joeyh.name/git/reactive-banana-automation.git" (d "reactive-banana-automation") Nothing & buildpoller & Systemd.enabled setupservicename `requires` setupserviceinstalled @@ -937,11 +938,21 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro d = "/var/www/html/homepower" sshkeyfile = d ".ssh/key" buildpoller = userScriptProperty (User "joey") - [ "cd " ++ d + [ "cd " ++ d "reactive-banana-automation" + , "cabal install" + , "cd " ++ d , "make" ] `assume` MadeChange - `requires` Apt.installed ["ghc", "make"] + `requires` Apt.installed + [ "ghc", "cabal-install", "make" + , "libghc-http-types-dev" + , "libghc-stm-dev" + , "libghc-aeson-dev" + , "libghc-wai-dev" + , "libghc-warp-dev" + , "libghc-reactive-banana-dev" + ] servicename = "homepower" servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" serviceinstalled = servicefile `File.hasContent` @@ -953,6 +964,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "WorkingDirectory=" ++ d , "User=joey" , "Group=joey" + , "Restart=always" , "" , "[Install]" , "WantedBy=multi-user.target" -- cgit v1.3-2-g0d8e From d023707d420bff9de2463cf4910b7165e6ddc5d0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 May 2018 23:28:51 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Propellor/Property/SiteSpecific') diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index e3619c2a..ec4cac57 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -951,6 +951,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-aeson-dev" , "libghc-wai-dev" , "libghc-warp-dev" + , "libghc-http-client-dev" , "libghc-reactive-banana-dev" ] servicename = "homepower" -- cgit v1.3-2-g0d8e From 4c88d4f0dab95deac11fac4cd59f84c1cb76d377 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 11:32:24 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Propellor/Property/SiteSpecific') diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index ec4cac57..1fc290bb 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -953,6 +953,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-warp-dev" , "libghc-http-client-dev" , "libghc-reactive-banana-dev" + , "libghc-hinotify-dev" ] servicename = "homepower" servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" @@ -1020,7 +1021,9 @@ homeRouter = propertyList "home router" $ props , "bogus-priv" , "interface=wlan0" , "domain=kitenet.net" - , "dhcp-range=10.1.1.100,10.1.1.150,24h" + -- lease time is 30 minutes because the homepower + -- controller wants to know when clients disconnect + , "dhcp-range=10.1.1.100,10.1.1.150,30m" , "no-hosts" , "address=/honeybee.kitenet.net/10.1.1.1" , "address=/house.kitenet.net/10.1.1.1" -- cgit v1.3-2-g0d8e From 9997a86d625b6ef91b7490a503f002d2a51d3997 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 21:56:21 -0400 Subject: propellor spin --- joeyconfig.hs | 2 +- src/Propellor/Property/SiteSpecific/JoeySites.hs | 43 +++++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) (limited to 'src/Propellor/Property/SiteSpecific') diff --git a/joeyconfig.hs b/joeyconfig.hs index 6236c9e2..2b69d541 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -196,7 +196,7 @@ honeybee = host "honeybee.kitenet.net" $ props [ (SshEd25519, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIS/hDYq1MAxfOBf49htym3BOYlx4Gk9SDpiHjv7u6IC") ] - & JoeySites.homePowerMonitor + & JoeySites.homePower (User "joey") hosts (Context "homepower.joeyh.name") diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 1fc290bb..aa68869d 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -909,21 +909,23 @@ alarmClock oncalendar (User user) command = combineProperties "goodmorning timer & "/etc/systemd/logind.conf" `ConfFile.containsIniSetting` ("Login", "LidSwitchIgnoreInhibited", "no") --- My home power monitor. -homePowerMonitor :: IsContext c => User -> [Host] -> c -> (SshKeyType, Ssh.PubKeyText) -> Property (HasInfo + DebianLike) -homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ props +homePower :: IsContext c => User -> [Host] -> c -> (SshKeyType, Ssh.PubKeyText) -> Property (HasInfo + DebianLike) +homePower user hosts ctx sshkey = propertyList "home power" $ props & Apache.installed & Apt.installed ["python", "python-pymodbus", "rrdtool", "rsync"] & File.ownerGroup "/var/www/html" user (userGroup user) & Git.cloned user "https://git.joeyh.name/git/joey/homepower.git" d Nothing & Git.cloned user "https://git.joeyh.name/git/reactive-banana-automation.git" (d "reactive-banana-automation") Nothing - & buildpoller + & build & Systemd.enabled setupservicename `requires` setupserviceinstalled `onChange` Systemd.started setupservicename - & Systemd.enabled servicename - `requires` serviceinstalled - `onChange` Systemd.started servicename + & Systemd.enabled pollerservicename + `requires` pollerserviceinstalled + `onChange` Systemd.started pollerservicename + & Systemd.enabled controllerservicename + `requires` controllerserviceinstalled + `onChange` Systemd.started controllerservicename & User.hasGroup user (Group "dialout") & Group.exists (Group "gpio") Nothing & User.hasGroup user (Group "gpio") @@ -937,7 +939,7 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro where d = "/var/www/html/homepower" sshkeyfile = d ".ssh/key" - buildpoller = userScriptProperty (User "joey") + build = userScriptProperty (User "joey") [ "cd " ++ d "reactive-banana-automation" , "cabal install" , "cd " ++ d @@ -955,11 +957,11 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "libghc-reactive-banana-dev" , "libghc-hinotify-dev" ] - servicename = "homepower" - servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" - serviceinstalled = servicefile `File.hasContent` + pollerservicename = "homepower" + pollerservicefile = "/etc/systemd/system/" ++ pollerservicename ++ ".service" + pollerserviceinstalled = pollerservicefile `File.hasContent` [ "[Unit]" - , "Description=home power monitor" + , "Description=home power poller" , "" , "[Service]" , "ExecStart=" ++ d ++ "/poller" @@ -970,6 +972,23 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro , "" , "[Install]" , "WantedBy=multi-user.target" + , "WantedBy=homepower-controller.target" + ] + controllerservicename = "homepower-controller" + controllerservicefile = "/etc/systemd/system/" ++ controllerservicename ++ ".service" + controllerserviceinstalled = controllerservicefile `File.hasContent` + [ "[Unit]" + , "Description=home power controller" + , "" + , "[Service]" + , "ExecStart=" ++ d ++ "/controller" + , "WorkingDirectory=" ++ d + , "User=joey" + , "Group=joey" + , "Restart=always" + , "" + , "[Install]" + , "WantedBy=multi-user.target" ] setupservicename = "homepower-setup" setupservicefile = "/etc/systemd/system/" ++ setupservicename ++ ".service" -- cgit v1.3-2-g0d8e From f7886b2d596311593c40260d0f5bae286d655a99 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 May 2018 23:39:35 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Property/SiteSpecific') diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index aa68869d..1ce8204b 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -1040,9 +1040,9 @@ homeRouter = propertyList "home router" $ props , "bogus-priv" , "interface=wlan0" , "domain=kitenet.net" - -- lease time is 30 minutes because the homepower + -- lease time is short because the homepower -- controller wants to know when clients disconnect - , "dhcp-range=10.1.1.100,10.1.1.150,30m" + , "dhcp-range=10.1.1.100,10.1.1.150,5m" , "no-hosts" , "address=/honeybee.kitenet.net/10.1.1.1" , "address=/house.kitenet.net/10.1.1.1" -- cgit v1.3-2-g0d8e