74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Find neko-12 bind inode and fix browser-launch; start chrome."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
raw = (
|
|
Path(__file__).resolve().parents[1] / "backend" / "neko" / "browser-launch.sh"
|
|
).read_bytes().replace(b"\r\n", b"\n").replace(b"\r", b"\n")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=60,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=300,
|
|
)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/browser-launch-lf.sh", "wb") as f:
|
|
f.write(raw)
|
|
sftp.chmod("/tmp/browser-launch-lf.sh", 0o755)
|
|
sftp.close()
|
|
|
|
_i, o, e = c.exec_command(
|
|
r"""
|
|
set +e
|
|
INO=$(docker exec douyinweb-neko-12 sh -c 'ls -li /etc/neko/browser-launch.sh' | awk '{print $1}')
|
|
echo CTR_INO=$INO
|
|
echo 'find host:'
|
|
find /opt /root /tmp /var -xdev -inum "$INO" 2>/dev/null
|
|
MATCH=$(find /opt /root -xdev -inum "$INO" 2>/dev/null | head -1)
|
|
echo MATCH=$MATCH
|
|
if [ -n "$MATCH" ]; then
|
|
cat /tmp/browser-launch-lf.sh > "$MATCH"
|
|
sed -i 's/\r$//' "$MATCH"
|
|
chmod 755 "$MATCH"
|
|
echo overwritten
|
|
else
|
|
echo 'NO_MATCH — remount via docker restart (not recreate)'
|
|
# Ensure canonical path is good
|
|
cat /tmp/browser-launch-lf.sh > /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
sed -i 's/\r$//' /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
chmod 755 /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
# restart container keeps volumes/profile; remounts file by path
|
|
docker restart douyinweb-neko-12
|
|
sleep 12
|
|
fi
|
|
|
|
docker exec douyinweb-neko-12 sh -c 'ls -li /etc/neko/browser-launch.sh; head -1 /etc/neko/browser-launch.sh | od -c | head -1; grep -n jitless /etc/neko/browser-launch.sh | head -1; sh -n /etc/neko/browser-launch.sh && echo syntax_ok'
|
|
docker exec douyinweb-neko-12 sh -c '
|
|
rm -f /home/neko/.config/google-chrome/Singleton* 2>/dev/null
|
|
supervisorctl start google-chrome 2>/dev/null || supervisorctl restart google-chrome
|
|
sleep 10
|
|
supervisorctl status
|
|
tail -30 /var/log/neko/google-chrome.log 2>/dev/null
|
|
curl -sS -m 3 http://127.0.0.1:9222/json/version || echo no_devtools
|
|
'
|
|
docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}'
|
|
""",
|
|
timeout=180,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
print("DONE")
|