summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Aiccu.hs
blob: c6c1569a07278123f6fcf50fb68f26edab66a0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Propellor.Property.Aiccu where

import Propellor
import qualified Propellor.Property.Apt as Apt

confPath :: FilePath
confPath = "/etc/aiccu.conf"

config :: String -> String -> PrivData -> [String]
config u t p = [ "protocol tic"
	       , "server tic.sixxs.net"
	       , "username " ++ u
	       , "password " ++ (privDataVal p)
	       , "ipv6_interface sixxs"
	       , "tunnel_id " ++ t
	       , "daemonize true"
	       , "automatic true"
	       , "requiretls true"
	       , "makebeats true"
	       ]

hasConfig :: String -> String -> 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)
	      go (f, _) = error $ "Unexpected type of privdata: " ++ show f