summaryrefslogtreecommitdiff
path: root/Property
diff options
context:
space:
mode:
authorJoey Hess2014-03-30 15:53:35 -0400
committerJoey Hess2014-03-30 15:53:35 -0400
commita2a3d3f3a252e64d80421b5a14ef572a7bdf9e4a (patch)
tree98ba2b94f011824e591bee66b3f113c52061f48a /Property
parent90efcd3203d64c2c5691e30ccc23307aae8d20c8 (diff)
better descriptions for properties
Diffstat (limited to 'Property')
-rw-r--r--Property/Apt.hs18
-rw-r--r--Property/Reboot.hs1
-rw-r--r--Property/Tor.hs1
-rw-r--r--Property/User.hs7
4 files changed, 21 insertions, 6 deletions
diff --git a/Property/Apt.hs b/Property/Apt.hs
index a5720e72..724d5843 100644
--- a/Property/Apt.hs
+++ b/Property/Apt.hs
@@ -59,19 +59,23 @@ runApt ps = cmdProperty' "apt-get" ps env
update :: Property
update = runApt [Param "update"]
+ `describe` "apt update"
upgrade :: Property
upgrade = runApt [Params "-y dist-upgrade"]
+ `describe` "apt dist-upgrade"
type Package = String
installed :: [Package] -> Property
installed ps = check (isInstallable ps) go
+ `describe` (unwords $ "apt installed":ps)
where
go = runApt $ [Param "-y", Param "install"] ++ map Param ps
removed :: [Package] -> Property
removed ps = check (or <$> isInstalled ps) go
+ `describe` (unwords $ "apt removed":ps)
where
go = runApt $ [Param "-y", Param "remove"] ++ map Param ps
@@ -95,18 +99,24 @@ isInstalled ps = catMaybes . map parse . lines
autoRemove :: Property
autoRemove = runApt [Param "-y", Param "autoremove"]
+ `describe` "apt autoremove"
unattendedUpgrades :: Bool -> Property
-unattendedUpgrades enabled = installed ["unattended-upgrades"]
+unattendedUpgrades enabled =
+ (if enabled then installed else removed) ["unattended-upgrades"]
`onChange` reConfigure "unattended-upgrades"
- [("unattended-upgrades/enable_auto_updates"
- , "boolean"
- , if enabled then "true" else "false")]
+ [("unattended-upgrades/enable_auto_updates" , "boolean", v)]
+ `describe` ("unattended upgrades " ++ v)
+ where
+ v
+ | enabled = "true"
+ | otherwise = "false"
{- Preseeds debconf values and reconfigures the package so it takes
- effect. -}
reConfigure :: Package -> [(String, String, String)] -> Property
reConfigure package vals = reconfigure `requires` setselections
+ `describe` ("reconfigure " ++ package)
where
setselections = Property "preseed" $ makeChange $
withHandle StdinHandle createProcessSuccess
diff --git a/Property/Reboot.hs b/Property/Reboot.hs
index 79aa6010..9b06f07c 100644
--- a/Property/Reboot.hs
+++ b/Property/Reboot.hs
@@ -4,3 +4,4 @@ import Common
now :: Property
now = cmdProperty "reboot" []
+ `describe` "reboot now"
diff --git a/Property/Tor.hs b/Property/Tor.hs
index a4184edf..f7182120 100644
--- a/Property/Tor.hs
+++ b/Property/Tor.hs
@@ -6,6 +6,7 @@ import qualified Property.Apt as Apt
isBridge :: Property
isBridge = setup `requires` Apt.installed ["tor"]
+ `describe` "tor bridge"
where
setup = "/etc/tor/torrc" `File.hasContent`
[ "SocksPort 0"
diff --git a/Property/User.hs b/Property/User.hs
index 733e26ea..8903a9e7 100644
--- a/Property/User.hs
+++ b/Property/User.hs
@@ -6,12 +6,13 @@ import Common
type UserName = String
-nonsystem :: UserName -> Property
-nonsystem user = check (isNothing <$> homedir user) $ cmdProperty "adduser"
+sshAccountFor :: UserName -> Property
+sshAccountFor user = check (isNothing <$> homedir user) $ cmdProperty "adduser"
[ Param "--disabled-password"
, Param "--gecos", Param ""
, Param user
]
+ `describe` ("ssh account " ++ user)
{- Removes user home directory!! Use with caution. -}
nuked :: UserName -> Property
@@ -19,12 +20,14 @@ nuked user = check (isJust <$> homedir user) $ cmdProperty "userdel"
[ Param "-r"
, Param user
]
+ `describe` ("nuked user " ++ user)
lockedPassword :: UserName -> Property
lockedPassword user = check (not <$> isLockedPassword user) $ cmdProperty "passwd"
[ Param "--lock"
, Param user
]
+ `describe` ("locked " ++ user ++ " password")
isLockedPassword :: UserName -> IO Bool
isLockedPassword user = parse . words <$> readProcess "passwd" ["-S", user]