reboot at end of propellor run when clean os has been installed

This commit is contained in:
Joey Hess 2014-12-06 06:41:21 -04:00
parent fcff7762e3
commit 62697c7b7f
1 changed files with 11 additions and 13 deletions

View File

@ -4,7 +4,6 @@ module Propellor.Property.OS (
preserveNetworkInterfaces, preserveNetworkInterfaces,
preserveResolvConf, preserveResolvConf,
preserveRootSshAuthorized, preserveRootSshAuthorized,
rebootForced,
oldOSRemoved, oldOSRemoved,
) where ) where
@ -35,8 +34,9 @@ import Control.Exception (throw)
-- --
-- The files from the old os will be left in /old-os -- The files from the old os will be left in /old-os
-- --
-- TODO: A forced reboot should be schedued to run after propellor finishes -- After the OS is installed, and if all properties of the host have
-- ensuring all properties of the host. -- been successfully satisfied, the host will be rebooted to properly load
-- the new OS.
-- --
-- You will typically want to run some more properties after the clean -- You will typically want to run some more properties after the clean
-- install succeeds, to bootstrap from the cleanly installed system to -- install succeeds, to bootstrap from the cleanly installed system to
@ -125,7 +125,6 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
unlessM (mount "devpts" "devpts" "/dev/pts") $ unlessM (mount "devpts" "devpts" "/dev/pts") $
warningMessage "failed mounting /dev/pts" warningMessage "failed mounting /dev/pts"
liftIO $ writeFile flagfile ""
return MadeChange return MadeChange
propellorbootstrapped = property "propellor re-debootstrapped in new os" $ propellorbootstrapped = property "propellor re-debootstrapped in new os" $
@ -136,9 +135,14 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
-- be present in /old-os's /usr/local/propellor) -- be present in /old-os's /usr/local/propellor)
-- TODO -- TODO
-- Ensure that MadeChange is returned by the overall property, finalized = property "clean OS installed" $ do
-- so that anything hooking in onChange will run afterwards. liftIO $ writeFile flagfile ""
finalized = property "clean OS installed" $ return MadeChange endAction "rebooting into new OS" $ liftIO $
ifM (boolSystem "reboot" [ Param "--force" ])
( return MadeChange
, return FailedChange
)
return MadeChange
flagfile = "/etc/propellor-cleaninstall" flagfile = "/etc/propellor-cleaninstall"
@ -206,12 +210,6 @@ preserveRootSshAuthorized = check (fileExist oldloc) $
newloc = "/root/.ssh/authorized_keys" newloc = "/root/.ssh/authorized_keys"
oldloc = oldOSDir ++ newloc oldloc = oldOSDir ++ newloc
-- | Forces an immediate reboot, without contacting the init system.
--
-- Can be used after cleanInstallOnce.
rebootForced :: Property
rebootForced = cmdProperty "reboot" [ "--force" ]
-- Removes the old OS's backup from /old-os -- Removes the old OS's backup from /old-os
oldOSRemoved :: Confirmation -> Property oldOSRemoved :: Confirmation -> Property
oldOSRemoved confirmation = check (doesDirectoryExist oldOSDir) $ oldOSRemoved confirmation = check (doesDirectoryExist oldOSDir) $