propellor

propellor config for hosts.
git clone git://git.ricketyspace.net/propellor.git
Log | Files | Refs | LICENSE

Aiccu.hs (1457B)


      1 {-# LANGUAGE TypeFamilies #-}
      2 
      3 -- | Maintainer: Jelmer Vernooij <jelmer@samba.org>
      4 
      5 module Propellor.Property.Aiccu (
      6 	installed,
      7 	restarted,
      8 	confPath,
      9 	UserName,
     10 	TunnelId,
     11 	hasConfig,
     12 ) where
     13 
     14 import Propellor.Base
     15 import qualified Propellor.Property.Apt as Apt
     16 import qualified Propellor.Property.Service as Service
     17 import qualified Propellor.Property.File as File
     18 
     19 installed :: Property DebianLike
     20 installed = Apt.installed ["aiccu"]
     21 
     22 restarted :: Property DebianLike
     23 restarted = Service.restarted "aiccu"
     24 
     25 confPath :: FilePath
     26 confPath = "/etc/aiccu.conf"
     27 
     28 type TunnelId = String
     29 
     30 config :: UserName -> TunnelId -> PrivData -> [File.Line]
     31 config u t p = 
     32 	[ "protocol tic"
     33 	, "server tic.sixxs.net"
     34 	, "username " ++ u
     35 	, "password " ++ privDataVal p
     36 	, "ipv6_interface sixxs"
     37 	, "tunnel_id " ++ t
     38 	, "daemonize true"
     39 	, "automatic true"
     40 	, "requiretls true"
     41 	, "makebeats true"
     42 	]
     43 
     44 -- | Configures an ipv6 tunnel using sixxs.net, with the given TunneId
     45 -- and sixx.net UserName.
     46 hasConfig :: TunnelId -> UserName -> Property (HasInfo + DebianLike)
     47 hasConfig t u = prop `onChange` restarted
     48   where
     49   	prop :: Property (HasInfo + UnixLike)
     50 	prop = withSomePrivData [(Password (u++"/"++t)), (Password u)] (Context "aiccu") $ \getpassword ->
     51 		property' "aiccu configured" $ \w -> getpassword $ ensureProperty w . go
     52 	go (Password u', p) = confPath `File.hasContentProtected` config u' t p
     53 	go (f, _) = error $ "Unexpected type of privdata: " ++ show f