diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-10 00:10:41 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-10 00:13:00 -0400 |
commit | bb5b94f8acc9db5acd78fdc88d32c69f49cf75c0 (patch) | |
tree | 601afe3fe3795f2da502ef06087a00d2232cdafd /acme-certify.hs | |
parent | f74375e4b6e8eaf8cfe508bcf31fb7315a0be728 (diff) |
'acme update' accepts hosts as arguments
When arguments are specified on the command line, they will be
interpreted as hosts to limit the update to.
Without arguments, update all hosts.
Diffstat (limited to 'acme-certify.hs')
-rw-r--r-- | acme-certify.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/acme-certify.hs b/acme-certify.hs index 8bad7ac..049ba5a 100644 --- a/acme-certify.hs +++ b/acme-certify.hs | |||
@@ -16,7 +16,7 @@ | |||
16 | module Main where | 16 | module Main where |
17 | 17 | ||
18 | import BasePrelude | 18 | import BasePrelude |
19 | import Control.Lens hiding ((&)) | 19 | import Control.Lens hiding ((&), argument) |
20 | import Control.Monad.IO.Class | 20 | import Control.Monad.IO.Class |
21 | import Control.Monad.Trans.Resource | 21 | import Control.Monad.Trans.Resource |
22 | import Data.Aeson.Lens | 22 | import Data.Aeson.Lens |
@@ -89,7 +89,8 @@ data CertifyOpts = CertifyOpts { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | data UpdateOpts = UpdateOpts { | 91 | data UpdateOpts = UpdateOpts { |
92 | updateConfigFile :: Maybe FilePath | 92 | updateConfigFile :: Maybe FilePath, |
93 | updateHosts :: [String] | ||
93 | } | 94 | } |
94 | 95 | ||
95 | instance Show HttpProvisioner where | 96 | instance Show HttpProvisioner where |
@@ -111,6 +112,7 @@ updateOpts = fmap Update $ | |||
111 | (long "config" <> | 112 | (long "config" <> |
112 | metavar "FILENAME" <> | 113 | metavar "FILENAME" <> |
113 | help "location of YAML configuration file")) | 114 | help "location of YAML configuration file")) |
115 | <*> many (argument str (metavar "HOSTS")) | ||
114 | 116 | ||
115 | certifyOpts :: Parser Command | 117 | certifyOpts :: Parser Command |
116 | certifyOpts = fmap Certify $ | 118 | certifyOpts = fmap Certify $ |
@@ -187,7 +189,9 @@ runUpdate UpdateOpts { .. } = do | |||
187 | 189 | ||
188 | issuerCert <- readX509 letsEncryptX1CrossSigned | 190 | issuerCert <- readX509 letsEncryptX1CrossSigned |
189 | 191 | ||
190 | forM_ certReqDomains $ \(host, domain, domains) -> when (host == "fifty") $ do | 192 | let wantUpdate h = null updateHosts || isJust (find (== h) updateHosts) |
193 | |||
194 | forM_ certReqDomains $ \(host, domain, domains) -> when (wantUpdate host) $ do | ||
191 | putStrLn host | 195 | putStrLn host |
192 | let Just spec = dereference (map (chooseProvisioner host) domains) <&> certSpec globalCertificateDir keys host domain | 196 | let Just spec = dereference (map (chooseProvisioner host) domains) <&> certSpec globalCertificateDir keys host domain |
193 | print spec | 197 | print spec |