summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-11-10 11:15:47 -0400
committerJoey Hess2014-11-10 11:15:47 -0400
commite0a47a59d965c06be9f5985db8b9234b5544ca33 (patch)
tree0927c39999eac28a8b21f83972d50c94e58d12b5
parenta6fba965a4dd43546584ee35288abc11045d5af5 (diff)
parent9608a390d2ded501a2b3fcbbb17e968314f1689d (diff)
Merge branch 'joeyconfig'
-rw-r--r--debian/changelog6
-rw-r--r--propellor.cabal9
-rw-r--r--src/Propellor/Property/Prosody.hs52
3 files changed, 63 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 8ef65e0f..f53888b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+propellor (0.9.3) UNRELEASED; urgency=medium
+
+ * Added prosody module, contributed by Félix Sipma.
+
+ -- Joey Hess <joeyh@debian.org> Mon, 10 Nov 2014 11:15:27 -0400
+
propellor (0.9.2) unstable; urgency=medium
* Added nginx module, contributed by Félix Sipma.
diff --git a/propellor.cabal b/propellor.cabal
index a6d00a03..5ec657a9 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -36,11 +36,11 @@ Executable propellor
Main-Is: wrapper.hs
GHC-Options: -Wall -threaded -O0
Hs-Source-Dirs: src
- Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
+ Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
containers, network, async, time, QuickCheck, mtl,
MonadCatchIO-transformers
-
+
if (! os(windows))
Build-Depends: unix
@@ -48,7 +48,7 @@ Executable propellor-config
Main-Is: config.hs
GHC-Options: -Wall -threaded -O0
Hs-Source-Dirs: src
- Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
+ Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
containers, network, async, time, QuickCheck, mtl,
MonadCatchIO-transformers
@@ -59,7 +59,7 @@ Executable propellor-config
Library
GHC-Options: -Wall -O0
Hs-Source-Dirs: src
- Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
+ Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
containers, network, async, time, QuickCheck, mtl,
MonadCatchIO-transformers
@@ -87,6 +87,7 @@ Library
Propellor.Property.Obnam
Propellor.Property.OpenId
Propellor.Property.Postfix
+ Propellor.Property.Prosody
Propellor.Property.Reboot
Propellor.Property.Scheduled
Propellor.Property.Service
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"