From 7a0074454bbae2506c102a57add9af17a32907cc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 10 Apr 2014 03:06:35 -0400 Subject: propellor spin --- Propellor/Property/File.hs | 10 ++++++++++ Propellor/Property/Git.hs | 3 ++- Propellor/Types.hs | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'Propellor') diff --git a/Propellor/Property/File.hs b/Propellor/Property/File.hs index 0c1155fe..64dce66f 100644 --- a/Propellor/Property/File.hs +++ b/Propellor/Property/File.hs @@ -58,3 +58,13 @@ fileProperty desc a f = Property desc $ go =<< doesFileExist f dirExists :: FilePath -> Property dirExists d = check (not <$> doesDirectoryExist d) $ Property (d ++ " exists") $ makeChange $ createDirectoryIfMissing True d + +-- | Ensures that a file/dir has the specified owner and group. +ownerGroup :: FilePath -> UserName -> GroupName -> Property +ownerGroup f owner group = Property (f ++ " owner " ++ og) $ do + r <- ensureProperty $ cmdProperty "chown" [og, f] + if r == FailedChange + then return r + else noChange + where + og = owner ++ ":" ++ group diff --git a/Propellor/Property/Git.hs b/Propellor/Property/Git.hs index 356ff87a..c0494160 100644 --- a/Propellor/Property/Git.hs +++ b/Propellor/Property/Git.hs @@ -22,7 +22,8 @@ daemonRunning exportdir = RevertableProperty setup unsetup `requires` Apt.serviceInstalledRunning "openbsd-inetd" `onChange` - Service.reloaded "openbsd-inetd" + Service.running "openbsd-inetd" + `describe` ("git-daemon exporting " ++ exportdir) unsetup = lacksLine conf (mkl "tcp4") `requires` lacksLine conf (mkl "tcp6") diff --git a/Propellor/Types.hs b/Propellor/Types.hs index c6be30c4..3be10d3f 100644 --- a/Propellor/Types.hs +++ b/Propellor/Types.hs @@ -4,6 +4,7 @@ import Data.Monoid import System.Console.ANSI type HostName = String +type GroupName = String type UserName = String data Property = Property -- cgit v1.2.3