summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Network.hs
diff options
context:
space:
mode:
authorJoey Hess2015-01-22 16:10:22 -0400
committerJoey Hess2015-01-22 16:10:22 -0400
commitbbac84590008ed4295a7de2693d9a3b055baa8e6 (patch)
treed24190c6948ef2092ee75983a73cebb9cb136c18 /src/Propellor/Property/Network.hs
parent4d34b837d2d81c76a50e8b7f1d31c80af3238f36 (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/Network.hs')
-rw-r--r--src/Propellor/Property/Network.hs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/Propellor/Property/Network.hs b/src/Propellor/Property/Network.hs
index 6009778a..c557d453 100644
--- a/src/Propellor/Property/Network.hs
+++ b/src/Propellor/Property/Network.hs
@@ -3,28 +3,32 @@ module Propellor.Property.Network where
import Propellor
import Propellor.Property.File
+type Interface = String
+
interfaces :: FilePath
interfaces = "/etc/network/interfaces"
+interfaceFile :: Interface -> FilePath
+interfaceFile iface = "/etc/network/interfaces.d" </> iface
+
+-- | Enable source-directory interfaces.d
+interfacesD :: Property
+interfacesD = containsLine interfaces "source-directory interfaces.d"
+ `describe` "interfaces.d directory enabled"
+
-- | 6to4 ipv6 connection, should work anywhere
ipv6to4 :: Property
-ipv6to4 = fileProperty "ipv6to4" go interfaces
+ipv6to4 = hasContent (interfaceFile "sit0")
+ [ "# Automatically added by propeller"
+ , "iface sit0 inet6 static"
+ , "\taddress 2002:5044:5531::1"
+ , "\tnetmask 64"
+ , "\tgateway ::192.88.99.1"
+ , "auto sit0"
+ ]
+ `describe` "ipv6to4"
+ `requires` interfacesD
`onChange` ifUp "sit0"
- where
- go ls
- | all (`elem` ls) stanza = ls
- | otherwise = ls ++ stanza
- stanza =
- [ "# Automatically added by propeller"
- , "iface sit0 inet6 static"
- , "\taddress 2002:5044:5531::1"
- , "\tnetmask 64"
- , "\tgateway ::192.88.99.1"
- , "auto sit0"
- , "# End automatically added by propeller"
- ]
-
-type Interface = String
ifUp :: Interface -> Property
ifUp iface = cmdProperty "ifup" [iface]