diff options
Diffstat (limited to 'src/Propellor/Property')
| -rw-r--r-- | src/Propellor/Property/OS.hs | 8 | ||||
| -rw-r--r-- | src/Propellor/Property/Reboot.hs | 28 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs index e84490fd..2185471d 100644 --- a/src/Propellor/Property/OS.hs +++ b/src/Propellor/Property/OS.hs @@ -11,6 +11,7 @@ import Propellor import qualified Propellor.Property.Debootstrap as Debootstrap import qualified Propellor.Property.Ssh as Ssh import qualified Propellor.Property.File as File +import qualified Propellor.Property.Reboot as Reboot import Propellor.Property.Mount import Propellor.Property.Chroot.Util (stdPATH) import Utility.SafeCommand @@ -67,6 +68,8 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $ go = finalized `requires` + Reboot.atEnd True (/= FailedChange) + `requires` propellorbootstrapped `requires` flipped @@ -137,11 +140,6 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $ finalized = property "clean OS installed" $ do liftIO $ writeFile flagfile "" - endAction "rebooting into new OS" $ liftIO $ - ifM (boolSystem "reboot" [ Param "--force" ]) - ( return MadeChange - , return FailedChange - ) return MadeChange flagfile = "/etc/propellor-cleaninstall" diff --git a/src/Propellor/Property/Reboot.hs b/src/Propellor/Property/Reboot.hs index 25e53159..3a725838 100644 --- a/src/Propellor/Property/Reboot.hs +++ b/src/Propellor/Property/Reboot.hs @@ -1,7 +1,29 @@ module Propellor.Property.Reboot where import Propellor +import Utility.SafeCommand -now :: Property -now = cmdProperty "reboot" [] - `describe` "reboot now" +-- | Schedules a reboot at the end of the current propellor run. +-- +-- The Result code of the endire propellor run can be checked; +-- the reboot proceeds only if the function returns True. +-- +-- The reboot can be forced to run, which bypasses the init system. Useful +-- if the init system might not be running for some reason. +atEnd :: Bool -> (Result -> Bool) -> Property +atEnd force resultok = property "scheduled reboot at end of propellor run" $ do + endAction "rebooting" atend + return NoChange + where + atend r + | resultok r = liftIO $ + ifM (boolSystem "reboot" rebootparams) + ( return MadeChange + , return FailedChange + ) + | otherwise = do + warningMessage "Not rebooting, due to status of propellor run." + return FailedChange + rebootparams + | force = [Param "--force"] + | otherwise = [] |
