From 96f07ef513f6447baec8f66d52d4490ef627a588 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 13 Apr 2014 14:36:19 -0400 Subject: propellor spin --- Propellor/Property/Apache.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'Propellor/Property/Apache.hs') diff --git a/Propellor/Property/Apache.hs b/Propellor/Property/Apache.hs index 5e32b0da..81daf9e7 100644 --- a/Propellor/Property/Apache.hs +++ b/Propellor/Property/Apache.hs @@ -3,17 +3,21 @@ module Propellor.Property.Apache where import Propellor import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Service as Service 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"] + enable = cmdProperty "a2ensite" ["--quiet", hn] + `requires` siteAvailable hn cf + `requires` installed + `onChange` reloaded disable = 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) @@ -21,8 +25,24 @@ siteAvailable hn cf = siteCfg hn `File.hasContent` (comment:cf) where comment = "# deployed with propellor, do not modify" +modEnabled :: String -> RevertableProperty +modEnabled modname = RevertableProperty enable disable + where + enable = cmdProperty "a2enmod" ["--quiet", modname] + `requires` installed + `onChange` reloaded + disable = cmdProperty "a2dismod" ["--quiet", modname] + `requires` installed + `onChange` reloaded + siteCfg :: HostName -> FilePath -siteCfg hn = "/etc/apache2/sites-available/" ++ hn ++ ".conf" +siteCfg hn = "/etc/apache2/sites-available/" ++ hn + +installed :: Property +installed = Apt.installed ["apache2"] + +restarted :: Property +restarted = cmdProperty "service" ["apache2", "restart"] -restart :: Property -restart = cmdProperty "service" ["apache2", "restart"] +reloaded :: Property +reloaded = Service.reloaded "apache2" -- cgit v1.3-2-g0d8e