Undo the host.docker.internal approach from the previous commit — proper Docker networking routes Caddy to services by container name on the shared caddy_net, not via the host gateway. - lib/common.sh: configure_caddy_for_service now accepts either a plain port number (localhost:PORT fallback) or container:port (preferred). The Caddyfile entry uses the container name for direct Docker DNS routing. - services/caddy.sh: remove extra_hosts hack; update Caddyfile template comments to show container_name:port format - All service files: update configure_caddy_for_service calls to pass container_name:internal_port (e.g. "filebrowser:80", "mealie:9000"). Services using network_mode:host keep plain port numbers. - tools/manage_users.sh: new FileBrowser user-management script (deployed to ~/docker/filebrowser/ during installation). Manages users via the FileBrowser REST API: list, add, delete, passwd, scope, info commands. Documents username format (letters/numbers/hyphens/underscores), password rules (min 8 chars, letter + number required), and scope path convention relative to /srv (= FB_PATH on the host). https://claude.ai/code/session_01UZus2Q9gNTfUdqSMrhuX29
98 lines
2.3 KiB
Bash
98 lines
2.3 KiB
Bash
#!/bin/bash
|
|
# services/ntfy.sh — ntfy self-hosted push notification server.
|
|
# Part of the modular post-install system (sourced by setup.sh).
|
|
|
|
register_service ntfy utilities "Self-hosted push notifications (ntfy)" 8090
|
|
|
|
install_ntfy() {
|
|
require_docker || return 1
|
|
log_info "Installing ntfy..."
|
|
local NTFY_DIR="$DOCKER_DIR/ntfy"
|
|
|
|
if [ "$DRY_RUN" = true ]; then
|
|
echo "[DRY-RUN] Would create $NTFY_DIR"
|
|
return 0
|
|
fi
|
|
|
|
mkdir -p "$NTFY_DIR"
|
|
ensure_docker_dir_ownership "$NTFY_DIR"
|
|
cd "$NTFY_DIR" || return 1
|
|
|
|
cat > docker-compose.yml << 'NTFY_COMPOSE'
|
|
name: ntfy
|
|
|
|
services:
|
|
ntfy:
|
|
image: binwiederhier/ntfy:latest
|
|
container_name: ntfy
|
|
hostname: ntfy
|
|
restart: unless-stopped
|
|
command: serve
|
|
environment:
|
|
- TZ=${TZ}
|
|
volumes:
|
|
- ./cache:/var/cache/ntfy
|
|
- ./config:/etc/ntfy
|
|
ports:
|
|
- "8090:80"
|
|
networks:
|
|
- caddy_net
|
|
|
|
networks:
|
|
caddy_net:
|
|
external: true
|
|
name: ${CADDY_NET:-caddy_net}
|
|
NTFY_COMPOSE
|
|
|
|
cat > .env << NTFY_ENV
|
|
TZ=${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}
|
|
CADDY_NET=$SITE_CADDY_NET
|
|
NTFY_ENV
|
|
|
|
mkdir -p cache config
|
|
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$NTFY_DIR"
|
|
|
|
echo ""
|
|
log_success "ntfy configured at $NTFY_DIR"
|
|
|
|
configure_caddy_for_service "ntfy" "ntfy:80" "ntfy"
|
|
|
|
write_readme "$NTFY_DIR" << MD
|
|
# ntfy
|
|
|
|
Self-hosted push notification server. Send notifications from scripts to your
|
|
phone or browser.
|
|
|
|
## Access
|
|
- URL: http://localhost:8090
|
|
|
|
## Usage
|
|
- Send a notification: \`curl -d "Hello!" localhost:8090/mytopic\`
|
|
- Subscribe on phone: ntfy app -> Add subscription -> localhost:8090/mytopic
|
|
|
|
## Data
|
|
- Config: ./config (mounted to /etc/ntfy)
|
|
- Cache: ./cache (mounted to /var/cache/ntfy)
|
|
|
|
## Manage
|
|
\`\`\`
|
|
cd $NTFY_DIR
|
|
docker compose up -d # start
|
|
docker compose down # stop
|
|
docker compose logs -f # logs
|
|
\`\`\`
|
|
MD
|
|
|
|
local START_NTFY=""
|
|
prompt_yn "Start ntfy now? (y/n):" "y" START_NTFY
|
|
if [ "$START_NTFY" = "y" ] || [ "$START_NTFY" = "Y" ]; then
|
|
docker compose up -d 2>/dev/null && log_success "ntfy started" || log_warning "Failed to start"
|
|
fi
|
|
|
|
echo " Access at: http://localhost:8090"
|
|
echo ""
|
|
echo " Send notification: curl -d \"Hello!\" localhost:8090/mytopic"
|
|
echo " Subscribe on phone: ntfy app → Add subscription → localhost:8090/mytopic"
|
|
echo ""
|
|
}
|