summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-03-30 22:14:14 -0400
committerJoey Hess2014-03-30 22:14:14 -0400
commit4357d6117453e1a0759a6482f4006fa042110a6c (patch)
treed1c011a5244f20cec99e3cad384de9ba4d177add
parent25a12dd8f0e05165c5b7bed2b0e7b62d75b59e5c (diff)
propellor spin
-rw-r--r--Propellor.hs4
-rw-r--r--Property/Apt.hs11
-rw-r--r--Property/Cmd.hs7
-rw-r--r--Property/JoeySites.hs22
4 files changed, 39 insertions, 5 deletions
diff --git a/Propellor.hs b/Propellor.hs
index 8b1016d7..63040ff1 100644
--- a/Propellor.hs
+++ b/Propellor.hs
@@ -10,6 +10,7 @@ import qualified Property.Reboot as Reboot
import qualified Property.Tor as Tor
import qualified Property.Docker as Docker
import qualified Property.GitHome as GitHome
+import qualified Property.JoeySites as JoeySites
main :: IO ()
main = defaultMain getProperties
@@ -21,8 +22,9 @@ getProperties :: HostName -> [Property]
getProperties hostname@"clam.kitenet.net" =
[ cleanCloudAtCost hostname
, standardSystem Apt.Unstable
- -- Clam is a tor bridge.
+ -- Clam is a tor bridge, and an olduse.net shellbox.
, Tor.isBridge
+ , JoeySites.oldUseNetshellBox
-- I play with docker on clam.
, Docker.configured
-- This is not an important system so I don't want to need to
diff --git a/Property/Apt.hs b/Property/Apt.hs
index 5c0a32c3..b89fb30b 100644
--- a/Property/Apt.hs
+++ b/Property/Apt.hs
@@ -76,22 +76,25 @@ installed ps = check (isInstallable ps) go
go = runApt $ [Param "-y", Param "install"] ++ map Param ps
removed :: [Package] -> Property
-removed ps = check (or <$> isInstalled ps) go
+removed ps = check (or <$> isInstalled' ps) go
`describe` (unwords $ "apt removed":ps)
where
go = runApt $ [Param "-y", Param "remove"] ++ map Param ps
isInstallable :: [Package] -> IO Bool
isInstallable ps = do
- l <- isInstalled ps
+ l <- isInstalled' ps
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
- 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
- be included in the result list. -}
-isInstalled :: [Package] -> IO [Bool]
-isInstalled ps = catMaybes . map parse . lines
+isInstalled' :: [Package] -> IO [Bool]
+isInstalled' ps = catMaybes . map parse . lines
<$> readProcess "apt-cache" ("policy":ps)
where
parse l
diff --git a/Property/Cmd.hs b/Property/Cmd.hs
index b29a12b3..0a4a5ba4 100644
--- a/Property/Cmd.hs
+++ b/Property/Cmd.hs
@@ -1,10 +1,12 @@
module Property.Cmd (
cmdProperty,
cmdProperty',
+ scriptProperty,
module Utility.SafeCommand
) where
import Control.Applicative
+import Data.List
import Types
import Utility.Monad
@@ -26,3 +28,8 @@ cmdProperty' cmd params env = Property desc $ do
showp (Params s) = s
showp (Param s) = s
showp (File s) = s
+
+scriptProperty :: [String] -> Property
+scriptProperty script = cmdProperty "sh" [Param "-c", Param shellcmd]
+ where
+ shellcmd = intercalate " && " script
diff --git a/Property/JoeySites.hs b/Property/JoeySites.hs
new file mode 100644
index 00000000..35d51095
--- /dev/null
+++ b/Property/JoeySites.hs
@@ -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"
+ ]