diff options
| author | Félix Sipma <felix.sipma@no-log.org> | 2014-11-10 11:13:06 +0100 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-11-10 11:14:48 -0400 |
| commit | 3541260436da9633145654f36d12a2a047c386fc (patch) | |
| tree | e001274964b1cda93806a5e0ca67fb756411214a /src | |
| parent | f3a31c91922f6386b61c3b3f9c53dfc7f5286d9e (diff) | |
basic prosody support
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Prosody.hs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Propellor/Property/Prosody.hs b/src/Propellor/Property/Prosody.hs new file mode 100644 index 00000000..06e2355f --- /dev/null +++ b/src/Propellor/Property/Prosody.hs @@ -0,0 +1,52 @@ +module Propellor.Property.Prosody where + +import Propellor +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Service as Service +import System.Posix.Files + +type ConfigFile = [String] + +type Conf = String + +confEnabled :: Conf -> ConfigFile -> RevertableProperty +confEnabled conf cf = RevertableProperty enable disable + where + enable = check test prop + `describe` ("prosody conf enabled " ++ conf) + `requires` confAvailable conf cf + `requires` installed + `onChange` reloaded + where + test = not <$> doesFileExist (confValPath conf) + prop = property "prosody conf in place" $ makeChange $ + createSymbolicLink target dir + target = confValRelativePath conf + dir = confValPath conf + confValRelativePath conf' = "../conf.avail" </> conf' <.> "cfg.lua" + disable = trivial $ File.notPresent (confValPath conf) + `describe` ("prosody conf disabled " ++ conf) + `requires` installed + `onChange` reloaded + +confAvailable :: Conf -> ConfigFile -> Property +confAvailable conf cf = ("prosody conf available " ++ conf) ==> + confAvailPath conf `File.hasContent` (comment : cf) + where + comment = "-- deployed with propellor, do not modify" + +confAvailPath :: Conf -> FilePath +confAvailPath conf = "/etc/prosody/conf.avail" </> conf <.> "cfg.lua" + +confValPath :: Conf -> FilePath +confValPath conf = "/etc/prosody/conf.d" </> conf <.> "cfg.lua" + +installed :: Property +installed = Apt.installed ["prosody"] + +restarted :: Property +restarted = Service.restarted "prosody" + +reloaded :: Property +reloaded = Service.reloaded "prosody" |
