55# %% auto 0
66__all__ = ['automation_path' , 'srvs_path' , 'rts_path' , 'get_id' , 'get_path' , 'gid' , 'has_id' , 'gcfg' , 'has_path' , 'pid' , 'pcfg' ,
77 'nested_setdict' , 'path2keys' , 'keys2path' , 'nested_setcfg' , 'init_path' , 'get_acme_config' ,
8- 'add_tls_internal_config' , 'add_acme_config' , 'init_routes' , 'setup_caddy ' , 'add_route ' , 'del_id ' ,
9- 'add_reverse_proxy' , 'add_wildcard_route' , 'add_sub_reverse_proxy' ]
8+ 'add_tls_internal_config' , 'add_acme_config' , 'init_routes' , 'setup_pki_trust ' , 'setup_caddy ' , 'add_route ' ,
9+ 'del_id' , ' add_reverse_proxy' , 'add_wildcard_route' , 'add_sub_reverse_proxy' ]
1010
1111# %% ../nbs/00_core.ipynb 3
1212import os , subprocess , httpx , json
@@ -142,28 +142,36 @@ def init_routes(srv_name='srv0', skip=1):
142142 pcfg (ir , f"{ srvs_path } /{ srv_name } " )
143143
144144# %% ../nbs/00_core.ipynb 37
145+ def setup_pki_trust (install_trust ):
146+ "Configure PKI certificate authority trust installation"
147+ if install_trust is None : return
148+ pki_path = '/apps/pki/certificate_authorities/local'
149+ init_path (pki_path , skip = 1 )
150+ pcfg ({"install_trust" : install_trust }, pki_path )
151+
152+ # %% ../nbs/00_core.ipynb 38
145153def setup_caddy (
146154 cf_token = None , # Cloudflare API token
147155 srv_name = 'srv0' , # Server name in the Caddyfile
148156 local :bool = False , # Whether or not this is for localdev or deployment
149- skip_install_trust :bool = None ): # Skip installing trust store
157+ install_trust :bool = None ): # Install trust store?
150158 "Create SSL config and HTTP app skeleton"
151- if skip_install_trust is not None : pcfg (skip_install_trust , '/skip_install_trust' , method = 'patch' )
152159 if local : add_tls_internal_config ()
153160 else : add_acme_config (cf_token )
161+ setup_pki_trust (install_trust )
154162 init_routes (srv_name )
155163
156- # %% ../nbs/00_core.ipynb 40
164+ # %% ../nbs/00_core.ipynb 41
157165def add_route (route ):
158166 "Add `route` dict to config"
159167 return pcfg (route , rts_path )
160168
161- # %% ../nbs/00_core.ipynb 41
169+ # %% ../nbs/00_core.ipynb 42
162170def del_id (id ):
163171 "Delete route for `id` (e.g. a host)"
164172 xdelete (get_id (id ))
165173
166- # %% ../nbs/00_core.ipynb 43
174+ # %% ../nbs/00_core.ipynb 44
167175def add_reverse_proxy (from_host , to_url ):
168176 "Create a reverse proxy handler"
169177 if has_id (from_host ): del_id (from_host )
@@ -176,7 +184,7 @@ def add_reverse_proxy(from_host, to_url):
176184 }
177185 add_route (route )
178186
179- # %% ../nbs/00_core.ipynb 47
187+ # %% ../nbs/00_core.ipynb 48
180188def add_wildcard_route (domain ):
181189 "Add a wildcard subdomain"
182190 route = {
@@ -189,7 +197,7 @@ def add_wildcard_route(domain):
189197 }
190198 add_route (route )
191199
192- # %% ../nbs/00_core.ipynb 49
200+ # %% ../nbs/00_core.ipynb 50
193201def add_sub_reverse_proxy (
194202 domain ,
195203 subdomain ,
0 commit comments