diff options
| -rw-r--r-- | debian/changelog | 7 | ||||
| -rw-r--r-- | propellor.cabal | 1 | ||||
| -rw-r--r-- | src/Propellor/Property/Apt.hs | 8 | ||||
| -rw-r--r-- | src/Propellor/Property/Uwsgi.hs | 56 |
4 files changed, 72 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 53ccc04a..932a708b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +propellor (2.8.2) UNRELEASED; urgency=medium + + * Added basic Uwsgi module, contributed by Félix Sipma. + * Add Apt.hasForeignArch. Thanks, Per Olofsson. + + -- Joey Hess <id@joeyh.name> Thu, 08 Oct 2015 11:09:01 -0400 + propellor (2.8.1) unstable; urgency=medium * Guard against power loss etc when building propellor, by updating diff --git a/propellor.cabal b/propellor.cabal index d2e2e0c6..32f3772d 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -116,6 +116,7 @@ Library Propellor.Property.Tor Propellor.Property.Unbound Propellor.Property.User + Propellor.Property.Uwsgi Propellor.Property.HostingProvider.CloudAtCost Propellor.Property.HostingProvider.DigitalOcean Propellor.Property.HostingProvider.Linode diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 2e913540..15c45629 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -297,3 +297,11 @@ aptKeyFile k = "/etc/apt/trusted.gpg.d" </> keyname k ++ ".gpg" cacheCleaned :: Property NoInfo cacheCleaned = trivial $ cmdProperty "apt-get" ["clean"] `describe` "apt cache cleaned" + +-- | Add a foreign architecture to dpkg and apt. +hasForeignArch :: String -> Property NoInfo +hasForeignArch arch = check notAdded add + `describe` ("dpkg has foreign architecture " ++ arch) + where + notAdded = (not . elem arch . lines) <$> readProcess "dpkg" ["--print-foreign-architectures"] + add = cmdProperty "dpkg" ["--add-architecture", arch] `before` update diff --git a/src/Propellor/Property/Uwsgi.hs b/src/Propellor/Property/Uwsgi.hs new file mode 100644 index 00000000..d1cdb550 --- /dev/null +++ b/src/Propellor/Property/Uwsgi.hs @@ -0,0 +1,56 @@ +-- | Maintainer: Félix Sipma <felix+propellor@gueux.org> + +module Propellor.Property.Uwsgi where + +import Propellor +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Service as Service +import System.Posix.Files + +type ConfigFile = [String] + +type AppName = String + +appEnabled :: AppName -> ConfigFile -> RevertableProperty +appEnabled an cf = enable <!> disable + where + enable = check test prop + `describe` ("uwsgi app enabled " ++ an) + `requires` appAvailable an cf + `requires` installed + `onChange` reloaded + where + test = not <$> doesFileExist (appVal an) + prop = property "uwsgi app in place" $ makeChange $ + createSymbolicLink target dir + target = appValRelativeCfg an + dir = appVal an + disable = trivial $ File.notPresent (appVal an) + `describe` ("uwsgi app disable" ++ an) + `requires` installed + `onChange` reloaded + +appAvailable :: AppName -> ConfigFile -> Property NoInfo +appAvailable an cf = ("uwsgi app available " ++ an) ==> + appCfg an `File.hasContent` (comment : cf) + where + comment = "# deployed with propellor, do not modify" + +appCfg :: AppName -> FilePath +appCfg an = "/etc/uwsgi/apps-available/" ++ an + +appVal :: AppName -> FilePath +appVal an = "/etc/uwsgi/apps-enabled/" ++ an + +appValRelativeCfg :: AppName -> FilePath +appValRelativeCfg an = "../apps-available/" ++ an + +installed :: Property NoInfo +installed = Apt.installed ["uwsgi"] + +restarted :: Property NoInfo +restarted = Service.restarted "uwsgi" + +reloaded :: Property NoInfo +reloaded = Service.reloaded "uwsgi" |
