Add --list-fields to list a host's currently set privdata fields.
This commit is contained in:
parent
42594d6b4c
commit
f674c56119
|
@ -1,6 +1,7 @@
|
||||||
propellor (0.7.1) UNRELEASED; urgency=medium
|
propellor (0.7.1) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Add --edit to edit a privdata value in $EDITOR.
|
* Add --edit to edit a privdata value in $EDITOR.
|
||||||
|
* Add --list-fields to list a host's currently set privdata fields.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 19 Jun 2014 14:27:21 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 19 Jun 2014 14:27:21 -0400
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ usage = do
|
||||||
, " propellor --set hostname field"
|
, " propellor --set hostname field"
|
||||||
, " propellor --dump hostname field"
|
, " propellor --dump hostname field"
|
||||||
, " propellor --edit hostname field"
|
, " propellor --edit hostname field"
|
||||||
|
, " propellor --list-fields hostname"
|
||||||
]
|
]
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ processCmdLine = go =<< getArgs
|
||||||
go ("--set":h:f:[]) = withprivfield f (return . Set h)
|
go ("--set":h:f:[]) = withprivfield f (return . Set h)
|
||||||
go ("--dump":h:f:[]) = withprivfield f (return . Dump h)
|
go ("--dump":h:f:[]) = withprivfield f (return . Dump h)
|
||||||
go ("--edit":h:f:[]) = withprivfield f (return . Edit h)
|
go ("--edit":h:f:[]) = withprivfield f (return . Edit h)
|
||||||
|
go ("--list-fields":h:[]) = return $ ListFields h
|
||||||
go ("--continue":s:[]) = case readish s of
|
go ("--continue":s:[]) = case readish s of
|
||||||
Just cmdline -> return $ Continue cmdline
|
Just cmdline -> return $ Continue cmdline
|
||||||
Nothing -> errorMessage "--continue serialization failure"
|
Nothing -> errorMessage "--continue serialization failure"
|
||||||
|
@ -74,6 +76,7 @@ defaultMain hostlist = do
|
||||||
go _ (Set hn field) = setPrivData hn field
|
go _ (Set hn field) = setPrivData hn field
|
||||||
go _ (Dump hn field) = dumpPrivData hn field
|
go _ (Dump hn field) = dumpPrivData hn field
|
||||||
go _ (Edit hn field) = editPrivData hn field
|
go _ (Edit hn field) = editPrivData hn field
|
||||||
|
go _ (ListFields hn) = listPrivDataFields hn
|
||||||
go _ (AddKey keyid) = addKey keyid
|
go _ (AddKey keyid) = addKey keyid
|
||||||
go _ (Chain hn) = withhost hn $ \h -> do
|
go _ (Chain hn) = withhost hn $ \h -> do
|
||||||
r <- runPropellor h $ ensureProperties $ hostProperties h
|
r <- runPropellor h $ ensureProperties $ hostProperties h
|
||||||
|
|
|
@ -68,6 +68,13 @@ editPrivData host field = do
|
||||||
readFile f
|
readFile f
|
||||||
setPrivDataTo host field v'
|
setPrivDataTo host field v'
|
||||||
|
|
||||||
|
listPrivDataFields :: HostName -> IO ()
|
||||||
|
listPrivDataFields host = do
|
||||||
|
putStrLn (host ++ "'s currently set privdata fields:")
|
||||||
|
mapM_ list . M.keys =<< decryptPrivData host
|
||||||
|
where
|
||||||
|
list = putStrLn . ("\t" ++) . shellEscape . show
|
||||||
|
|
||||||
setPrivDataTo :: HostName -> PrivDataField -> String -> IO ()
|
setPrivDataTo :: HostName -> PrivDataField -> String -> IO ()
|
||||||
setPrivDataTo host field value = do
|
setPrivDataTo host field value = do
|
||||||
makePrivDataDir
|
makePrivDataDir
|
||||||
|
|
|
@ -138,6 +138,7 @@ data CmdLine
|
||||||
| Set HostName PrivDataField
|
| Set HostName PrivDataField
|
||||||
| Dump HostName PrivDataField
|
| Dump HostName PrivDataField
|
||||||
| Edit HostName PrivDataField
|
| Edit HostName PrivDataField
|
||||||
|
| ListFields HostName
|
||||||
| AddKey String
|
| AddKey String
|
||||||
| Continue CmdLine
|
| Continue CmdLine
|
||||||
| Chain HostName
|
| Chain HostName
|
||||||
|
|
Loading…
Reference in New Issue