summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs67
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"