feat: add various infrastructure check and automation scripts
This commit is contained in:
@@ -1,17 +1,34 @@
|
||||
import os
|
||||
import sys
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
pkey = paramiko.Ed25519Key.from_private_key_file(os.path.expanduser('~/.ssh/id_ed25519_snarfnet'))
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('140.44.4.75', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect("140.44.4.11", username="root", pkey=pkey, timeout=10)
|
||||
def run(cmd):
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
return stdout.read().decode().strip(), stderr.read().decode().strip()
|
||||
|
||||
cmd = "curl -s http://140.44.4.21:80/main.105b4163.async.js | grep -o -E '\"/api/[a-zA-Z0-9_/]+\"' | sort -u | head -n 30"
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
print("API ROUTES ON 140.44.4.21:")
|
||||
print(stdout.read().decode())
|
||||
client.close()
|
||||
cid, _ = run("echo 'Katzir476!' | sudo -S docker ps -q -f name=peanut_peanut")
|
||||
|
||||
# Check readdir in src/app or src
|
||||
script = """
|
||||
const fs = require('fs');
|
||||
function walk(dir) {
|
||||
let res = [];
|
||||
for (let f of fs.readdirSync(dir)) {
|
||||
let p = dir + '/' + f;
|
||||
if (fs.statSync(p).isDirectory()) res.push(...walk(p));
|
||||
else if (f.endsWith('.ts') || f.endsWith('.js') || f.endsWith('.tsx')) res.push(p);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
console.log(walk('src/app/api'));
|
||||
"""
|
||||
run(f"cat << 'EOF' > /tmp/walk.js\n{script}\nEOF")
|
||||
out, err = run(f"echo 'Katzir476!' | sudo -S docker exec -i {cid} node < /tmp/walk.js")
|
||||
print(out)
|
||||
if err: print(err)
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user