From 811ad9d4f5e907c7064d86db89a40e840b187f55 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:53:53 -0400 Subject: found this handy conversion of my blog post to propellor property in spwhitton's repo --- config-joey.hs | 2 ++ src/Propellor/Property/SiteSpecific/JoeySites.hs | 40 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/config-joey.hs b/config-joey.hs index 34b48027..479bb221 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -80,6 +80,8 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.postfixClientRelay (Context "darkstar.kitenet.net") & JoeySites.dkimMilter + & alarmClock "*-*-* 7:30" (User "joey") + "/usr/bin/timeout 45m /home/joey/bin/goodmorning" & imageBuilt "/tmp/img" c MSDOS (grubBooted PC) [ partition EXT2 `mountedAt` "/boot" diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index d6a50309..f428d382 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -929,3 +929,43 @@ userDirHtml = File.fileProperty "apache userdir is html" (map munge) conf munge = replace "public_html" "html" conf = "/etc/apache2/mods-available/userdir.conf" +-- Alarm clock: see +-- +-- +-- oncalendar example value: "*-*-* 7:30" +alarmClock :: String -> User -> String -> Property NoInfo +alarmClock oncalendar (User user) command = combineProperties + "goodmorning timer installed" + [ "/etc/systemd/system/goodmorning.timer" `File.hasContent` + [ "[Unit]" + , "Description=good morning" + , "" + , "[Timer]" + , "Unit=goodmorning.service" + , "OnCalendar=" ++ oncalendar + , "WakeSystem=true" + , "Persistent=false" + , "" + , "[Install]" + , "WantedBy=multi-user.target" + ] + `onChange` (Systemd.daemonReloaded + `before` Systemd.restarted "goodmorning.timer") + , "/etc/systemd/system/goodmorning.service" `File.hasContent` + [ "[Unit]" + , "Description=good morning" + , "RefuseManualStart=true" + , "RefuseManualStop=true" + , "ConditionACPower=true" + , "StopWhenUnneeded=yes" + , "" + , "[Service]" + , "Type=oneshot" + , "ExecStart=/bin/systemd-inhibit --what=handle-lid-switch --why=goodmorning /bin/su " ++ user ++ " -c \"" ++ program ++ "\"" + ] + `onChange` Systemd.daemonReloaded + , Systemd.enabled "goodmorning.timer" + , Systemd.started "goodmorning.timer" + , "/etc/systemd/logind.conf" `File.containsConfPair` + ("Login", "LidSwitchIgnoreInhibited", "no") + ] -- cgit v1.2.3 From 03bb424d18651e5e6225590a752b7267e6eed6b5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:54:38 -0400 Subject: merge fix from gix-annex --- src/Utility/Scheduled.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Utility/Scheduled.hs b/src/Utility/Scheduled.hs index ead8f771..d23aaf03 100644 --- a/src/Utility/Scheduled.hs +++ b/src/Utility/Scheduled.hs @@ -36,6 +36,7 @@ import Data.Time.LocalTime import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.Time.Calendar.OrdinalDate +import Data.Time.Format () import Data.Tuple.Utils import Data.Char import Control.Applicative -- cgit v1.2.3 From 776c11f6a9187da03324b879e744a8f07b480a09 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:58:45 -0400 Subject: fixes --- config-joey.hs | 2 +- src/Propellor/Property/SiteSpecific/JoeySites.hs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index 479bb221..98cb195a 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -80,7 +80,7 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.postfixClientRelay (Context "darkstar.kitenet.net") & JoeySites.dkimMilter - & alarmClock "*-*-* 7:30" (User "joey") + & JoeySites.alarmClock "*-*-* 7:30" (User "joey") "/usr/bin/timeout 45m /home/joey/bin/goodmorning" & imageBuilt "/tmp/img" c MSDOS (grubBooted PC) diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index f428d382..d22eb615 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -6,6 +6,7 @@ module Propellor.Property.SiteSpecific.JoeySites where import Propellor.Base import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.File as File +import qualified Propellor.Property.ConfFile as ConfFile import qualified Propellor.Property.Gpg as Gpg import qualified Propellor.Property.Ssh as Ssh import qualified Propellor.Property.Git as Git @@ -961,11 +962,11 @@ alarmClock oncalendar (User user) command = combineProperties , "" , "[Service]" , "Type=oneshot" - , "ExecStart=/bin/systemd-inhibit --what=handle-lid-switch --why=goodmorning /bin/su " ++ user ++ " -c \"" ++ program ++ "\"" + , "ExecStart=/bin/systemd-inhibit --what=handle-lid-switch --why=goodmorning /bin/su " ++ user ++ " -c \"" ++ command ++ "\"" ] `onChange` Systemd.daemonReloaded , Systemd.enabled "goodmorning.timer" , Systemd.started "goodmorning.timer" - , "/etc/systemd/logind.conf" `File.containsConfPair` + , "/etc/systemd/logind.conf" `ConfFile.containsIniSetting` ("Login", "LidSwitchIgnoreInhibited", "no") ] -- cgit v1.2.3