include .env

SERVICES = actualbudget gitea homepage linkding nextcloud photoprism restic syncthing traefik

# Default target: upload .env files for all services
upload: $(addprefix upload-,$(SERVICES))

# Target to upload .env file for a specific service
upload-%:
	@echo "🚀 Uploading .env file for $* service..."
	scp $*/.env $(REMOTE_USER)@$(REMOTE_HOST):$(REMOTE_PATH)/$*/
	@echo "✅ Uploaded .env file for $* service successfully."

	# Check if app.ini file exists for the service
	if [ -f "$*/app.ini" ]; then \
		echo "🚀 Uploading app.ini file for $* service..."; \
		scp $*/app.ini $(REMOTE_USER)@$(REMOTE_HOST):$(REMOTE_PATH)/$*/; \
		echo "✅ Uploaded app.ini file for $* service successfully."; \
	fi

# Usage instructions
help:
	@echo "📋 Usage: make [target]"
	@echo ""
	@echo "🎯 Targets:"
	@echo "  upload          📤 Upload .env files for all services"
	@echo "  upload-service  📤 Upload .env file for a specific service (e.g., upload-actualbudget)"