From 815673962625221ded45d98177f19970d66dd525 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Fri, 11 Sep 2015 11:08:43 +0200 Subject: add DebianMirror property. Signed-off-by: Félix Sipma --- propellor.cabal | 1 + src/Propellor/Property/DebianMirror.hs | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/Propellor/Property/DebianMirror.hs 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..271b386e --- /dev/null +++ b/src/Propellor/Property/DebianMirror.hs @@ -0,0 +1,54 @@ +module Propellor.Property.DebianMirror + ( DebianPriority(..) + , showPriority + , mirror + ) 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 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 :: FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo +mirror dir suites archs sections source priorities crontimes = propertyList + ("Debian mirror " ++ dir) + [ Apt.installed ["debmirror"] + , File.dirExists dir + , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args + `describe` "debmirror setup" + , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "root") "/" $ + 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", "ftp.fr.debian.org" + , "--method", "http" + , "--keyring", "/usr/share/keyrings/debian-archive-keyring.gpg" + , dir + ] -- cgit v1.2.3 From aef9f836ffba8ffbac669f0060b5963d5b10bfd7 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Fri, 11 Sep 2015 11:09:09 +0200 Subject: DebianMirror: add Url argument; add mirrorCdn Signed-off-by: Félix Sipma --- src/Propellor/Property/DebianMirror.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs index 271b386e..37a22ae0 100644 --- a/src/Propellor/Property/DebianMirror.hs +++ b/src/Propellor/Property/DebianMirror.hs @@ -23,8 +23,8 @@ showPriority Standard = "standard" showPriority Optional = "optional" showPriority Extra = "extra" -mirror :: FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo -mirror dir suites archs sections source priorities crontimes = propertyList +mirror :: 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"] , File.dirExists dir @@ -47,8 +47,11 @@ mirror dir suites archs sections source priorities crontimes = propertyList ++ (if source then [] else ["--nosource"]) ++ - [ "--host", "ftp.fr.debian.org" + [ "--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" -- cgit v1.2.3 From 1a1bbd3efe5d567b342f3ace29a92afb149bbb3f Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Fri, 11 Sep 2015 11:09:38 +0200 Subject: DebianMirror: run cronjob as user "debmirror" Signed-off-by: Félix Sipma --- src/Propellor/Property/DebianMirror.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs index 37a22ae0..252520c7 100644 --- a/src/Propellor/Property/DebianMirror.hs +++ b/src/Propellor/Property/DebianMirror.hs @@ -8,6 +8,7 @@ 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 @@ -27,10 +28,11 @@ mirror :: Url -> FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> mirror url dir suites archs sections source priorities crontimes = propertyList ("Debian mirror " ++ dir) [ Apt.installed ["debmirror"] + , User.accountFor "debmirror" , File.dirExists dir , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args `describe` "debmirror setup" - , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "root") "/" $ + , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "debmirror") "/" $ unwords ("/usr/bin/debmirror" : args) ] where -- cgit v1.2.3 From 6f474f544737759db93766b0b1bac8b91b2c841b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Sep 2015 11:25:39 -0400 Subject: changelog --- debian/changelog | 1 + 1 file changed, 1 insertion(+) 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 Fri, 04 Sep 2015 10:36:40 -0700 -- cgit v1.2.3 From 5bcc57d21f88aedaf708c93495370dc01ff8ee0a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Sep 2015 14:30:14 -0400 Subject: todo --- src/Propellor/Property/DiskImage.hs | 1 + 1 file changed, 1 insertion(+) 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) -- cgit v1.2.3 From 491f38584e8f7824dd397d81a9b90789eee14ed6 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sat, 12 Sep 2015 16:33:16 +0200 Subject: DebianMirror: ensure mirror dir is owned by debmirror:debmirror Signed-off-by: Félix Sipma --- src/Propellor/Property/DebianMirror.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs index 252520c7..aeac8d42 100644 --- a/src/Propellor/Property/DebianMirror.hs +++ b/src/Propellor/Property/DebianMirror.hs @@ -30,6 +30,7 @@ mirror url dir suites archs sections source priorities crontimes = propertyList [ Apt.installed ["debmirror"] , User.accountFor "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") "/" $ -- cgit v1.2.3 From 9003e331e4b225bd07e4c343ab77f975571cb7a3 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sat, 12 Sep 2015 17:35:58 +0200 Subject: DebianMirror: fix various typos Signed-off-by: Félix Sipma --- src/Propellor/Property/DebianMirror.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs index aeac8d42..cd98b6ff 100644 --- a/src/Propellor/Property/DebianMirror.hs +++ b/src/Propellor/Property/DebianMirror.hs @@ -2,6 +2,7 @@ module Propellor.Property.DebianMirror ( DebianPriority(..) , showPriority , mirror + , mirrorCdn ) where import Propellor @@ -24,11 +25,11 @@ showPriority Standard = "standard" showPriority Optional = "optional" showPriority Extra = "extra" -mirror :: Url -> FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo +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 "debmirror" + , User.accountFor (User "debmirror") , File.dirExists dir , File.ownerGroup dir (User "debmirror") (Group "debmirror") , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args -- cgit v1.2.3 From 2af70d4ac7ff25a3e596de195abe40db46c74074 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 13 Sep 2015 12:47:48 -0400 Subject: add virus collection cleanup --- src/Propellor/Property/SiteSpecific/JoeySites.hs | 3 +++ 1 file changed, 3 insertions(+) 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 -- cgit v1.2.3