diff options
Diffstat (limited to 'src/Propellor/Property/Apache.hs')
| -rw-r--r-- | src/Propellor/Property/Apache.hs | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/Propellor/Property/Apache.hs b/src/Propellor/Property/Apache.hs index cf3e62cc..e6930893 100644 --- a/src/Propellor/Property/Apache.hs +++ b/src/Propellor/Property/Apache.hs @@ -10,20 +10,21 @@ type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = RevertableProperty enable disable where - enable = trivial $ cmdProperty "a2ensite" ["--quiet", hn] + enable = trivial (cmdProperty "a2ensite" ["--quiet", hn]) `describe` ("apache site enabled " ++ hn) `requires` siteAvailable hn cf `requires` installed `onChange` reloaded - disable = trivial $ File.notPresent (siteCfg hn) - `describe` ("apache site disabled " ++ hn) + disable = trivial $ combineProperties + ("apache site disabled " ++ hn) + (map File.notPresent (siteCfg hn)) `onChange` cmdProperty "a2dissite" ["--quiet", hn] `requires` installed `onChange` reloaded siteAvailable :: HostName -> ConfigFile -> Property -siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf) - `describe` ("apache site available " ++ hn) +siteAvailable hn cf = combineProperties ("apache site available " ++ hn) $ + map (`File.hasContent` (comment:cf)) (siteCfg hn) where comment = "# deployed with propellor, do not modify" @@ -39,8 +40,15 @@ modEnabled modname = RevertableProperty enable disable `requires` installed `onChange` reloaded -siteCfg :: HostName -> FilePath -siteCfg hn = "/etc/apache2/sites-available/" ++ hn +-- This is a list of config files because different versions of apache +-- use different filenames. Propellor simply writen them all. +siteCfg :: HostName -> [FilePath] +siteCfg hn = + -- Debian pre-2.4 + [ "/etc/apache2/sites-available/" ++ hn + -- Debian 2.4+ + , "/etc/apache2/sites-available/" ++ hn ++ ".conf" + ] installed :: Property installed = Apt.installed ["apache2"] @@ -60,3 +68,19 @@ multiSSL = "/etc/apache2/conf.d/ssl" `File.hasContent` ] `describe` "apache SNI enabled" `onChange` reloaded + +-- | Config file fragment that can be inserted into a <Directory> +-- stanza to allow global read access to the directory. +-- +-- Works with multiple versions of apache that have different ways to do +-- it. +allowAll :: String +allowAll = unlines + [ "<IfVersion < 2.4>" + , "Order allow,deny" + , "allow from all" + , "</IfVersion>" + , "<IfVersion >= 2.4>" + , "Require all granted" + , "</IfVersion>" + ] |
