From c282a894b56012ae4f68b518e5fad01052ac4f22 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:01:55 -0400 Subject: XFCE and applyPath properties * Propellor.Property.XFCE added with some useful properties for the desktop environment. * Added File.applyPath property. This commit was sponsored by Riku Voipio. --- src/Propellor/Property/XFCE.hs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Propellor/Property/XFCE.hs (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs new file mode 100644 index 00000000..e75946a5 --- /dev/null +++ b/src/Propellor/Property/XFCE.hs @@ -0,0 +1,38 @@ +module Propellor.Property.XFCE where + +import Propellor.Base +import Propellor.Types.Core (getSatisfy) +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.File as File +import qualified Propellor.Property.User as User + +installed :: Property DebianLike +installed = Apt.installed ["task-xfce-desktop"] + +-- | Minimal install of XFCE, with a terminal emulator and panel, +-- and X, but not any of the extras. +installedMin :: Property DebianLike +installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] + +-- | Normally at first login, XFCE asks what kind of panel the user wants. +-- This enables the default configuration noninteractively. +-- +-- If the user subsequently modifies their panel, their modifications will +-- not be overwritten by this property. +defaultPanelFor :: User -> Property DebianLike +defaultPanelFor u@(User username) = adjustPropertySatisfy baseprop $ \s -> do + home <- liftIO $ User.homedir u + s <> fromMaybe mempty (getSatisfy (go home)) + where + cf = ".config" "xfce4" "xfconf" + "xfce-perchannel-xml" "xfce4-panel.xml" + -- This location is probably Debian-specific. + defcf = "/etc/xdg/xfce4/panel/default.xml" + go :: FilePath -> Property DebianLike + go home = tightenTargets $ + (home cf) `File.isCopyOf` defcf + `before` File.applyPath home cf + (\f -> File.ownerGroup f u (userGroup u)) + `requires` Apt.installed ["xfce4-panel"] + baseprop :: Property DebianLike + baseprop = doNothing `describe` ("default XFCE panel for " ++ username) -- cgit v1.3-2-g0d8e From 1428b1f276a65a3a3c5a881905458df8fe0e6f62 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:20:47 -0400 Subject: propellor spin --- src/Propellor/Property/XFCE.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index e75946a5..4f3a152a 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -8,11 +8,13 @@ import qualified Propellor.Property.User as User installed :: Property DebianLike installed = Apt.installed ["task-xfce-desktop"] + `describe` "XFCE desktop installed" -- | Minimal install of XFCE, with a terminal emulator and panel, -- and X, but not any of the extras. installedMin :: Property DebianLike installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] + `describe` "minimal XFCE desktop installed" -- | Normally at first login, XFCE asks what kind of panel the user wants. -- This enables the default configuration noninteractively. -- cgit v1.3-2-g0d8e From 20a5f616bd4c8c3acc78bc64f20832ca4784b5c7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:26:30 -0400 Subject: less wonky (and working) implementation of defaultPanelFor --- joeyconfig.hs | 3 +-- src/Propellor/Property/XFCE.hs | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index ff16777c..f8b26a2b 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -110,9 +110,8 @@ darkstar = host "darkstar.kitenet.net" $ props `before` File.ownerGroup "/srv/propellor-disk.img" (User "joey") (Group "joey") demo :: Host -demo = host "demo.kitenet.net" $ props +demo = host "demo" $ props & osDebian Unstable X86_64 - & Hostname.setTo "demo" & Apt.installed ["linux-image-amd64"] & bootstrappedFrom GitRepoOutsideChroot & User.accountFor user diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index 4f3a152a..e3dd060e 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -1,7 +1,6 @@ module Propellor.Property.XFCE where import Propellor.Base -import Propellor.Types.Core (getSatisfy) import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.File as File import qualified Propellor.Property.User as User @@ -22,10 +21,11 @@ installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] -- If the user subsequently modifies their panel, their modifications will -- not be overwritten by this property. defaultPanelFor :: User -> Property DebianLike -defaultPanelFor u@(User username) = adjustPropertySatisfy baseprop $ \s -> do +defaultPanelFor u@(User username) = property' desc $ \w -> do home <- liftIO $ User.homedir u - s <> fromMaybe mempty (getSatisfy (go home)) + ensureProperty w (go home) where + desc = "default XFCE panel for " ++ username cf = ".config" "xfce4" "xfconf" "xfce-perchannel-xml" "xfce4-panel.xml" -- This location is probably Debian-specific. @@ -36,5 +36,3 @@ defaultPanelFor u@(User username) = adjustPropertySatisfy baseprop $ \s -> do `before` File.applyPath home cf (\f -> File.ownerGroup f u (userGroup u)) `requires` Apt.installed ["xfce4-panel"] - baseprop :: Property DebianLike - baseprop = doNothing `describe` ("default XFCE panel for " ++ username) -- cgit v1.3-2-g0d8e From f9f1158c0c0fc173045ec7bb7fcbacdd76b24ffd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:42:57 -0400 Subject: avoid overwriting existing file --- src/Propellor/Property/XFCE.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index e3dd060e..a1b9d7d7 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -26,13 +26,15 @@ defaultPanelFor u@(User username) = property' desc $ \w -> do ensureProperty w (go home) where desc = "default XFCE panel for " ++ username - cf = ".config" "xfce4" "xfconf" + basecf = ".config" "xfce4" "xfconf" "xfce-perchannel-xml" "xfce4-panel.xml" -- This location is probably Debian-specific. defcf = "/etc/xdg/xfce4/panel/default.xml" go :: FilePath -> Property DebianLike - go home = tightenTargets $ - (home cf) `File.isCopyOf` defcf - `before` File.applyPath home cf + go home = tightenTargets $ check (not <$> doesFileExist cf) $ + cf `File.isCopyOf` defcf + `before` File.applyPath home basecf (\f -> File.ownerGroup f u (userGroup u)) `requires` Apt.installed ["xfce4-panel"] + where + cf = home basecf -- cgit v1.3-2-g0d8e From 36671f5c992905aa71722b16d800313f60a02622 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:46:36 -0400 Subject: add Overwrite configuration --- joeyconfig.hs | 2 +- src/Propellor/Property/XFCE.hs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index f8b26a2b..20e73cef 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -118,7 +118,7 @@ demo = host "demo" $ props & root `User.hasInsecurePassword` "debian" & user `User.hasInsecurePassword` "debian" & XFCE.installedMin - & XFCE.defaultPanelFor user + & XFCE.defaultPanelFor user OverwriteExisting & LightDM.autoLogin user & Apt.installed ["firefox"] where diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index a1b9d7d7..e0c062ae 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -15,13 +15,12 @@ installedMin :: Property DebianLike installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] `describe` "minimal XFCE desktop installed" +data Overwrite = OverwriteExisting | PreserveExisting + -- | Normally at first login, XFCE asks what kind of panel the user wants. -- This enables the default configuration noninteractively. --- --- If the user subsequently modifies their panel, their modifications will --- not be overwritten by this property. -defaultPanelFor :: User -> Property DebianLike -defaultPanelFor u@(User username) = property' desc $ \w -> do +defaultPanelFor :: User -> Overwrite -> Property DebianLike +defaultPanelFor u@(User username) overwrite = property' desc $ \w -> do home <- liftIO $ User.homedir u ensureProperty w (go home) where @@ -31,10 +30,13 @@ defaultPanelFor u@(User username) = property' desc $ \w -> do -- This location is probably Debian-specific. defcf = "/etc/xdg/xfce4/panel/default.xml" go :: FilePath -> Property DebianLike - go home = tightenTargets $ check (not <$> doesFileExist cf) $ + go home = tightenTargets $ checkoverwrite cf cf `File.isCopyOf` defcf `before` File.applyPath home basecf (\f -> File.ownerGroup f u (userGroup u)) `requires` Apt.installed ["xfce4-panel"] where cf = home basecf + checkoverwrite cf p = case overwrite of + OverwriteExisting -> p + PreserveExisting -> check (not <$> doesFileExist cf) p -- cgit v1.3-2-g0d8e From 0d15c3f01a424e021481c9630441997c032cbc82 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 16:57:03 -0400 Subject: Added File.checkOverwrite. This commit was sponsored by Ethan Aubin. --- debian/changelog | 1 + joeyconfig.hs | 2 +- src/Propellor/Property/File.hs | 9 +++++++++ src/Propellor/Property/XFCE.hs | 20 +++++++------------- 4 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/debian/changelog b/debian/changelog index 7917bbf6..ea9f43bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ propellor (4.1.0) UNRELEASED; urgency=medium * Propellor.Property.XFCE added with some useful properties for the desktop environment. * Added File.applyPath property. + * Added File.checkOverwrite. * File.isCopyOf: Fix bug that prevented this property from working when the destination file did not yet exist. diff --git a/joeyconfig.hs b/joeyconfig.hs index 20e73cef..4286097b 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -118,7 +118,7 @@ demo = host "demo" $ props & root `User.hasInsecurePassword` "debian" & user `User.hasInsecurePassword` "debian" & XFCE.installedMin - & XFCE.defaultPanelFor user OverwriteExisting + & XFCE.defaultPanelFor user File.OverwriteExisting & LightDM.autoLogin user & Apt.installed ["firefox"] where diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs index 8d10b94c..3293599a 100644 --- a/src/Propellor/Property/File.hs +++ b/src/Propellor/Property/File.hs @@ -307,3 +307,12 @@ readConfigFileName = readish . unescape Nothing -> '_' : ns ++ unescape cs' Just n -> chr n : unescape cs' unescape (c:cs) = c : unescape cs + +data Overwrite = OverwriteExisting | PreserveExisting + +-- | When passed PreserveExisting, only ensures the property when the file +-- does not exist. +checkOverwrite :: Overwrite -> FilePath -> (FilePath -> Property i) -> Property i +checkOverwrite OverwriteExisting f mkp = mkp f +checkOverwrite PreserveExisting f mkp = + check (not <$> doesFileExist f) (mkp f) diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index e0c062ae..6241326e 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -15,11 +15,9 @@ installedMin :: Property DebianLike installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] `describe` "minimal XFCE desktop installed" -data Overwrite = OverwriteExisting | PreserveExisting - -- | Normally at first login, XFCE asks what kind of panel the user wants. -- This enables the default configuration noninteractively. -defaultPanelFor :: User -> Overwrite -> Property DebianLike +defaultPanelFor :: User -> File.Overwrite -> Property DebianLike defaultPanelFor u@(User username) overwrite = property' desc $ \w -> do home <- liftIO $ User.homedir u ensureProperty w (go home) @@ -30,13 +28,9 @@ defaultPanelFor u@(User username) overwrite = property' desc $ \w -> do -- This location is probably Debian-specific. defcf = "/etc/xdg/xfce4/panel/default.xml" go :: FilePath -> Property DebianLike - go home = tightenTargets $ checkoverwrite cf - cf `File.isCopyOf` defcf - `before` File.applyPath home basecf - (\f -> File.ownerGroup f u (userGroup u)) - `requires` Apt.installed ["xfce4-panel"] - where - cf = home basecf - checkoverwrite cf p = case overwrite of - OverwriteExisting -> p - PreserveExisting -> check (not <$> doesFileExist cf) p + go home = tightenTargets $ + File.checkOverwrite overwrite (home basecf) $ \cf -> + cf `File.isCopyOf` defcf + `before` File.applyPath home basecf + (\f -> File.ownerGroup f u (userGroup u)) + `requires` Apt.installed ["xfce4-panel"] -- cgit v1.3-2-g0d8e From 3451ca8beeb58a3bdd864cd1009ba9f0e314b442 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2017 17:27:57 -0400 Subject: add XFCE.networkManager --- joeyconfig.hs | 3 ++- src/Propellor/Property/XFCE.hs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Property/XFCE.hs') diff --git a/joeyconfig.hs b/joeyconfig.hs index 37b8fafb..1be4ff14 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -118,9 +118,10 @@ demo = host "demo" $ props & root `User.hasInsecurePassword` "debian" & user `User.hasInsecurePassword` "debian" & XFCE.installedMin + & XFCE.networkManager & XFCE.defaultPanelFor user File.OverwriteExisting & LightDM.autoLogin user - & Apt.installed ["network-manager", "network-manager-gnome", "firefox"] + & Apt.installed ["firefox"] where user = User "user" root = User "root" diff --git a/src/Propellor/Property/XFCE.hs b/src/Propellor/Property/XFCE.hs index 6241326e..dc57660f 100644 --- a/src/Propellor/Property/XFCE.hs +++ b/src/Propellor/Property/XFCE.hs @@ -10,11 +10,16 @@ installed = Apt.installed ["task-xfce-desktop"] `describe` "XFCE desktop installed" -- | Minimal install of XFCE, with a terminal emulator and panel, --- and X, but not any of the extras. +-- and X and network-manager, but not any of the extra apps. installedMin :: Property DebianLike installedMin = Apt.installedMin ["xfce4", "xfce4-terminal", "task-desktop"] `describe` "minimal XFCE desktop installed" +-- | Installs network-manager-gnome, which is the way to get +-- network-manager to manage networking in XFCE too. +networkManager :: Property DebianLike +networkManager = Apt.installedMin ["network-manager-gnome"] + -- | Normally at first login, XFCE asks what kind of panel the user wants. -- This enables the default configuration noninteractively. defaultPanelFor :: User -> File.Overwrite -> Property DebianLike -- cgit v1.3-2-g0d8e