summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Fstab.hs
diff options
context:
space:
mode:
authorJoey Hess2017-05-20 09:28:22 -0400
committerJoey Hess2017-05-20 09:28:22 -0400
commit24e789a2ac981b3d4b2dfaf1af359c4407587a00 (patch)
treee676038cd69b8ff91efc3b7b5a85e63aad5214d4 /src/Propellor/Property/Fstab.hs
parentd499d8d668fa8ec32833edb4b7a5677dcbf75c56 (diff)
parent3dd36f7e922b0dfdde54420a931e77fd02e6b83c (diff)
Merge branch 'joeyconfig' of ssh://propellor.branchable.com into joeyconfig
Diffstat (limited to 'src/Propellor/Property/Fstab.hs')
-rw-r--r--src/Propellor/Property/Fstab.hs29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/Propellor/Property/Fstab.hs b/src/Propellor/Property/Fstab.hs
index 60f11d8e..29b85426 100644
--- a/src/Propellor/Property/Fstab.hs
+++ b/src/Propellor/Property/Fstab.hs
@@ -24,19 +24,32 @@ import Utility.Table
-- Note that if anything else is already mounted at the `MountPoint`, it
-- will be left as-is by this property.
mounted :: FsType -> Source -> MountPoint -> MountOpts -> Property Linux
-mounted fs src mnt opts = tightenTargets $
- "/etc/fstab" `File.containsLine` l
- `describe` (mnt ++ " mounted by fstab")
+mounted fs src mnt opts = tightenTargets $
+ listed fs src mnt opts
`onChange` mountnow
where
- l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno]
- dump = "0"
- passno = "2"
-- This use of mountPoints, which is linux-only, is why this
-- property currently only supports linux.
mountnow = check (notElem mnt <$> mountPoints) $
cmdProperty "mount" [mnt]
+-- | Ensures that </etc/fstab> contains a line mounting the specified
+-- `Source` on the specified `MountPoint`. Does not ensure that it's
+-- currently `mounted`.
+listed :: FsType -> Source -> MountPoint -> MountOpts -> Property UnixLike
+listed fs src mnt opts = "/etc/fstab" `File.containsLine` l
+ `describe` (mnt ++ " mounted by fstab")
+ where
+ l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno]
+ dump = "0"
+ passno = "2"
+
+-- | Ensures that </etc/fstab> contains a line enabling the specified
+-- `Source` to be used as swap space, and that it's enabled.
+swap :: Source -> Property Linux
+swap src = listed "swap" src "none" mempty
+ `onChange` swapOn src
+
newtype SwapPartition = SwapPartition FilePath
-- | Replaces </etc/fstab> with a file that should cause the currently
@@ -77,8 +90,8 @@ genFstab mnts swaps mnttransform = do
, pure "0"
, pure (if mnt == "/" then "1" else "2")
]
- getswapcfg (SwapPartition swap) = sequence
- [ fromMaybe swap <$> getM (\a -> a swap)
+ getswapcfg (SwapPartition s) = sequence
+ [ fromMaybe s <$> getM (\a -> a s)
[ uuidprefix getSourceUUID
, sourceprefix getSourceLabel
]