summaryrefslogtreecommitdiff
path: root/Propellor/Property/Apache.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-13 14:01:30 -0400
committerJoey Hess2014-04-13 14:01:30 -0400
commit1495db6cd103bf5f9f4635dbbfe807c7c1f39b2e (patch)
treef01d5ee3b99cc9609cdcefb0fc4076c4b9bb5e91 /Propellor/Property/Apache.hs
parentf428ccd9b1fa32fac7415910021be8f51f66857c (diff)
propellor spin
Diffstat (limited to 'Propellor/Property/Apache.hs')
-rw-r--r--Propellor/Property/Apache.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Propellor/Property/Apache.hs b/Propellor/Property/Apache.hs
new file mode 100644
index 00000000..5e32b0da
--- /dev/null
+++ b/Propellor/Property/Apache.hs
@@ -0,0 +1,28 @@
+module Propellor.Property.Apache where
+
+import Propellor
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+
+type ConfigFile = [String]
+
+siteEnabled :: HostName -> ConfigFile -> RevertableProperty
+siteEnabled hn cf = RevertableProperty enable disable
+ where
+ enable = siteAvailable hn cf
+ `onChange` cmdProperty "a2ensite" ["--quiet", hn]
+ `requires` Apt.installed ["apache2"]
+ disable = File.notPresent (siteCfg hn)
+ `onChange` cmdProperty "a2dissite" ["--quiet", hn]
+
+siteAvailable :: HostName -> ConfigFile -> Property
+siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf)
+ `describe` ("apache site available " ++ hn)
+ where
+ comment = "# deployed with propellor, do not modify"
+
+siteCfg :: HostName -> FilePath
+siteCfg hn = "/etc/apache2/sites-available/" ++ hn ++ ".conf"
+
+restart :: Property
+restart = cmdProperty "service" ["apache2", "restart"]