2014-03-31 03:37:54 +00:00
|
|
|
module Propellor.Property.Reboot where
|
2014-03-30 03:24:40 +00:00
|
|
|
|
2014-03-31 03:55:59 +00:00
|
|
|
import Propellor
|
2014-12-06 17:21:19 +00:00
|
|
|
import Utility.SafeCommand
|
2014-03-30 03:24:40 +00:00
|
|
|
|
2015-01-25 02:38:10 +00:00
|
|
|
now :: Property NoInfo
|
2014-12-06 17:32:53 +00:00
|
|
|
now = cmdProperty "reboot" []
|
|
|
|
`describe` "reboot now"
|
|
|
|
|
2014-12-06 17:21:19 +00:00
|
|
|
-- | 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.
|
2015-01-25 02:38:10 +00:00
|
|
|
atEnd :: Bool -> (Result -> Bool) -> Property NoInfo
|
2014-12-06 17:21:19 +00:00
|
|
|
atEnd force resultok = property "scheduled reboot at end of propellor run" $ do
|
|
|
|
endAction "rebooting" atend
|
|
|
|
return NoChange
|
|
|
|
where
|
|
|
|
atend r
|
2014-12-08 05:07:31 +00:00
|
|
|
| resultok r = liftIO $ toResult
|
|
|
|
<$> boolSystem "reboot" rebootparams
|
2014-12-06 17:21:19 +00:00
|
|
|
| otherwise = do
|
|
|
|
warningMessage "Not rebooting, due to status of propellor run."
|
|
|
|
return FailedChange
|
|
|
|
rebootparams
|
|
|
|
| force = [Param "--force"]
|
|
|
|
| otherwise = []
|