summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-12-04 17:05:03 -0400
committerJoey Hess2014-12-04 17:05:03 -0400
commit014af4a5b4a21185e16f7564be00859b3bc4c060 (patch)
tree95739ce9a6f11143b00ae88b29936da680dffb67
parentc57a42388366f4e0bb6195ec4d957f8bc8ebad6e (diff)
propellor spin
-rw-r--r--src/Propellor/Property/OS.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index 603e4593..14e5d85a 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -16,6 +16,8 @@ import qualified Propellor.Property.Ssh as Ssh
import qualified Propellor.Property.User as User
import Propellor.Property.Mount
+import System.Posix.Files (rename, fileExist)
+
-- | Replaces whatever OS was installed before with a clean installation
-- of the OS that the Host is configured to have.
--
@@ -86,12 +88,12 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
rootcontents <- dirContents "/"
forM_ rootcontents $ \d ->
when (d `notElem` (oldOSDir:newOSDir:trickydirs)) $
- renameDirectory d (oldOSDir ++ d)
+ rename d (oldOSDir ++ d)
newrootcontents <- dirContents newOSDir
forM_ newrootcontents $ \d -> do
let dest = "/" ++ takeFileName d
- whenM (not <$> doesDirectoryExist dest) $
- renameDirectory d dest
+ whenM (not <$> fileExist dest) $
+ rename d dest
removeDirectory newOSDir
return MadeChange