summaryrefslogtreecommitdiff
path: root/Propellor/Property/Apache.hs
blob: 5e32b0da03b1cbe92b40b68e9b7cc4ca62814273 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"]