fix: make setup auto-installs deps and handles container-owned dirs

- Add check-deps target: auto-installs python3, pip3, cryptography via
  apt (with pip fallback) before running setup_cell.py
- Add sudo chown in setup to reclaim config/data dirs if containers have
  taken ownership (e.g. re-running setup after make start)
- Pass PUID/PGID=$(id -u/g) to docker-compose so linuxserver/wireguard
  chowns its config dir to the host user instead of hardcoded UID 911

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:19:44 -04:00
parent f908a3b74b
commit 1e43f408bc
2 changed files with 19 additions and 7 deletions
+17 -5
View File
@@ -1,7 +1,7 @@
# Personal Internet Cell - Makefile
# Provides easy commands for managing the cell
.PHONY: help start stop restart status logs clean setup init-peers build build-api build-webui
.PHONY: help start stop restart status logs clean setup check-deps init-peers build build-api build-webui
# Detect docker compose command (v2 plugin preferred, fallback to v1 standalone)
DC := $(shell docker compose version >/dev/null 2>&1 && echo "docker compose" || echo "docker-compose")
@@ -38,8 +38,20 @@ help:
@echo " restore - Restore from backup"
# Setup commands
setup:
check-deps:
@echo "Checking system dependencies..."
@which python3 >/dev/null 2>&1 || (echo "Installing python3..." && sudo apt-get install -y python3)
@which pip3 >/dev/null 2>&1 || (echo "Installing pip3..." && sudo apt-get install -y python3-pip)
@python3 -c "import cryptography" 2>/dev/null || \
(echo "Installing python3-cryptography..." && \
(sudo apt-get install -y python3-cryptography 2>/dev/null || \
pip3 install --break-system-packages cryptography 2>/dev/null || \
pip3 install cryptography))
@echo "Dependencies OK."
setup: check-deps
@echo "Setting up Personal Internet Cell..."
@sudo chown -R $$(id -u):$$(id -g) config/ data/ 2>/dev/null || true
CELL_NAME=$(or $(CELL_NAME),mycell) \
CELL_DOMAIN=$(or $(CELL_DOMAIN),cell) \
VPN_ADDRESS=$(or $(VPN_ADDRESS),10.0.0.1/24) \
@@ -56,17 +68,17 @@ init-peers:
# Management commands
start:
@echo "Starting Personal Internet Cell..."
$(DC) up -d --build
PUID=$$(id -u) PGID=$$(id -g) $(DC) up -d --build
@echo "Services started. Check status with 'make status'"
stop:
@echo "Stopping Personal Internet Cell..."
$(DC) down
PUID=$$(id -u) PGID=$$(id -g) $(DC) down
@echo "Services stopped."
restart:
@echo "Restarting Personal Internet Cell..."
$(DC) restart
PUID=$$(id -u) PGID=$$(id -g) $(DC) restart
@echo "Services restarted."
status:
+2 -2
View File
@@ -164,8 +164,8 @@ services:
container_name: cell-wireguard
environment:
- SERVERMODE=true
- PUID=911
- PGID=911
- PUID=${PUID:-1000}
- PGID=${PGID:-1000}
ports:
- "51820:51820/udp"
volumes: