summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2014-12-09 00:05:34 -0400
committerJoey Hess2014-12-09 00:05:34 -0400
commit57520809299789956479256f68119a3043cf2f9a (patch)
treeeed478c5d3686e5504fecbead9fa47bfc9630e6e /src
parent9841594c852bd7a663c25b961df11400557502f5 (diff)
parent040a5fe3c75930f08667369357a77ededf815c5a (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/Debootstrap.hs10
-rw-r--r--src/Propellor/Property/Service.hs17
2 files changed, 11 insertions, 16 deletions
diff --git a/src/Propellor/Property/Debootstrap.hs b/src/Propellor/Property/Debootstrap.hs
index 0181d58a..0a7308ff 100644
--- a/src/Propellor/Property/Debootstrap.hs
+++ b/src/Propellor/Property/Debootstrap.hs
@@ -148,18 +148,16 @@ sourceInstall = property "debootstrap installed from source" (liftIO sourceInsta
`requires` arInstalled
perlInstalled :: Property
-perlInstalled = check (not <$> inPath "perl") $ property "perl installed" $ do
- v <- liftIO $ firstM id
+perlInstalled = check (not <$> inPath "perl") $ property "perl installed" $
+ liftIO $ toResult . isJust <$> firstM id
[ yumInstall "perl"
]
- if isJust v then return MadeChange else return FailedChange
arInstalled :: Property
-arInstalled = check (not <$> inPath "ar") $ property "ar installed" $ do
- v <- liftIO $ firstM id
+arInstalled = check (not <$> inPath "ar") $ property "ar installed" $
+ liftIO $ toResult . isJust <$> firstM id
[ yumInstall "binutils"
]
- if isJust v then return MadeChange else return FailedChange
yumInstall :: String -> IO Bool
yumInstall p = boolSystem "yum" [Param "-y", Param "install", Param p]
diff --git a/src/Propellor/Property/Service.hs b/src/Propellor/Property/Service.hs
index 14e769d0..93e959c6 100644
--- a/src/Propellor/Property/Service.hs
+++ b/src/Propellor/Property/Service.hs
@@ -13,19 +13,16 @@ type ServiceName = String
-- we can do is try to start the service, and if it fails, assume
-- this means it's already running.
running :: ServiceName -> Property
-running svc = property ("running " ++ svc) $ do
- void $ ensureProperty $
- scriptProperty ["service " ++ shellEscape svc ++ " start >/dev/null 2>&1 || true"]
- return NoChange
+running = signaled "start" "running"
restarted :: ServiceName -> Property
-restarted svc = property ("restarted " ++ svc) $ do
- void $ ensureProperty $
- scriptProperty ["service " ++ shellEscape svc ++ " restart >/dev/null 2>&1 || true"]
- return NoChange
+restarted = signaled "restart" "restarted"
reloaded :: ServiceName -> Property
-reloaded svc = property ("reloaded " ++ svc) $ do
+reloaded = signaled "reload" "reloaded"
+
+signaled :: String -> Desc -> ServiceName -> Property
+signaled cmd desc svc = property (desc ++ " " ++ svc) $ do
void $ ensureProperty $
- scriptProperty ["service " ++ shellEscape svc ++ " reload >/dev/null 2>&1 || true"]
+ scriptProperty ["service " ++ shellEscape svc ++ " " ++ cmd ++ " >/dev/null 2>&1 || true"]
return NoChange