From 4b4ac8dfbf743cc8b60ec68f44c6c98a69738332 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 18 Jan 2018 18:13:16 -0400 Subject: propellor spin --- joeyconfig.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'joeyconfig.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index 9894a155..bcafea0c 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -27,6 +27,7 @@ import qualified Propellor.Property.Apache as Apache import qualified Propellor.Property.LetsEncrypt as LetsEncrypt import qualified Propellor.Property.Locale as Locale import qualified Propellor.Property.Grub as Grub +import qualified Propellor.Property.FlashKernel as FlashKernel import qualified Propellor.Property.Borg as Borg import qualified Propellor.Property.Gpg as Gpg import qualified Propellor.Property.Systemd as Systemd @@ -187,6 +188,9 @@ honeybee = host "honeybee.kitenet.net" $ props `mountedAt` "/" `setSize` MegaBytes 8000 ) + & File.hasPrivContentExposed "/etc/flash-kernel/dtbs/sun7i-a20-cubietruck.dtb" + (Context "cubietruck gpio") + `onChange` FlashKernel.flashKernel & Apt.installed ["firmware-brcm80211"] -- Workaround for https://bugs.debian.org/844056 -- cgit v1.3-2-g0d8e From 8f02cace980527c005f3807a8d6c965fec6e50b9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Jan 2018 13:19:38 -0400 Subject: propellor spin --- joeyconfig.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'joeyconfig.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index bcafea0c..3615181c 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -95,6 +95,7 @@ darkstar = host "darkstar.kitenet.net" $ props -- & JoeySites.alarmClock "*-*-* 7:30" (User "joey") -- "/usr/bin/timeout 45m /home/joey/bin/goodmorning" & JoeySites.laptopSoftware + & JoeySites.userDirHtml & Ssh.userKeys (User "joey") hostContext [ (SshRsa, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1YoyHxZwG5Eg0yiMTJLSWJ/+dMM6zZkZiR4JJ0iUfP+tT2bm/lxYompbSqBeiCq+PYcSC67mALxp1vfmdOV//LWlbXfotpxtyxbdTcQbHhdz4num9rJQz1tjsOsxTEheX5jKirFNC5OiKhqwIuNydKWDS9qHGqsKcZQ8p+n1g9Lr3nJVGY7eRRXzw/HopTpwmGmAmb9IXY6DC2k91KReRZAlOrk0287LaK3eCe1z0bu7LYzqqS+w99iXZ/Qs0m9OqAPnHZjWQQ0fN4xn5JQpZSJ7sqO38TBAimM+IHPmy2FTNVVn9zGM+vN1O2xr3l796QmaUG1+XLL0shfR/OZbb joey@darkstar") ] -- cgit v1.3-2-g0d8e From 2ac8353c96326f911768c985f638dabe36991e32 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Feb 2018 11:51:51 -0400 Subject: Grub: Added properties to configure /etc/default/grub. This commit was sponsored by Ewen McNeill on Patreon. --- debian/changelog | 1 + joeyconfig.hs | 2 ++ src/Propellor/Property/Grub.hs | 65 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) (limited to 'joeyconfig.hs') diff --git a/debian/changelog b/debian/changelog index acfbc895..7dc8c42a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ propellor (5.3.0) UNRELEASED; urgency=medium * Added BiosGrubFlag to PartFlag. * Run su with --login, to avoid inheriting some problematic environment variables, such as TMP, from the caller. + * Grub: Added properties to configure /etc/default/grub. -- Joey Hess Tue, 02 Jan 2018 13:06:45 -0400 diff --git a/joeyconfig.hs b/joeyconfig.hs index 3615181c..258df4b1 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -89,6 +89,8 @@ darkstar = host "darkstar.kitenet.net" $ props & ipv6 "2001:4830:1600:187::2" & Hostname.sane & Apt.serviceInstalledRunning "swapspace" + & Grub.cmdline_Linux "i915.enable_psr=1" + ! Grub.cmdline_Linux "quiet" & JoeySites.dkimMilter & JoeySites.postfixSaslPasswordClient diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index 5cb9077d..573a30f3 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -5,6 +5,8 @@ module Propellor.Property.Grub ( installed, mkConfig, installed', + configured, + cmdline_Linux, boots, bootsMounted, TimeoutSecs, @@ -13,11 +15,15 @@ module Propellor.Property.Grub ( import Propellor.Base import qualified Propellor.Property.File as File +import qualified Propellor.Property.ConfFile as ConfFile import qualified Propellor.Property.Apt as Apt import Propellor.Property.Mount import Propellor.Property.Chroot (inChroot) import Propellor.Types.Info import Propellor.Types.Bootloader +import Utility.SafeCommand + +import Data.List -- | Eg, \"hd0,0\" or \"xen/xvda1\" type GrubDevice = String @@ -53,6 +59,65 @@ installed' grubtarget = setInfoProperty aptinstall Coreboot -> "grub-coreboot" Xen -> "grub-xen" +-- | Sets a simple confguration value, using grub-mkconfig to update +-- the grub boot menu accordingly. On Debian, these are written to +-- +-- +-- Example: +-- +-- > & Grub.configured "GRUB_TIMEOUT" "10" +-- > & Grub.configured "GRUB_TERMINAL_INPUT" "console serial" +configured :: String -> String -> Property DebianLike +configured k v = ConfFile.adjustSection + ("grub configured with " ++ k ++ "=" ++ v) + isline + (not . isline) + (const [l]) + (const [l]) + simpleConfigFile + `onChange` mkConfig + where + isline s = (k ++ "=") `isPrefixOf` s + l = k ++ "=" ++ shellEscape v + +simpleConfigFile :: FilePath +simpleConfigFile = "/etc/default/grub" + +-- | Adds a word to the linux command line. Any other words in the command +-- line will be left unchanged. +-- +-- Example: +-- +-- > & Grub.cmdline_Linux "i915.enable_psr=1" +-- > ! Grub.cmdline_Linux "quiet" +cmdline_Linux :: String -> RevertableProperty DebianLike DebianLike +cmdline_Linux w = setup undo + where + setup = ConfFile.adjustSection + ("linux command line includes " ++ w) + isline + (not . isline) + (map (mkline . addw . getws)) + (++ [mkline [w]]) + simpleConfigFile + `onChange` mkConfig + undo = ConfFile.adjustSection + ("linux command line does not include " ++ w) + isline + (not . isline) + (map (mkline . rmw . getws)) + (++ [mkline [""]]) + simpleConfigFile + `onChange` mkConfig + k = "GRUB_CMDLINE_LINUX" + isline s = (k ++ "=") `isPrefixOf` s + mkline ws = k ++ "=" ++ shellEscape (unwords ws) + getws = concatMap words . shellUnEscape . drop 1 . dropWhile (/= '=') + addw ws + | w `elem` ws = ws + | otherwise = ws ++ [w] + rmw = filter (/= w) + -- | Installs grub onto a device's boot loader, -- so the system can boot from that device. -- -- cgit v1.3-2-g0d8e From 121c20726cebf3657b0b5d22d220cbdc7aa1aac4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Feb 2018 11:57:06 -0400 Subject: add only to default linux command line Don't affect rescue mode. --- joeyconfig.hs | 5 +++-- src/Propellor/Property/Grub.hs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'joeyconfig.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index 258df4b1..3d895e69 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -89,8 +89,9 @@ darkstar = host "darkstar.kitenet.net" $ props & ipv6 "2001:4830:1600:187::2" & Hostname.sane & Apt.serviceInstalledRunning "swapspace" - & Grub.cmdline_Linux "i915.enable_psr=1" - ! Grub.cmdline_Linux "quiet" + ! Grub.cmdline_Linux_default "quiet" + -- Power consumption tuning + & Grub.cmdline_Linux_default "i915.enable_psr=1" & JoeySites.dkimMilter & JoeySites.postfixSaslPasswordClient diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index 573a30f3..79ecd8c9 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -6,7 +6,7 @@ module Propellor.Property.Grub ( mkConfig, installed', configured, - cmdline_Linux, + cmdline_Linux_default, boots, bootsMounted, TimeoutSecs, @@ -83,15 +83,15 @@ configured k v = ConfFile.adjustSection simpleConfigFile :: FilePath simpleConfigFile = "/etc/default/grub" --- | Adds a word to the linux command line. Any other words in the command --- line will be left unchanged. +-- | Adds a word to the default linux command line. +-- Any other words in the command line will be left unchanged. -- -- Example: -- --- > & Grub.cmdline_Linux "i915.enable_psr=1" --- > ! Grub.cmdline_Linux "quiet" -cmdline_Linux :: String -> RevertableProperty DebianLike DebianLike -cmdline_Linux w = setup undo +-- > & Grub.cmdline_Linux_default "i915.enable_psr=1" +-- > ! Grub.cmdline_Linux_default "quiet" +cmdline_Linux_default :: String -> RevertableProperty DebianLike DebianLike +cmdline_Linux_default w = setup undo where setup = ConfFile.adjustSection ("linux command line includes " ++ w) @@ -109,7 +109,7 @@ cmdline_Linux w = setup undo (++ [mkline [""]]) simpleConfigFile `onChange` mkConfig - k = "GRUB_CMDLINE_LINUX" + k = "GRUB_CMDLINE_LINUX_DEFAULT" isline s = (k ++ "=") `isPrefixOf` s mkline ws = k ++ "=" ++ shellEscape (unwords ws) getws = concatMap words . shellUnEscape . drop 1 . dropWhile (/= '=') -- cgit v1.3-2-g0d8e From 141cf24148a1258a94f95ba1a6b2265070675d30 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Feb 2018 12:19:09 -0400 Subject: Laptop: New module, starting with powertopAutoTuneOnBoot. This commit was sponsored by Brock Spratlen on Patreon. --- debian/changelog | 1 + joeyconfig.hs | 5 +++-- propellor.cabal | 1 + src/Propellor/Property/Laptop.hs | 28 ++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/Propellor/Property/Laptop.hs (limited to 'joeyconfig.hs') diff --git a/debian/changelog b/debian/changelog index 7dc8c42a..23172a22 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ propellor (5.3.0) UNRELEASED; urgency=medium * Run su with --login, to avoid inheriting some problematic environment variables, such as TMP, from the caller. * Grub: Added properties to configure /etc/default/grub. + * Laptop: New module, starting with powertopAutoTuneOnBoot. -- Joey Hess Tue, 02 Jan 2018 13:06:45 -0400 diff --git a/joeyconfig.hs b/joeyconfig.hs index 3d895e69..1d019498 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -33,6 +33,7 @@ import qualified Propellor.Property.Gpg as Gpg import qualified Propellor.Property.Systemd as Systemd import qualified Propellor.Property.Journald as Journald import qualified Propellor.Property.Fail2Ban as Fail2Ban +import qualified Propellor.Property.Laptop as Laptop import qualified Propellor.Property.OS as OS import qualified Propellor.Property.HostingProvider.CloudAtCost as CloudAtCost import qualified Propellor.Property.HostingProvider.Linode as Linode @@ -89,9 +90,9 @@ darkstar = host "darkstar.kitenet.net" $ props & ipv6 "2001:4830:1600:187::2" & Hostname.sane & Apt.serviceInstalledRunning "swapspace" - ! Grub.cmdline_Linux_default "quiet" - -- Power consumption tuning + & Laptop.powertopAutoTuneOnBoot & Grub.cmdline_Linux_default "i915.enable_psr=1" + ! Grub.cmdline_Linux_default "quiet" & JoeySites.dkimMilter & JoeySites.postfixSaslPasswordClient diff --git a/propellor.cabal b/propellor.cabal index a76d63f0..e59a55a4 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -127,6 +127,7 @@ Library Propellor.Property.Journald Propellor.Property.Kerberos Propellor.Property.LetsEncrypt + Propellor.Property.Laptop Propellor.Property.List Propellor.Property.LightDM Propellor.Property.Locale diff --git a/src/Propellor/Property/Laptop.hs b/src/Propellor/Property/Laptop.hs new file mode 100644 index 00000000..a36bda18 --- /dev/null +++ b/src/Propellor/Property/Laptop.hs @@ -0,0 +1,28 @@ +module Propellor.Property.Laptop where + +import Propellor.Base +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Systemd as Systemd + +-- | Makes powertop auto-tune the system for optimal power consumption on +-- boot. +powertopAutoTuneOnBoot :: RevertableProperty DebianLike DebianLike +powertopAutoTuneOnBoot = setup undo + `describe` "powertop auto-tune on boot" + where + setup = Systemd.enabled "powertop" + `requires` Apt.installed ["powertop"] + `requires` File.hasContent servicefile + [ "[Unit]" + , "Description=Powertop tunings" + , "[Service]" + , "ExecStart=/usr/sbin/powertop --auto-tune" + , "RemainAfterExit=true" + , "[Install]" + , "WantedBy=multi-user.target" + ] + undo = tightenTargets $ File.notPresent servicefile + `requires` check (doesFileExist servicefile) + (Systemd.disabled "powertop") + servicefile = "/etc/systemd/system/powertop.service" -- cgit v1.3-2-g0d8e