Files

30 lines
1013 B
Python

#!/usr/bin/env python3
"""Inventory git repos on server with dirty status."""
import paramiko
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", username="root", password="Xiao4669805", timeout=20, allow_agent=False, look_for_keys=False)
cmd = r"""
set +e
for d in /var/www/nomadro.com /opt/douyinWEB /opt/tiktokWEB /opt/wauto /opt/xauto /opt/umami /opt/ntfy /var/www/nomadro-wp /var/www/nomadro-router; do
echo "======== $d"
if [ -d "$d/.git" ]; then
cd "$d"
git remote -v 2>/dev/null | head -3
git status -sb 2>/dev/null
git rev-parse --abbrev-ref HEAD 2>/dev/null
echo "dirty files:" $(git status --porcelain 2>/dev/null | wc -l)
else
echo "NO_GIT"
ls -la "$d" 2>/dev/null | head -8
fi
done
# also find other git repos under /opt /var/www
find /opt /var/www -maxdepth 3 -type d -name .git 2>/dev/null | sed 's|/.git||'
"""
_i, o, e = c.exec_command(cmd, timeout=60)
print((o.read() + e.read()).decode())
c.close()