From 7a0074454bbae2506c102a57add9af17a32907cc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 10 Apr 2014 03:06:35 -0400 Subject: [PATCH] propellor spin --- Propellor/Property/File.hs | 10 ++++++++++ Propellor/Property/Git.hs | 3 ++- Propellor/Types.hs | 1 + config-joey.hs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Propellor/Property/File.hs b/Propellor/Property/File.hs index 0c1155f..64dce66 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 356ff87..c049416 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 c6be30c..3be10d3 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 diff --git a/config-joey.hs b/config-joey.hs index b4aeebe..d07e12b 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -67,6 +67,7 @@ host hostname@"diatom.kitenet.net" = Just $ props & Apt.installed ["git", "git-annex", "rsync"] & Apt.buildDep ["git-annex"] `period` Daily & Git.daemonRunning "/srv/git" + & File.ownerGroup "/srv/git" "joey" "joey" -- git repos restore (how?) -- kgb installation and setup -- ssh keys for branchable and github repo hooks