From 2f4340bb1b235f6aec9a6a28233ee28d82b499a3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 20 Sep 2015 14:49:15 -0400 Subject: a few improvements --- src/Propellor/Property/Aiccu.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/Propellor/Property/Aiccu.hs') 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 -- cgit v1.2.3