From cc169f4ac0cf8ac6de38662671c14abd419b5f48 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Apr 2014 23:32:42 -0400 Subject: propellor spin --- Propellor/Property/Cron.hs | 2 +- Propellor/Property/Obnam.hs | 15 ++++--- Propellor/Property/SiteSpecific/JoeySites.hs | 58 ++++++++++++++++++++++++++-- config-joey.hs | 3 ++ 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/Propellor/Property/Cron.hs b/Propellor/Property/Cron.hs index 0649ee9f..5b070eff 100644 --- a/Propellor/Property/Cron.hs +++ b/Propellor/Property/Cron.hs @@ -33,7 +33,7 @@ job desc times user cddir command = cronjobfile `File.hasContent` `requires` Apt.installed ["util-linux", "moreutils"] `describe` ("cronned " ++ desc) where - cmdline = "cd " ++ cddir ++ " && " ++ command + cmdline = "cd " ++ cddir ++ " && ( " ++ command ++ " )" cronjobfile = "/etc/cron.d/" ++ map sanitize desc sanitize c | isAlphaNum c = c diff --git a/Propellor/Property/Obnam.hs b/Propellor/Property/Obnam.hs index 4d0584bb..6fda218a 100644 --- a/Propellor/Property/Obnam.hs +++ b/Propellor/Property/Obnam.hs @@ -97,14 +97,17 @@ installed = Apt.installed ["obnam"] -- | Ensures that a recent version of obnam gets installed. -- --- Only useful on Stable. +-- Only does anything for Debian Stable. latestVersion :: Property -latestVersion = propertyList "obnam latest version" - [ toProp $ Apt.trustsKey key - , Apt.setSourcesListD sources "obnam" - ] +latestVersion = withOS "obnam latest version" $ \o -> case o of + (Just (System (Debian suite) _)) | isStable suite -> ensureProperty $ + Apt.setSourcesListD (sources suite) "obnam" + `requires` toProp (Apt.trustsKey key) + _ -> noChange where - sources = ["deb http://code.liw.fi/debian wheezy main"] + sources suite = + [ "deb http://code.liw.fi/debian " ++ Apt.showSuite suite ++ " main" + ] -- gpg key used by the code.liw.fi repository. key = Apt.AptKey "obnam" $ unlines [ "-----BEGIN PGP PUBLIC KEY BLOCK-----" diff --git a/Propellor/Property/SiteSpecific/JoeySites.hs b/Propellor/Property/SiteSpecific/JoeySites.hs index 3d0ff246..9b4587ba 100644 --- a/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/Propellor/Property/SiteSpecific/JoeySites.hs @@ -16,9 +16,60 @@ import qualified Propellor.Property.Obnam as Obnam import qualified Propellor.Property.Apache as Apache import Utility.SafeCommand +import Data.List +import System.Posix.Files + +oldUseNetServer :: [Host] -> Property +oldUseNetServer hosts = propertyList ("olduse.net server") + [ oldUseNetInstalled "oldusenet-server" + , Obnam.latestVersion + , Obnam.backup datadir "33 4 * * *" + [ "--repository=sftp://2318@usw-s002.rsync.net/~/olduse.net" + , "--client-name=spool" + ] Obnam.OnlyClient + `requires` Ssh.keyImported SshRsa "root" + `requires` Ssh.knownHost hosts "usw-s002.rsync.net" "root" + , check (not . isSymbolicLink <$> getSymbolicLinkStatus newsspool) $ + Property "olduse.net spool in place" $ makeChange $ do + removeDirectoryRecursive newsspool + createSymbolicLink (datadir "news") newsspool + , Apt.installed ["leafnode"] + , "/etc/news/leafnode/config" `File.hasContent` + [ "# olduse.net configuration (deployed by propellor)" + , "expire = 1000000" -- no expiry via texpire + , "server = " -- no upstream server + , "debugmode = 1" + , "allowSTRANGERS = 42" -- lets anyone connect + , "nopost = 1" -- no new posting (just gather them) + ] + , Apt.serviceInstalledRunning "openbsd-inetd" + , File.notPresent "/etc/cron.daily/leafnode" + , File.notPresent "/etc/cron.d/leafnode" + , Cron.niceJob "oldusenet-expire" "11 1 * * *" "news" newsspool $ intercalate ";" + [ "find \\( -path ./out.going -or -path ./interesting.groups -or -path './*/.overview' \\) -prune -or -type f -ctime +60 -print | xargs --no-run-if-empty rm" + , "find -type d -empty | xargs --no-run-if-empty rmdir" + ] + , Cron.niceJob "oldusenet-uucp" "*/5 * * * *" "news" "/" $ + "/usr/bin/uucp " ++ datadir + , toProp $ Apache.siteEnabled "nntp.olduse.net" $ apachecfg "nntp.olduse.net" False + [ " DocumentRoot " ++ datadir ++ "/" + , " " + , " Options Indexes FollowSymlinks" + , " AllowOverride None" + , " Require all granted" + , " " + ] + ] + where + newsspool = "/var/spool/news" + datadir = "/var/spool/oldusenet" + oldUseNetShellBox :: Property -oldUseNetShellBox = check (not <$> Apt.isInstalled "oldusenet") $ - propertyList ("olduse.net shellbox") +oldUseNetShellBox = oldUseNetInstalled "oldusenet" + +oldUseNetInstalled :: Apt.Package -> Property +oldUseNetInstalled pkg = check (not <$> Apt.isInstalled pkg) $ + propertyList ("olduse.net " ++ pkg) [ Apt.installed (words "build-essential devscripts debhelper git libncursesw5-dev libpcre3-dev pkg-config bison libicu-dev libidn11-dev libcanlock2-dev libuu-dev ghc libghc-strptime-dev libghc-hamlet-dev libghc-ifelse-dev libghc-hxt-dev libghc-utf8-string-dev libghc-missingh-dev libghc-sha-dev") `describe` "olduse.net build deps" , scriptProperty @@ -26,12 +77,13 @@ oldUseNetShellBox = check (not <$> Apt.isInstalled "oldusenet") $ , "git clone git://olduse.net/ /root/tmp/oldusenet/source" , "cd /root/tmp/oldusenet/source/" , "dpkg-buildpackage -us -uc" - , "dpkg -i ../oldusenet*.deb || true" + , "dpkg -i ../" ++ pkg ++ "_*.deb || true" , "apt-get -fy install" -- dependencies , "rm -rf /root/tmp/oldusenet" ] `describe` "olduse.net built" ] + kgbServer :: Property kgbServer = withOS desc $ \o -> case o of (Just (System (Debian Unstable) _)) -> diff --git a/config-joey.hs b/config-joey.hs index dec1f1bd..ac70fc32 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -111,6 +111,9 @@ hosts = -- (o) ` [] & JoeySites.twitRss + & cname "nntp.olduse.net" + & JoeySites.oldUseNetServer hosts + & Apt.installed ["ntop"] -- cgit v1.2.3