Files
dsh_ai1net_server/归档/迁移/域名迁移_ai1net_20260919/s4_followups.sh
T

33 lines
2.2 KiB
Bash
Raw Normal View History

set +e
V=/www/server/panel/vhost/nginx
TS=$(date +%Y%m%d-%H%M%S)
DB='postgres://dshs:[email protected]:15432/dshs'
echo "=== S4-0 取实例用户名(只打印名字) ==="
psql "$DB" -t -A -c "select name from users order by name limit 6" 2>&1 | head -8
echo "--- 表清单(若上面报错则看这里) ---"
psql "$DB" -t -A -c "select tablename from pg_tables where schemaname='public' order by tablename" 2>&1 | head -14
echo "=== S4-1 备份连带项两份 ==="
cp -a "$V/relay-direct.conf" "$V/relay-direct.conf.bak-dom-$TS"
cp -a "$V/dsh.alotbuy.com.conf" "$V/dsh.alotbuy.com.conf.bak-dom-$TS"
ls -l "$V"/relay-direct.conf.bak-dom-$TS "$V"/dsh.alotbuy.com.conf.bak-dom-$TS | awk '{print $5, $9}'
echo "=== S4-2 relay-direct.conf:Host 改写 → ai1net.com ==="
sed -i 's/^\([[:space:]]*proxy_set_header Host[[:space:]]*\)alotbuy\.com;/\1ai1net.com;/' "$V/relay-direct.conf"
grep -n "proxy_set_header Host" "$V/relay-direct.conf"
echo "=== S4-3 dsh.alotbuy.com.conf:map 目标 → 新域(⛔ 不动 server_name/正则) ==="
sed -i 's/^\([[:space:]]*default[[:space:]]*\)alotbuy\.com;/\1ai1net.com;/' "$V/dsh.alotbuy.com.conf"
sed -i 's/\$label\.alotbuy\.com;/$label.ai1net.com;/' "$V/dsh.alotbuy.com.conf"
sed -n '7,10p' "$V/dsh.alotbuy.com.conf"
echo "--- 确认 server_name 未被改(应仍是 alotbuy) ---"
grep -n "server_name" "$V/dsh.alotbuy.com.conf"
echo "=== S4-4 nginx -t + reload ==="
nginx -t 2>&1 | tail -1 && nginx -s reload 2>&1 | tail -1
sleep 1
echo "=== S4-5 兜底入口验收(源站侧) ==="
curl -sk --http1.1 -o /dev/null -w "relay-direct.ai1net /dshs-overlay/bootstrap => %{http_code}\n" -H "Host: relay-direct.ai1net.com" https://127.0.0.1/dshs-overlay/bootstrap
curl -sk --http1.1 -o /dev/null -w "relay-direct.ai1net /unknown => %{http_code}(应 404)\n" -H "Host: relay-direct.ai1net.com" https://127.0.0.1/unknown
curl -sk --http1.1 -o /dev/null -w "relay-direct.alotbuy /dshs-overlay/bootstrap => %{http_code}\n" -H "Host: relay-direct.alotbuy.com" https://127.0.0.1/dshs-overlay/bootstrap
curl -sk --http1.1 -o /dev/null -w "ai1net 门户 => %{http_code}\n" -H "Host: ai1net.com" https://127.0.0.1/portal.html