diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-03 13:58:21 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-03 13:58:21 -0400 |
| commit | b14b56d84a448664bb86cde8079812ff11a9a79d (patch) | |
| tree | effe4010302eec431ae38bec2380b2ab214ff0dd | |
| parent | e1c42aeeb1770b42373ae04ef21c897248f62380 (diff) | |
propellor spin
| -rw-r--r-- | Propellor/CmdLine.hs | 17 |
1 files 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 |
