summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/OS.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-06 06:41:21 -0400
committerJoey Hess2014-12-06 06:41:21 -0400
commit62697c7b7f7ba2d39bfad632f1cf720c9805bdd2 (patch)
treeacdd5485d5efd4e76eac4a8c1af86074f514634a /src/Propellor/Property/OS.hs
parentfcff7762e395378791f01c9ea8507b41a4d7d501 (diff)
reboot at end of propellor run when clean os has been installed
Diffstat (limited to 'src/Propellor/Property/OS.hs')
-rw-r--r--src/Propellor/Property/OS.hs24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index 22414bb6..e84490fd 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -4,7 +4,6 @@ module Propellor.Property.OS (
preserveNetworkInterfaces,
preserveResolvConf,
preserveRootSshAuthorized,
- rebootForced,
oldOSRemoved,
) where
@@ -35,8 +34,9 @@ import Control.Exception (throw)
--
-- The files from the old os will be left in /old-os
--
--- TODO: A forced reboot should be schedued to run after propellor finishes
--- ensuring all properties of the host.
+-- After the OS is installed, and if all properties of the host have
+-- 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
-- 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") $
warningMessage "failed mounting /dev/pts"
- liftIO $ writeFile flagfile ""
return MadeChange
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)
-- TODO
- -- Ensure that MadeChange is returned by the overall property,
- -- so that anything hooking in onChange will run afterwards.
- finalized = property "clean OS installed" $ return MadeChange
+ 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"
@@ -206,12 +210,6 @@ preserveRootSshAuthorized = check (fileExist oldloc) $
newloc = "/root/.ssh/authorized_keys"
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
oldOSRemoved :: Confirmation -> Property
oldOSRemoved confirmation = check (doesDirectoryExist oldOSDir) $