File: //tmp/ovh_insert2.sh
#!/bin/bash
SLUG="gabinet-masazu-piotr-czajkowski-kielce"
TITLE="Gabinet masażu Piotra Czajkowskiego w Kielcach – profesjonalne zabiegi"
IMG="https://adriangrabski.com/wp-content/uploads/2026/04/masazkielce.png"
declare -A DD=( [abagraf.com.pl]=2026-05-07 [agrokapital.pl]=2026-05-10 [baby-clinic.pl]=2026-05-13 [acercentrumogrodnicze.pl]=2026-05-17 [activerock.pl]=2026-05-20 [alcalary.pl]=2026-05-22 [aquatica.com.pl]=2026-05-24 )
for d in abagraf.com.pl agrokapital.pl baby-clinic.pl acercentrumogrodnicze.pl activerock.pl alcalary.pl aquatica.com.pl; do
P="/var/www/$d"; date="${DD[$d]}"
# --skip-themes --skip-plugins omija zepsuty motyw
WPU="sudo -u www-data wp --path=$P --allow-root --skip-themes --skip-plugins"
EX=$($WPU post list --post_type=post --name="$SLUG" --field=ID 2>/dev/null | head -1)
if [ -n "$EX" ]; then echo "$d|EXISTS|$EX|https://$d/$SLUG/"; continue; fi
HTML=$(python3 -c "import json;print(json.load(open('/tmp/bm_articles.json'))['$d'])" 2>/dev/null)
[ -z "$HTML" ] && { echo "$d|NOHTML||"; continue; }
PID=$($WPU post create --post_type=post --post_status=publish --post_title="$TITLE" --post_name="$SLUG" --post_date="$date 10:00:00" --post_content="$HTML" --porcelain 2>/dev/null | tail -1)
[ -z "$PID" ] && { echo "$d|FAIL2||"; continue; }
$WPU media import "$IMG" --post_id=$PID --featured_image >/dev/null 2>&1
CAT=$($WPU term list category --field=term_id --number=1 2>/dev/null | head -1)
[ -n "$CAT" ] && $WPU post term set $PID category $CAT >/dev/null 2>&1
$WPU rewrite flush >/dev/null 2>&1
echo "$d|OK|$PID|https://$d/$SLUG/"
done
# bernardyn retry (byl OK ale 404 publicznie - flush+cache)
P=/var/www/bernardyn.org.pl
sudo -u www-data wp --path=$P --allow-root --skip-themes --skip-plugins rewrite flush >/dev/null 2>&1