From b14b56d84a448664bb86cde8079812ff11a9a79d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 13:58:21 -0400 Subject: propellor spin --- Propellor/CmdLine.hs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index f1c002ac..a9c61993 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -68,24 +68,15 @@ defaultMain getprops = do go True cmdline@(Spin _) = buildFirst cmdline $ go False cmdline go True cmdline = updateFirst cmdline $ go False cmdline go False (Spin host) = withprops host $ const $ spin host - go False cmdline@(Run host) = withprops host $ - asRoot cmdline . ensureProperties + go False (Run host) = ifM ((==) 0 <$> getRealUserID) + ( withprops host ensureProperties + , go True (Spin host) + ) go False (Boot host) = withprops host $ boot withprops host a = maybe (unknownhost host) a $ headMaybe $ catMaybes $ map (\get -> get host) getprops -asRoot :: CmdLine -> IO a -> IO a -asRoot cmdline a = ifM ((==) 0 <$> getRealUserID) - ( a - , do - hPutStrLn stderr "Need to be root to provision the local host! Running sudo propellor..." - hFlush stderr - (_, _, _, pid) <- createProcess $ - proc "sudo" ["./propellor", show (Continue cmdline)] - exitWith =<< waitForProcess pid - ) - unknownhost :: HostName -> IO a unknownhost h = errorMessage $ unlines [ "Unknown host: " ++ h -- cgit v1.2.3