summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Apache.hs
diff options
context:
space:
mode:
authorJoey Hess2015-10-10 12:43:28 -0400
committerJoey Hess2015-10-10 12:43:28 -0400
commite011925ed89687df29c3a3a53a12357e8a5d42b1 (patch)
tree56004d57a4965fe6572cedd393e4b7084ac33a7c /src/Propellor/Property/Apache.hs
parent62ad133081963d9c4b41d35c9030feaa2ae3b6fc (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/Apache.hs')
-rw-r--r--src/Propellor/Property/Apache.hs25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs
index fe81dcd8..49e3d525 100644
--- a/src/Propellor/Property/Apache.hs
+++ b/src/Propellor/Property/Apache.hs
@@ -7,6 +7,20 @@ import qualified Propellor.Property.Service as Service
type ConfigFile = [String]
+-- | A basic virtual host, publishing a directory, and logging to
+-- the combined apache log file.
+virtualHost :: HostName -> Port -> FilePath -> RevertableProperty
+virtualHost hn (Port p) docroot = siteEnabled hn
+ [ "<VirtualHost *:"++show p++">"
+ , "ServerName "++hn++":"++show p
+ , "DocumentRoot " ++ docroot
+ , "ErrorLog /var/log/apache2/error.log"
+ , "LogLevel warn"
+ , "CustomLog /var/log/apache2/access.log combined"
+ , "ServerSignature On"
+ , "</VirtualHost>"
+ ]
+
siteEnabled :: HostName -> ConfigFile -> RevertableProperty
siteEnabled hn cf = enable <!> disable
where
@@ -19,13 +33,16 @@ siteEnabled hn cf = enable <!> disable
`requires` installed
`onChange` reloaded
]
- disable = combineProperties
- ("apache site disabled " ++ hn)
- (map File.notPresent (siteCfg hn))
+ disable = siteDisabled hn
+ isenabled = boolSystem "a2query" [Param "-q", Param "-s", Param hn]
+
+siteDisabled :: HostName -> Property NoInfo
+siteDisabled hn = combineProperties
+ ("apache site disabled " ++ hn)
+ (map File.notPresent (siteCfg hn))
`onChange` cmdProperty "a2dissite" ["--quiet", hn]
`requires` installed
`onChange` reloaded
- isenabled = boolSystem "a2query" [Param "-q", Param "-s", Param hn]
siteAvailable :: HostName -> ConfigFile -> Property NoInfo
siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $