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:
@@ -1,7 +1,7 @@
|
|||||||
# Personal Internet Cell - Makefile
|
# Personal Internet Cell - Makefile
|
||||||
# Provides easy commands for managing the cell
|
# 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)
|
# 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")
|
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"
|
@echo " restore - Restore from backup"
|
||||||
|
|
||||||
# Setup commands
|
# 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..."
|
@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_NAME=$(or $(CELL_NAME),mycell) \
|
||||||
CELL_DOMAIN=$(or $(CELL_DOMAIN),cell) \
|
CELL_DOMAIN=$(or $(CELL_DOMAIN),cell) \
|
||||||
VPN_ADDRESS=$(or $(VPN_ADDRESS),10.0.0.1/24) \
|
VPN_ADDRESS=$(or $(VPN_ADDRESS),10.0.0.1/24) \
|
||||||
@@ -56,17 +68,17 @@ init-peers:
|
|||||||
# Management commands
|
# Management commands
|
||||||
start:
|
start:
|
||||||
@echo "Starting Personal Internet Cell..."
|
@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'"
|
@echo "Services started. Check status with 'make status'"
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
@echo "Stopping Personal Internet Cell..."
|
@echo "Stopping Personal Internet Cell..."
|
||||||
$(DC) down
|
PUID=$$(id -u) PGID=$$(id -g) $(DC) down
|
||||||
@echo "Services stopped."
|
@echo "Services stopped."
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
@echo "Restarting Personal Internet Cell..."
|
@echo "Restarting Personal Internet Cell..."
|
||||||
$(DC) restart
|
PUID=$$(id -u) PGID=$$(id -g) $(DC) restart
|
||||||
@echo "Services restarted."
|
@echo "Services restarted."
|
||||||
|
|
||||||
status:
|
status:
|
||||||
|
|||||||
+2
-2
@@ -164,8 +164,8 @@ services:
|
|||||||
container_name: cell-wireguard
|
container_name: cell-wireguard
|
||||||
environment:
|
environment:
|
||||||
- SERVERMODE=true
|
- SERVERMODE=true
|
||||||
- PUID=911
|
- PUID=${PUID:-1000}
|
||||||
- PGID=911
|
- PGID=${PGID:-1000}
|
||||||
ports:
|
ports:
|
||||||
- "51820:51820/udp"
|
- "51820:51820/udp"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user