From e011925ed89687df29c3a3a53a12357e8a5d42b1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 10 Oct 2015 12:43:28 -0400 Subject: propellor spin --- src/Propellor/Property/Apache.hs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/Propellor') 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 + [ "" + , "ServerName "++hn++":"++show p + , "DocumentRoot " ++ docroot + , "ErrorLog /var/log/apache2/error.log" + , "LogLevel warn" + , "CustomLog /var/log/apache2/access.log combined" + , "ServerSignature On" + , "" + ] + 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) $ -- cgit v1.2.3