summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2015-01-23 01:29:47 -0400
committerJoey Hess2015-01-23 01:30:50 -0400
commit38eec6fc37054df1838be905670e1ed1ff308a65 (patch)
tree0851d9604f51028a493f165eba7588d8f0bbcf3a
parente4511a78baa2c5aa93d02fa2296aeb04ac5647e5 (diff)
OS.preserveNetwork finally written
-rw-r--r--debian/changelog1
-rw-r--r--src/Propellor/Property/OS.hs15
2 files changed, 14 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 18a8a366..3d3e9e07 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ propellor (1.4.0) UNRELEASED; urgency=medium
* Added systemd configuration properties.
* Added journald configuration properties.
* Added more network interface configuration properties.
+ * Implemented OS.preserveNetwork.
-- Joey Hess <id@joeyh.name> Thu, 15 Jan 2015 20:14:29 -0400
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