Compare commits
2
Commits
b286b0a305
...
21b6f50613
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21b6f50613 | ||
|
|
92a0fd76cb |
@@ -0,0 +1,5 @@
|
|||||||
|
# ShellCheck configuration for the TSYS Developer Support Stack
|
||||||
|
# These rules are inherent to the environment-driven (dynamic source) design:
|
||||||
|
# SC1090 - can't follow non-constant source (e.g. `source "$ENV_FILE"`)
|
||||||
|
# SC1091 - not following external file specified as input (demo.env)
|
||||||
|
disable=SC1090,SC1091
|
||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Kiwix bootstrap: ensure a sample ZIM file is present, then serve it.
|
||||||
|
#
|
||||||
|
# ZIM filenames on download.kiwix.org are date-stamped and rotate monthly,
|
||||||
|
# so hard-coded URLs rot quickly. Instead this script resolves the current
|
||||||
|
# filename from the Kiwix OPDS catalog, which always points at the live file.
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
ZIM_DIR=/data
|
||||||
|
ZIM_FILE=devdocs_en_lit.zim
|
||||||
|
CATALOG_URL='https://library.kiwix.org/catalog/v2/entries?name=devdocs_en_lit&count=1'
|
||||||
|
MAX_ATTEMPTS=6
|
||||||
|
RETRY_DELAY=5
|
||||||
|
|
||||||
|
if ! ls "$ZIM_DIR"/*.zim >/dev/null 2>&1; then
|
||||||
|
echo "[kiwix] No ZIM files found; resolving a sample ZIM from the Kiwix catalog..."
|
||||||
|
attempt=0
|
||||||
|
while [ "$attempt" -lt "$MAX_ATTEMPTS" ]; do
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
zim_url=$(wget -q -O - "$CATALOG_URL" 2>/dev/null \
|
||||||
|
| grep -o 'https://[^"]*\.zim\.meta4' | head -n1 \
|
||||||
|
| sed 's/\.meta4$//')
|
||||||
|
if [ -n "$zim_url" ]; then
|
||||||
|
echo "[kiwix] Downloading: $zim_url"
|
||||||
|
if wget -q --timeout=60 -O "$ZIM_DIR/$ZIM_FILE" "$zim_url"; then
|
||||||
|
echo "[kiwix] Download complete."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
rm -f "$ZIM_DIR/$ZIM_FILE"
|
||||||
|
echo "[kiwix] Download failed; retrying in ${RETRY_DELAY}s..."
|
||||||
|
else
|
||||||
|
echo "[kiwix] Catalog lookup failed; retrying in ${RETRY_DELAY}s..."
|
||||||
|
fi
|
||||||
|
sleep "$RETRY_DELAY"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ls "$ZIM_DIR"/*.zim >/dev/null 2>&1; then
|
||||||
|
echo "[kiwix] Starting kiwix-serve..."
|
||||||
|
exec kiwix-serve --port 8080 "$ZIM_DIR"/*.zim
|
||||||
|
else
|
||||||
|
echo "[kiwix] No ZIM files available; sleeping indefinitely."
|
||||||
|
exec sleep infinity
|
||||||
|
fi
|
||||||
@@ -750,23 +750,11 @@ services:
|
|||||||
- "${KIWIX_PORT}:8080"
|
- "${KIWIX_PORT}:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ${COMPOSE_PROJECT_NAME}_kiwix_data:/data
|
- ${COMPOSE_PROJECT_NAME}_kiwix_data:/data
|
||||||
|
- ./config/kiwix/bootstrap.sh:/bootstrap.sh:ro
|
||||||
entrypoint: []
|
entrypoint: []
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- sh
|
||||||
- -c
|
- /bootstrap.sh
|
||||||
- |
|
|
||||||
if ! ls /data/*.zim 1>/dev/null 2>&1; then
|
|
||||||
echo 'No ZIM files found. Downloading sample ZIM...';
|
|
||||||
wget -q -O /data/demo.zim
|
|
||||||
'https://download.kiwix.org/zim/other/bleedingedge_climate-change_en.zim'
|
|
||||||
|| echo 'Download failed';
|
|
||||||
fi
|
|
||||||
if ls /data/*.zim 1>/dev/null 2>&1; then
|
|
||||||
exec kiwix-serve /data/*.zim
|
|
||||||
else
|
|
||||||
echo 'No ZIM files available, sleeping indefinitely'
|
|
||||||
exec sleep infinity
|
|
||||||
fi
|
|
||||||
environment:
|
environment:
|
||||||
- PUID=${DEMO_UID}
|
- PUID=${DEMO_UID}
|
||||||
- PGID=${DEMO_GID}
|
- PGID=${DEMO_GID}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ test_service_health() {
|
|||||||
log_test "Service health"
|
log_test "Service health"
|
||||||
local unhealthy=0
|
local unhealthy=0
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
local name status
|
local name
|
||||||
name=$(echo "$line" | awk '{print $1}')
|
name=$(echo "$line" | awk '{print $1}')
|
||||||
[[ "$name" == "NAMES" || -z "$name" ]] && continue
|
[[ "$name" == "NAMES" || -z "$name" ]] && continue
|
||||||
if echo "$line" | grep -q "(healthy)"; then
|
if echo "$line" | grep -q "(healthy)"; then
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ BLUE='\033[0;34m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
log_validation() { echo -e "${BLUE}[VALIDATE]${NC} $1"; }
|
log_validation() { echo -e "${BLUE}[VALIDATE]${NC} $1"; }
|
||||||
log_pass() { echo -e "${GREEN}[PASS]${NC} $1"; ((VALIDATION_PASSED++)); }
|
log_pass() { echo -e "${GREEN}[PASS]${NC} $1"; VALIDATION_PASSED=$((VALIDATION_PASSED + 1)); }
|
||||||
log_fail() { echo -e "${RED}[FAIL]${NC} $1"; ((VALIDATION_FAILED++)); }
|
log_fail() { echo -e "${RED}[FAIL]${NC} $1"; VALIDATION_FAILED=$((VALIDATION_FAILED + 1)); }
|
||||||
|
|
||||||
validate_yaml_files() {
|
validate_yaml_files() {
|
||||||
log_validation "Validating YAML files with yamllint..."
|
log_validation "Validating YAML files with yamllint..."
|
||||||
|
|||||||
Reference in New Issue
Block a user