150 lines
6.7 KiB
Bash
150 lines
6.7 KiB
Bash
#!/bin/bash
|
|
# Bootstrap English WordPress for nomadro.live (idempotent-ish).
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$DIR"
|
|
|
|
if [[ ! -f .env ]]; then
|
|
echo "Missing .env"
|
|
exit 1
|
|
fi
|
|
# shellcheck disable=SC1091
|
|
source .env
|
|
|
|
WP() {
|
|
docker compose --profile tools run --rm wpcli "$@"
|
|
}
|
|
|
|
echo "==> Waiting for WordPress HTTP..."
|
|
for i in $(seq 1 60); do
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:8089" || true)
|
|
if [[ "$code" =~ ^(200|301|302|403)$ ]]; then
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
if ! WP core is-installed >/dev/null 2>&1; then
|
|
echo "==> Installing WordPress (English)"
|
|
WP core install \
|
|
--url="https://nomadro.live" \
|
|
--title="Nomadro Live" \
|
|
--admin_user="${WP_ADMIN_USER}" \
|
|
--admin_password="${WP_ADMIN_PASSWORD}" \
|
|
--admin_email="${WP_ADMIN_EMAIL}" \
|
|
--skip-email
|
|
fi
|
|
|
|
echo "==> Core settings"
|
|
WP language core install en_US --activate || true
|
|
WP option update blogdescription "Guides for live-stream monitoring, creator operations, and event automation"
|
|
WP option update WPLANG ""
|
|
WP option update blog_public 1
|
|
WP option update timezone_string "UTC"
|
|
WP option update date_format "F j, Y"
|
|
WP option update time_format "g:i a"
|
|
WP option update start_of_week 1
|
|
WP option update show_on_front posts
|
|
WP rewrite structure '/%postname%/' --hard
|
|
WP rewrite flush --hard
|
|
|
|
echo "==> Theme + essentials"
|
|
WP theme install twentytwentyfive --activate || WP theme activate twentytwentyfive || true
|
|
WP plugin install wordpress-seo --activate || true
|
|
WP option patch update wpseo_titles noindex-author-wpseo true || true
|
|
|
|
HELLO_ID=$(WP post list --post_type=post --name=hello-world --field=ID 2>/dev/null || true)
|
|
if [[ -n "${HELLO_ID}" ]]; then
|
|
WP post delete "${HELLO_ID}" --force || true
|
|
fi
|
|
SAMPLE_ID=$(WP post list --post_type=page --name=sample-page --field=ID 2>/dev/null || true)
|
|
if [[ -n "${SAMPLE_ID}" ]]; then
|
|
WP post delete "${SAMPLE_ID}" --force || true
|
|
fi
|
|
# Default Privacy Policy page (often a draft) collides with our slug.
|
|
WP post list --post_type=page --post_status=any --format=ids | tr ' ' '\n' | while read -r pid; do
|
|
[ -z "$pid" ] && continue
|
|
name=$(WP post get "$pid" --field=post_name 2>/dev/null || true)
|
|
status=$(WP post get "$pid" --field=post_status 2>/dev/null || true)
|
|
if [[ "$name" == "privacy-policy" && "$status" != "publish" ]]; then
|
|
WP post delete "$pid" --force || true
|
|
fi
|
|
done
|
|
|
|
create_page() {
|
|
local slug="$1"
|
|
local title="$2"
|
|
local file="$3"
|
|
local existing
|
|
existing=$(WP post list --post_type=page --name="$slug" --field=ID 2>/dev/null || true)
|
|
if [[ -n "$existing" ]]; then
|
|
echo "Page exists: $slug ($existing)"
|
|
return
|
|
fi
|
|
WP post create "$file" --post_type=page --post_title="$title" --post_name="$slug" --post_status=publish
|
|
}
|
|
|
|
create_post() {
|
|
local slug="$1"
|
|
local title="$2"
|
|
local file="$3"
|
|
local existing
|
|
existing=$(WP post list --post_type=post --name="$slug" --field=ID 2>/dev/null || true)
|
|
if [[ -n "$existing" ]]; then
|
|
echo "Post exists: $slug ($existing)"
|
|
return
|
|
fi
|
|
WP post create "$file" --post_type=post --post_title="$title" --post_name="$slug" --post_status=publish
|
|
}
|
|
|
|
echo "==> Policy / trust pages"
|
|
create_page about "About Nomadro Live" /content/about.html
|
|
create_page contact "Contact" /content/contact.html
|
|
create_page privacy-policy "Privacy Policy" /content/privacy-policy.html
|
|
create_page terms "Terms of Service" /content/terms.html
|
|
create_page disclaimer "Disclaimer" /content/disclaimer.html
|
|
|
|
echo "==> English articles"
|
|
create_post what-is-a-live-monitoring-toolkit "What Is a Live Stream Monitoring Toolkit?" /content/posts/01-live-monitoring-toolkit.html
|
|
create_post how-to-track-live-gifts "How to Track Live Gifts Without Missing Events" /content/posts/02-gift-tracking.html
|
|
create_post multi-channel-live-monitoring "Multi-Channel Live Monitoring for Small Teams" /content/posts/03-multi-channel-ops.html
|
|
create_post webhook-automation-for-lives "Webhook Automation for Live Stream Events" /content/posts/04-webhook-automation.html
|
|
create_post desktop-vs-android-live-monitoring "Desktop vs Android for Live Monitoring" /content/posts/05-desktop-vs-android.html
|
|
create_post creator-ops-dashboard "Building a Creator Ops Dashboard That Gets Used" /content/posts/06-creator-ops-dashboard.html
|
|
create_post chat-moderation-workflow "Chat Moderation Workflows for Live Streams" /content/posts/07-chat-moderation-workflow.html
|
|
create_post reading-viewer-trend-charts "How to Read Viewer Trend Charts During a Live" /content/posts/08-viewer-trend-charts.html
|
|
create_post live-session-archives "Local Session Archives for Live Operations" /content/posts/09-session-archives.html
|
|
create_post overnight-live-coverage "Staffing Overnight Live Coverage Without Burnout" /content/posts/10-overnight-coverage.html
|
|
create_post notification-design-for-lives "Notification Design for High-Value Live Events" /content/posts/11-notification-design.html
|
|
create_post rest-api-live-event-tooling "REST API Basics for Live Event Tooling" /content/posts/12-rest-api-for-live-events.html
|
|
create_post reducing-false-alerts "Reducing False Alerts in Live Monitoring" /content/posts/13-false-alerts.html
|
|
create_post live-session-runbook "Preparing a One-Page Live Session Runbook" /content/posts/14-live-runbook.html
|
|
create_post creator-tooling-checklist "A Cross-Platform Creator Tooling Checklist" /content/posts/15-creator-tooling-checklist.html
|
|
create_post engagement-beyond-viewer-count "Measuring Engagement Beyond Viewer Count" /content/posts/16-engagement-beyond-viewers.html
|
|
create_post handling-live-disconnects "Handling Stream Disconnects and Reconnects" /content/posts/17-disconnects-and-reconnects.html
|
|
create_post privacy-for-live-logs "Privacy and Data Retention for Live Logs" /content/posts/18-privacy-live-logs.html
|
|
create_post hardware-for-always-on-monitoring "Choosing Hardware for Always-On Live Monitoring" /content/posts/19-hardware-for-24-7.html
|
|
create_post onboarding-live-operators "Onboarding a New Operator to Live Monitoring" /content/posts/20-onboarding-operators.html
|
|
|
|
MENU_ID=$(WP menu list --fields=term_id,name --format=csv 2>/dev/null | awk -F, '$2=="Footer"{print $1; exit}' || true)
|
|
if [[ -z "${MENU_ID}" ]]; then
|
|
MENU_ID=$(WP menu create "Footer" --porcelain)
|
|
fi
|
|
for slug in about contact privacy-policy terms disclaimer; do
|
|
PAGE_ID=$(WP post list --post_type=page --name="$slug" --field=ID)
|
|
if [[ -n "$PAGE_ID" ]]; then
|
|
WP menu item add-post "$MENU_ID" "$PAGE_ID" || true
|
|
fi
|
|
done
|
|
WP menu location assign "$MENU_ID" footer || true
|
|
WP menu location assign "$MENU_ID" primary || true
|
|
|
|
PRIVACY_ID=$(WP post list --post_type=page --name=privacy-policy --field=ID)
|
|
if [[ -n "${PRIVACY_ID}" ]]; then
|
|
WP option update wp_page_for_privacy_policy "${PRIVACY_ID}" || true
|
|
fi
|
|
|
|
echo "==> Done. Admin: https://nomadro.live/wp-admin/"
|