summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Aiccu.hs
diff options
context:
space:
mode:
authorJoey Hess2015-09-20 14:49:15 -0400
committerJoey Hess2015-09-20 14:49:15 -0400
commit2f4340bb1b235f6aec9a6a28233ee28d82b499a3 (patch)
tree73f73676772ab232c20bd0d305bc5269d5a2e368 /src/Propellor/Property/Aiccu.hs
parent9aa06bcaa93cb2f2a9debe360cd64a9e930c6cdf (diff)
a few improvements
Diffstat (limited to 'src/Propellor/Property/Aiccu.hs')
-rw-r--r--src/Propellor/Property/Aiccu.hs32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/Propellor/Property/Aiccu.hs b/src/Propellor/Property/Aiccu.hs
index e6d4f7fe..e3070c90 100644
--- a/src/Propellor/Property/Aiccu.hs
+++ b/src/Propellor/Property/Aiccu.hs
@@ -1,12 +1,29 @@
-module Propellor.Property.Aiccu where
+module Propellor.Property.Aiccu (
+ installed,
+ reloaded,
+ confPath,
+ UserName,
+ TunnelId,
+ hasConfig,
+) where
import Propellor
import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Service as Service
+import qualified Propellor.Property.File as File
+
+installed :: Property NoInfo
+installed = Apt.installed ["aiccu"]
+
+reloaded :: Property NoInfo
+reloaded = Service.reloaded "aiccu"
confPath :: FilePath
confPath = "/etc/aiccu.conf"
-config :: String -> String -> PrivData -> [String]
+type TunnelId = String
+
+config :: UserName -> TunnelId -> PrivData -> [File.Line]
config u t p =
[ "protocol tic"
, "server tic.sixxs.net"
@@ -20,10 +37,13 @@ config u t p =
, "makebeats true"
]
-hasConfig :: String -> String -> Property HasInfo
-hasConfig t u = withSomePrivData [(Password (u++"/"++t)), (Password u)] (Context "aiccu") $ property "aiccu configured" . writeConfig
+-- | Configures an ipv6 tunnel using sixxs.net, with the given TunneId
+-- and sixx.net UserName.
+hasConfig :: TunnelId -> UserName -> Property HasInfo
+hasConfig t u = withSomePrivData [(Password (u++"/"++t)), (Password u)] (Context "aiccu") $
+ property "aiccu configured" . writeConfig
where
writeConfig :: (((PrivDataField, PrivData) -> Propellor Result) -> Propellor Result) -> Propellor Result
- writeConfig getpassword = getpassword $ go
- go (Password u', p) = makeChange $ writeFile confPath (unlines $ config u' t p)
+ writeConfig getpassword = getpassword $ ensureProperty . go
+ go (Password u', p) = confPath `File.hasContent` config u' t p
go (f, _) = error $ "Unexpected type of privdata: " ++ show f