diff options
| author | Joey Hess <joeyh@joeyh.name> | 2018-05-06 11:05:46 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2018-05-06 11:05:46 -0400 |
| commit | b6fe3fdc3aa0a24f34dab254f26ff96d1ba544ab (patch) | |
| tree | 48a76fce1de2338b6c1aa2baa7e976a3ab93fa25 /src/Propellor/Property/SiteSpecific/JoeySites.hs | |
| parent | df95706a73f4509a5ac315fdb9b62940c38e9583 (diff) | |
| parent | 9863be7663b7954452d995956ebe1d4b65edaf56 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/SiteSpecific/JoeySites.hs')
| -rw-r--r-- | src/Propellor/Property/SiteSpecific/JoeySites.hs | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 9d7423d7..1ce8204b 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -909,20 +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 "git://git.kitenet.net/joey/homepower" d Nothing - & buildpoller + & 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 + & 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") @@ -936,23 +939,53 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro where d = "/var/www/html/homepower" sshkeyfile = d </> ".ssh/key" - buildpoller = userScriptProperty (User "joey") - [ "cd " ++ d + build = userScriptProperty (User "joey") + [ "cd " ++ d </> "reactive-banana-automation" + , "cabal install" + , "cd " ++ d , "make" ] `assume` MadeChange - `requires` Apt.installed ["ghc", "make"] - servicename = "homepower" - servicefile = "/etc/systemd/system/" ++ servicename ++ ".service" - serviceinstalled = servicefile `File.hasContent` + `requires` Apt.installed + [ "ghc", "cabal-install", "make" + , "libghc-http-types-dev" + , "libghc-stm-dev" + , "libghc-aeson-dev" + , "libghc-wai-dev" + , "libghc-warp-dev" + , "libghc-http-client-dev" + , "libghc-reactive-banana-dev" + , "libghc-hinotify-dev" + ] + 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" , "WorkingDirectory=" ++ d , "User=joey" , "Group=joey" + , "Restart=always" + , "" + , "[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" @@ -1007,7 +1040,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 short because the homepower + -- controller wants to know when clients disconnect + , "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" |
