From 2e42b9db53ecf8cc33d92e2374e0d5ca24013a85 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Oct 2015 11:42:59 -0400 Subject: propellor spin --- config-joey.hs | 1 + src/Propellor/Property/DiskImage.hs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index 81e97af4..6ec80f92 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -91,6 +91,7 @@ darkstar = host "darkstar.kitenet.net" where c d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d & Apt.installed ["linux-image-amd64"] + & User "root" `User.hasInsecurePassword` "root" gnu :: Host gnu = host "gnu.kitenet.net" diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index 56ee2a8c..af8a020b 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -47,7 +47,7 @@ import Propellor.Property.Partition import Propellor.Property.Rsync import Utility.Path -import Data.List (isPrefixOf, sortBy) +import Data.List (isPrefixOf, isInfixOf, sortBy) import Data.Function (on) import qualified Data.Map.Strict as M import qualified Data.ByteString.Lazy as L @@ -309,6 +309,10 @@ imageFinalized (_, final) mnts devs (PartTable _ parts) = -- comes before /usr/local orderedmntsdevs :: [(Maybe MountPoint, LoopDev)] orderedmntsdevs = sortBy (compare `on` fst) $ zip mnts devs + + swaps = map (SwapPartition . partitionLoopDev . snd) $ + filter ((== LinuxSwap) . partFs . fst) $ + zip parts devs mountall top = forM_ orderedmntsdevs $ \(mp, loopdev) -> case mp of Nothing -> noop @@ -323,13 +327,13 @@ imageFinalized (_, final) mnts devs (PartTable _ parts) = umountLazy top writefstab top = do - old <- catchDefaultIO "" $ readFileStrict "/etc/fstab" + old <- catchDefaultIO [] $ filter (not . unconfigured) . lines + <$> readFileStrict (top ++ "/etc/fstab") new <- genFstab (map (top ++) (catMaybes mnts)) swaps (toSysDir top) - writeFile "/etc/fstab" (unlines new ++ old) - swaps = map (SwapPartition . partitionLoopDev . snd) $ - filter ((== LinuxSwap) . partFs . fst) $ - zip parts devs + writeFile "/etc/fstab" $ unlines $ new ++ old + -- Eg "UNCONFIGURED FSTAB FOR BASE SYSTEM" + unconfigured s = "UNCONFIGURED" `isInfixOf` s noFinalization :: Finalization noFinalization = (doNothing, \_ _ -> doNothing) -- cgit v1.2.3