summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog1
-rw-r--r--propellor.cabal1
-rw-r--r--src/Propellor/Property/DebianMirror.hs61
-rw-r--r--src/Propellor/Property/DiskImage.hs1
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs3
5 files changed, 67 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index fd3e4f63..cc39df17 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ propellor (2.8.0) UNRELEASED; urgency=medium
* Improve propellor wrapper to better handle installation cloning
the public propellor repo, by setting that repo to be upstream,
so propellor doesnt try to push to a read-only repo.
+ * Added DebianMirror module, contributed by FĂ©lix Sipma.
-- Joey Hess <id@joeyh.name> Fri, 04 Sep 2015 10:36:40 -0700
diff --git a/propellor.cabal b/propellor.cabal
index b8e19828..f30695a0 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -77,6 +77,7 @@ Library
Propellor.Property.Chroot
Propellor.Property.ConfFile
Propellor.Property.Cron
+ Propellor.Property.DebianMirror
Propellor.Property.Debootstrap
Propellor.Property.DiskImage
Propellor.Property.Dns
diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs
new file mode 100644
index 00000000..cd98b6ff
--- /dev/null
+++ b/src/Propellor/Property/DebianMirror.hs
@@ -0,0 +1,61 @@
+module Propellor.Property.DebianMirror
+ ( DebianPriority(..)
+ , showPriority
+ , mirror
+ , mirrorCdn
+ ) where
+
+import Propellor
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Cron as Cron
+import qualified Propellor.Property.User as User
+
+import Data.List
+
+
+data DebianPriority = Essential | Required | Important | Standard | Optional | Extra
+ deriving (Show, Eq)
+
+showPriority :: DebianPriority -> String
+showPriority Essential = "essential"
+showPriority Required = "required"
+showPriority Important = "important"
+showPriority Standard = "standard"
+showPriority Optional = "optional"
+showPriority Extra = "extra"
+
+mirror :: Apt.Url -> FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo
+mirror url dir suites archs sections source priorities crontimes = propertyList
+ ("Debian mirror " ++ dir)
+ [ Apt.installed ["debmirror"]
+ , User.accountFor (User "debmirror")
+ , File.dirExists dir
+ , File.ownerGroup dir (User "debmirror") (Group "debmirror")
+ , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args
+ `describe` "debmirror setup"
+ , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "debmirror") "/" $
+ unwords ("/usr/bin/debmirror" : args)
+ ]
+ where
+ suitemirrored suite = doesDirectoryExist $ dir </> "dists" </> Apt.showSuite suite
+ architecturearg = intercalate ","
+ suitearg = intercalate "," $ map Apt.showSuite suites
+ priorityRegex pp = "(" ++ intercalate "|" (map showPriority pp) ++ ")"
+ args =
+ [ "--dist" , suitearg
+ , "--arch", architecturearg archs
+ , "--section", intercalate "," sections
+ , "--limit-priority", "\"" ++ priorityRegex priorities ++ "\""
+ ]
+ ++
+ (if source then [] else ["--nosource"])
+ ++
+ [ "--host", url
+ , "--method", "http"
+ , "--keyring", "/usr/share/keyrings/debian-archive-keyring.gpg"
+ , dir
+ ]
+
+mirrorCdn :: FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo
+mirrorCdn = mirror "http://httpredir.debian.org/debian"
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 7a3460cb..35082eec 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -292,6 +292,7 @@ fitChrootSize tt l basesizes = (mounts, parttable)
type Finalization = (Property NoInfo, Property NoInfo)
-- | Makes grub be the boot loader of the disk image.
+-- TODO not implemented
grubBooted :: Grub.BIOS -> Finalization
grubBooted bios = (Grub.installed bios, undefined)
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index b6524f69..0a59452c 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -520,6 +520,9 @@ kiteMailServer = propertyList "kitenet.net mail server" $ props
`onChange` Service.restarted "amavisd-milter"
`describe` "amavisd-milter configured for postfix"
& Apt.serviceInstalledRunning "clamav-freshclam"
+ -- Workaround https://bugs.debian.org/569150
+ & Cron.niceJob "amavis-expire" Cron.Daily (User "root") "/"
+ "find /var/lib/amavis/virusmails/ -type f -ctime +7 -delete"
& dkimInstalled