From 3cba277a166da90d3cceabb144562ec7491f9a6d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 8 Apr 2018 18:13:17 -0400 Subject: propellor spin --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Propellor') 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/" -- cgit v1.2.3