4
4
montagu status <path>
5
5
montagu stop <path> [--volumes] [--network] [--kill] [--force]
6
6
[--extra=PATH] [--option=OPTION]...
7
+ montagu renew-certificate <path> [--option=OPTION]... [--] [ARGS...]
7
8
8
9
Options:
9
10
--extra=PATH Path, relative to <path>, of yml file of additional
15
16
--volumes Remove volumes (WARNING: irreversible data loss)
16
17
--network Remove network
17
18
--kill Kill the containers (faster, but possible db corruption)
18
- --force Force stop even if containers are corrupted and cannot
19
- signal their running configuration, or if config cannot be
20
- parsed. Use with extra and/or option to force stop with
21
- configuration options.
22
19
"""
23
20
24
21
import docopt
25
22
import yaml
26
23
27
24
import montagu_deploy .__about__ as about
25
+ from montagu_deploy .certbot import obtain_certificate
28
26
from montagu_deploy .config import MontaguConfig
29
- from montagu_deploy .montagu_constellation import montagu_constellation
27
+ from montagu_deploy .montagu_constellation import montagu_constellation , proxy_update_certificate
30
28
31
29
32
30
def main (argv = None ):
33
31
path , extra , options , args = parse_args (argv )
34
32
if args .version :
35
- return about .__version__
33
+ print ( about .__version__ )
36
34
else :
37
35
cfg = MontaguConfig (path , extra , options )
38
36
obj = montagu_constellation (cfg )
@@ -42,7 +40,8 @@ def main(argv=None):
42
40
montagu_status (obj )
43
41
elif args .action == "stop" :
44
42
montagu_stop (obj , args , cfg )
45
- return True
43
+ elif args .action == "renew-certificate" :
44
+ montagu_renew_certificate (obj , cfg , args .extra_args )
46
45
47
46
48
47
def parse_args (argv = None ):
@@ -61,6 +60,18 @@ def montagu_status(obj):
61
60
obj .status ()
62
61
63
62
63
+ def montagu_renew_certificate (obj , cfg , extra_args ):
64
+ if cfg .ssl_mode != "acme" :
65
+ msg = "Proxy is not configured to use automatic certificates"
66
+ raise Exception (msg )
67
+
68
+ print ("Renewing certificates" )
69
+ (cert , key ) = obtain_certificate (cfg , extra_args )
70
+
71
+ container = obj .containers .get ("proxy" , cfg .container_prefix )
72
+ proxy_update_certificate (container , cert , key , reload = True )
73
+
74
+
64
75
def montagu_stop (obj , args , cfg ):
65
76
if args .volumes :
66
77
verify_data_loss (cfg )
@@ -123,9 +134,12 @@ def __init__(self, args):
123
134
self .action = "status"
124
135
elif args ["stop" ]:
125
136
self .action = "stop"
137
+ elif args ["renew-certificate" ]:
138
+ self .action = "renew-certificate"
126
139
127
140
self .pull = args ["--pull" ]
128
141
self .kill = args ["--kill" ]
129
142
self .volumes = args ["--volumes" ]
130
143
self .network = args ["--network" ]
131
144
self .version = args ["--version" ]
145
+ self .extra_args = args ["ARGS" ]
0 commit comments