blob: 212f737d6380604d327e0ebc10c3719a81c397cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-- | Wrapper program for propellor distribution.
--
-- Distributions should install this program into PATH.
-- (Cabal builds it as dist/build/propellor/propellor).
--
-- This is not the propellor main program (that's config.hs).
-- This bootstraps ~/.propellor/config.hs, builds it if
-- it's not already built, and runs it.
module Main where
import Propellor.DotDir
import Propellor.Message
import Propellor.Bootstrap
import Utility.Monad
import Utility.Process
import System.Directory
import System.Environment (getArgs)
import System.Exit
import System.Posix.Directory
import Control.Monad.IfElse
main :: IO ()
main = withConcurrentOutput $ go =<< getArgs
where
go ["--init"] = interactiveInit
go args = ifM (doesDirectoryExist =<< dotPropellor)
( do
checkRepoUpToDate
buildRunConfig args
, error "Seems that ~/.propellor/ does not exist. To set it up, run: propellor --init"
)
buildRunConfig :: [String] -> IO ()
buildRunConfig args = do
changeWorkingDirectory =<< dotPropellor
unlessM (doesFileExist "propellor") $ do
buildPropellor Nothing
putStrLn ""
putStrLn ""
(_, _, _, pid) <- createProcess (proc "./propellor" args)
exitWith =<< waitForProcess pid
|