This commit is contained in:
Joey Hess 2014-03-30 23:02:10 -04:00
parent 647e1a6de2
commit 02a7bf5f0e
2 changed files with 13 additions and 10 deletions

View File

@ -41,14 +41,20 @@ usage = do
] ]
exitFailure exitFailure
defaultMain :: (HostName -> [Property]) -> IO () defaultMain :: (HostName -> Maybe [Property]) -> IO ()
defaultMain getprops = go =<< processCmdLine defaultMain getprops = go =<< processCmdLine
where where
go (Run host) = ensureProperties (getprops host) go (Run host) = maybe (unknownhost host) ensureProperties (getprops host)
go (Spin host) = spin host go (Spin host) = spin host
go (Boot host) = boot (getprops host) go (Boot host) = maybe (unknownhost host) boot (getprops host)
go (Set host field) = setPrivData host field go (Set host field) = setPrivData host field
unknownhost :: HostName -> IO a
unknownhost h = error $ unwords
[ "Unknown host:", h
, "(perhaps you should specify the real hostname on the command line?)"
]
spin :: HostName -> IO () spin :: HostName -> IO ()
spin host = do spin host = do
url <- getUrl url <- getUrl

View File

@ -19,13 +19,13 @@ main = defaultMain getProperties
{- This is where the system's HostName, either as returned by uname {- This is where the system's HostName, either as returned by uname
- or one specified on the command line, is converted into a list of - or one specified on the command line, is converted into a list of
- Properties for that system. -} - Properties for that system. -}
getProperties :: HostName -> [Property] getProperties :: HostName -> Maybe [Property]
getProperties hostname@"clam.kitenet.net" = getProperties hostname@"clam.kitenet.net" = Just
[ cleanCloudAtCost hostname [ cleanCloudAtCost hostname
, standardSystem Apt.Unstable , standardSystem Apt.Unstable
, Network.ipv6to4
-- Clam is a tor bridge, and an olduse.net shellbox. -- Clam is a tor bridge, and an olduse.net shellbox.
, Tor.isBridge , Tor.isBridge
, Network.ipv6to4
, JoeySites.oldUseNetshellBox , JoeySites.oldUseNetshellBox
-- I play with docker on clam. -- I play with docker on clam.
, Docker.configured , Docker.configured
@ -37,10 +37,7 @@ getProperties hostname@"clam.kitenet.net" =
] ]
-- add more hosts here... -- add more hosts here...
--getProperties "foo" = --getProperties "foo" =
getProperties h = error $ unwords getProperties _ = Nothing
[ "Unknown host:", h
, "(perhaps you should specify the real hostname on the command line?)"
]
-- This is my standard system setup -- This is my standard system setup
standardSystem :: Apt.Suite -> Property standardSystem :: Apt.Suite -> Property