-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathstart
More file actions
executable file
·73 lines (60 loc) · 2.25 KB
/
start
File metadata and controls
executable file
·73 lines (60 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
NOSTR_CONFIG_DIR="${PROJECT_ROOT}/.nostr"
SETTINGS_FILE="${NOSTR_CONFIG_DIR}/settings.yaml"
DEFAULT_SETTINGS_FILE="${PROJECT_ROOT}/resources/default-settings.yaml"
CURRENT_DIR=$(pwd)
if [[ ${CURRENT_DIR} =~ /scripts$ ]]; then
echo "Please run this script from the Nostream root folder, not the scripts directory."
echo "To do this, change up one directory, and then run the following command:"
echo "./scripts/start"
exit 1
fi
if [ "$EUID" -eq 0 ]
then echo "Error: Nostream should not be run as root."
exit 1
fi
# ── DNS Pre-flight Check ─────────────────────────────────────────────
YELLOW=$'\033[0;33m'
BOLD_YELLOW=$'\033[1;33m'
NC=$'\033[0m'
DNS_TEST_URL="https://dl-cdn.alpinelinux.org"
DNS_MAX_RETRIES=3
DNS_OK=false
BACKOFF=2
echo "Checking Docker DNS connectivity..."
for i in $(seq 1 $DNS_MAX_RETRIES); do
printf " [Attempt $i/$DNS_MAX_RETRIES] Testing resolution... "
if docker run --rm alpine wget --spider --timeout=5 "$DNS_TEST_URL" > /dev/null 2>&1; then
echo "Success"
DNS_OK=true
break
else
echo "Failed"
fi
[ "$i" -lt "$DNS_MAX_RETRIES" ] && sleep $BACKOFF && BACKOFF=$((BACKOFF * 2))
done
if [ "$DNS_OK" = false ]; then
cat <<EOF >&2
${BOLD_YELLOW} WARNING: Docker DNS resolution failed after $DNS_MAX_RETRIES attempts.${NC}
${YELLOW} Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org).
This is commonly caused by a DNS bridge conflict with systemd-resolved.
Suggested fixes:
1. Add DNS to /etc/docker/daemon.json:
{ "dns": ["8.8.8.8", "8.8.4.4"] }
2. Then run sudo systemctl restart docker
The build will continue, but may fail during package installation.${NC}
EOF
fi
if [[ ! -d "${NOSTR_CONFIG_DIR}" ]]; then
echo "Creating folder ${NOSTR_CONFIG_DIR}"
mkdir -p "${NOSTR_CONFIG_DIR}"
fi
if [[ ! -f "${SETTINGS_FILE}" ]]; then
echo "Copying ${DEFAULT_SETTINGS_FILE} to ${SETTINGS_FILE}"
cp "${DEFAULT_SETTINGS_FILE}" "${SETTINGS_FILE}"
fi
docker compose \
-f $DOCKER_COMPOSE_FILE \
up --build --remove-orphans $@