summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index 8aa2f3bd..dbee7b0a 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -15,6 +15,7 @@ import qualified Propellor.Property.Git as Git
import qualified Propellor.Property.Cron as Cron
import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.User as User
+import qualified Propellor.Property.Group as Group
import qualified Propellor.Property.Borg as Borg
import qualified Propellor.Property.Apache as Apache
import qualified Propellor.Property.Postfix as Postfix
@@ -916,10 +917,15 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro
& File.ownerGroup "/var/www/html" user (userGroup user)
& Git.cloned user "git://git.kitenet.net/joey/homepower" d Nothing
& buildpoller
+ & Systemd.enabled setupservicename
+ `requires` setupserviceinstalled
+ `onChange` Systemd.started setupservicename
& Systemd.enabled servicename
`requires` serviceinstalled
`onChange` Systemd.started servicename
& User.hasGroup user (Group "dialout")
+ & Group.exists (Group "gpio") Nothing
+ & User.hasGroup user (Group "gpio")
& Cron.niceJob "homepower upload"
(Cron.Times "1 * * * *") user d rsynccommand
`requires` Ssh.userKeyAt (Just sshkeyfile) user ctx sshkey
@@ -951,6 +957,23 @@ homePowerMonitor user hosts ctx sshkey = propertyList "home power monitor" $ pro
, "[Install]"
, "WantedBy=multi-user.target"
]
+ setupservicename = "homepower-setup"
+ setupservicefile = "/etc/systemd/system/" ++ setupservicename ++ ".service"
+ setupserviceinstalled = servicefile `File.hasContent`
+ [ "[Unit]"
+ , "Description=home power monitor setup"
+ , ""
+ , "[Service]"
+ , "ExecStart=" ++ d ++ "/setup"
+ , "WorkingDirectory=" ++ d
+ , "User=root"
+ , "Group=root"
+ , "Type=oneshot"
+ , ""
+ , "[Install]"
+ , "WantedBy=multi-user.target"
+ , "WantedBy=homepower.target"
+ ]
-- Any changes to the rsync command will need my .authorized_keys
-- rsync server command to be updated too.
rsynccommand = "rsync -e 'ssh -i" ++ sshkeyfile ++ "' -avz rrds/recent/ joey@kitenet.net:/srv/web/homepower.joeyh.name/rrds/recent/"