{-# LANGUAGE TypeFamilies #-}
module Propellor.Property.Aiccu (
installed,
restarted,
confPath,
UserName,
TunnelId,
hasConfig,
) where
import Propellor.Base
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.File as File
installed :: Property DebianLike
installed :: Property DebianLike
installed = [Package] -> Property DebianLike
Apt.installed ["aiccu"]
restarted :: Property DebianLike
restarted :: Property DebianLike
restarted = Package -> Property DebianLike
Service.restarted "aiccu"
confPath :: FilePath
confPath :: Package
confPath = "/etc/aiccu.conf"
type TunnelId = String
config :: UserName -> TunnelId -> PrivData -> [File.Line]
config :: Package -> Package -> PrivData -> [Package]
config u :: Package
u t :: Package
t p :: PrivData
p =
[ "protocol tic"
, "server tic.sixxs.net"
, "username " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
u
, "password " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ PrivData -> Package
privDataVal PrivData
p
, "ipv6_interface sixxs"
, "tunnel_id " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
t
, "daemonize true"
, "automatic true"
, "requiretls true"
, "makebeats true"
]
hasConfig :: TunnelId -> UserName -> Property (HasInfo + DebianLike)
hasConfig :: Package -> Package -> Property (HasInfo + DebianLike)
hasConfig t :: Package
t u :: Package
u = Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
Property (HasInfo + UnixLike)
prop Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
-> Property DebianLike
-> CombinedType
(Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
(Property DebianLike)
forall x y. Combines x y => x -> y -> CombinedType x y
`onChange` Property DebianLike
restarted
where
prop :: Property (HasInfo + UnixLike)
prop :: Property (HasInfo + UnixLike)
prop = [PrivDataField]
-> Context
-> ((((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
forall c s metatypes.
(IsContext c, IsPrivDataSource s,
IncludesInfo metatypes ~ 'True) =>
[s]
-> c
-> ((((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result)
-> Property metatypes)
-> Property metatypes
withSomePrivData [(Package -> PrivDataField
Password (Package
uPackage -> Package -> Package
forall a. [a] -> [a] -> [a]
++"/"Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++Package
t)), (Package -> PrivDataField
Password Package
u)] (Package -> Context
Context "aiccu") (((((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
-> Property (HasInfo + UnixLike))
-> ((((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
-> Property (HasInfo + UnixLike)
forall a b. (a -> b) -> a -> b
$ \getpassword :: ((PrivDataField, PrivData) -> Propellor Result) -> Propellor Result
getpassword ->
Package
-> (OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
forall k (metatypes :: k).
SingI metatypes =>
Package
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' "aiccu configured" ((OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
-> (OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
-> Propellor Result)
-> Property
(Sing
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
forall a b. (a -> b) -> a -> b
$ \w :: OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w -> ((PrivDataField, PrivData) -> Propellor Result) -> Propellor Result
getpassword (((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result)
-> ((PrivDataField, PrivData) -> Propellor Result)
-> Propellor Result
forall a b. (a -> b) -> a -> b
$ OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
-> Property UnixLike -> Propellor Result
forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'WithInfo, 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w (Property UnixLike -> Propellor Result)
-> ((PrivDataField, PrivData) -> Property UnixLike)
-> (PrivDataField, PrivData)
-> Propellor Result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PrivDataField, PrivData) -> Property UnixLike
go
go :: (PrivDataField, PrivData) -> Property UnixLike
go (Password u' :: Package
u', p :: PrivData
p) = Package
confPath Package -> [Package] -> Property UnixLike
`File.hasContentProtected` Package -> Package -> PrivData -> [Package]
config Package
u' Package
t PrivData
p
go (f :: PrivDataField
f, _) = Package -> Property UnixLike
forall a. HasCallStack => Package -> a
error (Package -> Property UnixLike) -> Package -> Property UnixLike
forall a b. (a -> b) -> a -> b
$ "Unexpected type of privdata: " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ PrivDataField -> Package
forall a. Show a => a -> Package
show PrivDataField
f