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 --- src/Propellor/Property/DebianMirror.hs | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/Propellor/Property/DebianMirror.hs (limited to 'src/Propellor/Property/DebianMirror.hs') 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(-) (limited to 'src/Propellor/Property/DebianMirror.hs') 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(-) (limited to 'src/Propellor/Property/DebianMirror.hs') 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 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(+) (limited to 'src/Propellor/Property/DebianMirror.hs') 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(-) (limited to 'src/Propellor/Property/DebianMirror.hs') 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