propellor spin
This commit is contained in:
parent
c57a423883
commit
014af4a5b4
|
@ -16,6 +16,8 @@ import qualified Propellor.Property.Ssh as Ssh
|
||||||
import qualified Propellor.Property.User as User
|
import qualified Propellor.Property.User as User
|
||||||
import Propellor.Property.Mount
|
import Propellor.Property.Mount
|
||||||
|
|
||||||
|
import System.Posix.Files (rename, fileExist)
|
||||||
|
|
||||||
-- | Replaces whatever OS was installed before with a clean installation
|
-- | Replaces whatever OS was installed before with a clean installation
|
||||||
-- of the OS that the Host is configured to have.
|
-- of the OS that the Host is configured to have.
|
||||||
--
|
--
|
||||||
|
@ -86,12 +88,12 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
|
||||||
rootcontents <- dirContents "/"
|
rootcontents <- dirContents "/"
|
||||||
forM_ rootcontents $ \d ->
|
forM_ rootcontents $ \d ->
|
||||||
when (d `notElem` (oldOSDir:newOSDir:trickydirs)) $
|
when (d `notElem` (oldOSDir:newOSDir:trickydirs)) $
|
||||||
renameDirectory d (oldOSDir ++ d)
|
rename d (oldOSDir ++ d)
|
||||||
newrootcontents <- dirContents newOSDir
|
newrootcontents <- dirContents newOSDir
|
||||||
forM_ newrootcontents $ \d -> do
|
forM_ newrootcontents $ \d -> do
|
||||||
let dest = "/" ++ takeFileName d
|
let dest = "/" ++ takeFileName d
|
||||||
whenM (not <$> doesDirectoryExist dest) $
|
whenM (not <$> fileExist dest) $
|
||||||
renameDirectory d dest
|
rename d dest
|
||||||
removeDirectory newOSDir
|
removeDirectory newOSDir
|
||||||
return MadeChange
|
return MadeChange
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue