summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2015-01-23 01:29:47 -0400
committerJoey Hess2015-01-23 01:30:50 -0400
commit38eec6fc37054df1838be905670e1ed1ff308a65 (patch)
tree0851d9604f51028a493f165eba7588d8f0bbcf3a /src/Propellor
parente4511a78baa2c5aa93d02fa2296aeb04ac5647e5 (diff)
OS.preserveNetwork finally written
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/OS.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index b60151e8..c1b085a6 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -10,6 +10,7 @@ module Propellor.Property.OS (
import Propellor
import qualified Propellor.Property.Debootstrap as Debootstrap
import qualified Propellor.Property.Ssh as Ssh
+import qualified Propellor.Property.Network as Network
import qualified Propellor.Property.User as User
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Reboot as Reboot
@@ -51,7 +52,7 @@ import Control.Exception (throw)
-- > `onChange` propertyList "fixing up after clean install"
-- > [ preserveNetwork
-- > , preserveResolvConf
--- > , preserverRootSshAuthorized
+-- > , preserveRootSshAuthorized
-- > , Apt.update
-- > -- , Grub.boots "/dev/sda"
-- > -- `requires` Grub.installed Grub.PC
@@ -192,7 +193,17 @@ confirmed desc (Confirmed c) = property desc $ do
-- interface that currently has a default route configured, using
-- the same (static) IP address.
preserveNetwork :: Property
-preserveNetwork = undefined -- TODO
+preserveNetwork = go `requires` Network.cleanInterfacesFile
+ where
+ go = property "preserve network configuration" $ do
+ ls <- liftIO $ lines <$> readProcess "ip"
+ ["route", "list", "scope", "global"]
+ case words <$> headMaybe ls of
+ Just ("default":"via":_:"dev":iface:_) ->
+ ensureProperty $ Network.static iface
+ _ -> do
+ warningMessage "did not find any default ipv4 route"
+ return FailedChange
-- | </etc/resolv.conf> is copied from the old OS
preserveResolvConf :: Property