diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-03 14:07:32 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-03 14:07:32 -0400 |
| commit | ac480f6c85c6e780273154a4138f7fc293e507ca (patch) | |
| tree | c0e95898a0acac92bf411b855802212a6e211af2 /Propellor | |
| parent | 7c0b19218a65aec2bfb346f40c7b0ea2f6229668 (diff) | |
| parent | 680d480921e2aadd143d55533a55af5a02666d84 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'Propellor')
| -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 |
