fix(setup): preserve existing ip_range when re-running make setup
setup_cell.py now reads ip_range from cell_config.json before falling back to CELL_IP_RANGE env var, so re-running make setup on an existing install doesn't reset the .env subnet to the default 172.20.0.0/16. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -205,12 +205,23 @@ def write_compose_env(ip_range: str):
|
||||
print(f'[WARN] Could not write .env — containers will use built-in default IPs/ports')
|
||||
|
||||
|
||||
def _read_existing_ip_range() -> str:
|
||||
"""Read ip_range from existing cell_config.json if present, else return None."""
|
||||
cfg_path = os.path.join(ROOT, 'config', 'api', 'cell_config.json')
|
||||
try:
|
||||
existing = json.loads(open(cfg_path).read())
|
||||
return existing.get('_identity', {}).get('ip_range') or None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
cell_name = os.environ.get('CELL_NAME', 'mycell')
|
||||
domain = os.environ.get('CELL_DOMAIN', 'cell')
|
||||
vpn_address = os.environ.get('VPN_ADDRESS', '10.0.0.1/24')
|
||||
wg_port = int(os.environ.get('WG_PORT', '51820'))
|
||||
ip_range = os.environ.get('CELL_IP_RANGE', '172.20.0.0/16')
|
||||
# Prefer existing config ip_range over env var so `make setup` is safe to re-run
|
||||
ip_range = os.environ.get('CELL_IP_RANGE') or _read_existing_ip_range() or '172.20.0.0/16'
|
||||
|
||||
print('--- Personal Internet Cell: Setup ---')
|
||||
print(f' cell={cell_name} domain={domain} vpn={vpn_address} port={wg_port}')
|
||||
|
||||
Reference in New Issue
Block a user