summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/SiteSpecific/JoeySites.hs
diff options
context:
space:
mode:
authorJoey Hess2017-08-03 16:13:26 -0400
committerJoey Hess2017-08-03 16:13:26 -0400
commit6f5b1a8fd66864b45db36c2dc51a6586b97ea8fa (patch)
treed7b278a3b221090113a4f77d8f07799bc12e8383 /src/Propellor/Property/SiteSpecific/JoeySites.hs
parentbd3de25d6984ad6435da64814735c191a44cfb65 (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/SiteSpecific/JoeySites.hs')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index 61bc3b1a..ab3825a0 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -941,18 +941,22 @@ alarmClock oncalendar (User user) command = combineProperties "goodmorning timer
("Login", "LidSwitchIgnoreInhibited", "no")
-- My home power monitor.
-homePowerMonitor :: Property DebianLike
-homePowerMonitor = propertyList "home power monitor" $ props
+homePowerMonitor :: IsContext c => User -> c -> (SshKeyType, Ssh.PubKeyText) -> Property (HasInfo + DebianLike)
+homePowerMonitor user ctx sshkey = propertyList "home power monitor" $ props
& Apache.installed
& Apt.installed ["python2", "python-pymodbus"]
- & File.ownerGroup "/var/www/html" (User "joey") (Group "joey")
- & Git.cloned (User "joey") "git://git.kitenet.net/joey/homepower" d Nothing
+ & File.ownerGroup "/var/www/html" user (userGroup user)
+ & Git.cloned user "git://git.kitenet.net/joey/homepower" d Nothing
`onChange` buildpoller
& Systemd.enabled servicename
`requires` serviceinstalled
`onChange` Systemd.started servicename
+ & Cron.niceJob "homepower upload"
+ (Cron.Times "1 * * * *") user d rsynccommand
+ `requires` Ssh.userKeyAt (Just sshkeyfile) user ctx sshkey
where
d = "/var/www/html/homepower"
+ sshkeyfile = d </> ".ssh/key"
buildpoller = userScriptProperty (User "joey")
[ "cd " ++ d
, "make"
@@ -974,6 +978,10 @@ homePowerMonitor = propertyList "home power monitor" $ props
, "[Install]"
, "WantedBy=multi-user.target"
]
+ -- Only upload when eth0 is up; eg the satellite internet is up.
+ -- Any changes to the rsync command will need my .authorized_keys
+ -- rsync server command to be updated too.
+ rsynccommand = "if ip route | grep '^default' | grep -q eth0; then rsync -e 'ssh -i" ++ sshkeyfile ++ "' -avz rrds/recent/ joey@kitenet.net:/srv/web/homepower.joeyh.name/rrds/recent/; fi"
-- My home router, running hostapd and dnsmasq for wlan0,
-- with eth0 connected to a satellite modem, and a fallback ppp connection.