propellor spin

This commit is contained in:
Joey Hess 2014-03-30 22:14:14 -04:00
parent 25a12dd8f0
commit 4357d61174
4 changed files with 39 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import qualified Property.Reboot as Reboot
import qualified Property.Tor as Tor import qualified Property.Tor as Tor
import qualified Property.Docker as Docker import qualified Property.Docker as Docker
import qualified Property.GitHome as GitHome import qualified Property.GitHome as GitHome
import qualified Property.JoeySites as JoeySites
main :: IO () main :: IO ()
main = defaultMain getProperties main = defaultMain getProperties
@ -21,8 +22,9 @@ getProperties :: HostName -> [Property]
getProperties hostname@"clam.kitenet.net" = getProperties hostname@"clam.kitenet.net" =
[ cleanCloudAtCost hostname [ cleanCloudAtCost hostname
, standardSystem Apt.Unstable , standardSystem Apt.Unstable
-- Clam is a tor bridge. -- Clam is a tor bridge, and an olduse.net shellbox.
, Tor.isBridge , Tor.isBridge
, JoeySites.oldUseNetshellBox
-- I play with docker on clam. -- I play with docker on clam.
, Docker.configured , Docker.configured
-- This is not an important system so I don't want to need to -- This is not an important system so I don't want to need to

View File

@ -76,22 +76,25 @@ installed ps = check (isInstallable ps) go
go = runApt $ [Param "-y", Param "install"] ++ map Param ps go = runApt $ [Param "-y", Param "install"] ++ map Param ps
removed :: [Package] -> Property removed :: [Package] -> Property
removed ps = check (or <$> isInstalled ps) go removed ps = check (or <$> isInstalled' ps) go
`describe` (unwords $ "apt removed":ps) `describe` (unwords $ "apt removed":ps)
where where
go = runApt $ [Param "-y", Param "remove"] ++ map Param ps go = runApt $ [Param "-y", Param "remove"] ++ map Param ps
isInstallable :: [Package] -> IO Bool isInstallable :: [Package] -> IO Bool
isInstallable ps = do isInstallable ps = do
l <- isInstalled ps l <- isInstalled' ps
return $ any (== False) l && not (null l) return $ any (== False) l && not (null l)
isInstalled :: Package -> IO Bool
isInstalled p = (== [True]) <$> isInstalled' [p]
{- Note that the order of the returned list will not always {- Note that the order of the returned list will not always
- correspond to the order of the input list. The number of items may - correspond to the order of the input list. The number of items may
- even vary. If apt does not know about a package at all, it will not - even vary. If apt does not know about a package at all, it will not
- be included in the result list. -} - be included in the result list. -}
isInstalled :: [Package] -> IO [Bool] isInstalled' :: [Package] -> IO [Bool]
isInstalled ps = catMaybes . map parse . lines isInstalled' ps = catMaybes . map parse . lines
<$> readProcess "apt-cache" ("policy":ps) <$> readProcess "apt-cache" ("policy":ps)
where where
parse l parse l

View File

@ -1,10 +1,12 @@
module Property.Cmd ( module Property.Cmd (
cmdProperty, cmdProperty,
cmdProperty', cmdProperty',
scriptProperty,
module Utility.SafeCommand module Utility.SafeCommand
) where ) where
import Control.Applicative import Control.Applicative
import Data.List
import Types import Types
import Utility.Monad import Utility.Monad
@ -26,3 +28,8 @@ cmdProperty' cmd params env = Property desc $ do
showp (Params s) = s showp (Params s) = s
showp (Param s) = s showp (Param s) = s
showp (File s) = s showp (File s) = s
scriptProperty :: [String] -> Property
scriptProperty script = cmdProperty "sh" [Param "-c", Param shellcmd]
where
shellcmd = intercalate " && " script

22
Property/JoeySites.hs Normal file
View File

@ -0,0 +1,22 @@
{- Specific configuation for Joey Hess's sites. Probably not useful to
- others except as an example. -}
module Property.JoeySites where
import Common
import qualified Property.Apt as Apt
oldUseNetshellBox :: Property
oldUseNetshellBox = check (not <$> Apt.isInstalled "oldusenet") $
propertyList ("olduse.net shellbox")
[ Apt.installed (words "build-essential git 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
[ "git clone git://olduse.net/ /root/tmp/oldusenet/source"
, "cd /root/tmp/oldusenet/source/"
, "dpkg-buildpackage -us -uc"
, "dpkg -i ../oldusenet*.deb || true"
, "apt-get -f install" -- dependencies
, "rm -rf /root/tmp/oldusenet"
] `describe` "olduse.net built"
]