feat: add various infrastructure check and automation scripts
This commit is contained in:
49
scripts/check_heimdall_db_deep.py
Normal file
49
scripts/check_heimdall_db_deep.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import paramiko
|
||||
import json
|
||||
|
||||
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("140.44.4.71", username="snarf", password="Katzir476!", timeout=10)
|
||||
|
||||
py_script = """python3 - << 'PYEOF'
|
||||
import sqlite3
|
||||
import shutil
|
||||
import time
|
||||
|
||||
db_path = '/var/lib/docker/volumes/heimdall_heimdall_config/_data/www/app.sqlite'
|
||||
|
||||
# Make a fresh backup
|
||||
shutil.copyfile(db_path, f"{db_path}.verified_backup_{int(time.time())}")
|
||||
print("Backup created at verified_backup!")
|
||||
|
||||
con = sqlite3.connect(db_path)
|
||||
cur = con.cursor()
|
||||
|
||||
print("=== USERS ===")
|
||||
for r in cur.execute("SELECT id, username, email, public_front FROM users").fetchall():
|
||||
print("User:", r)
|
||||
|
||||
print("\n=== ITEMS ===")
|
||||
rows = cur.execute("SELECT id, title, url, pinned, user_id, apporder FROM items").fetchall()
|
||||
print(f"Total items in DB: {len(rows)}")
|
||||
for r in rows:
|
||||
print("Item:", r)
|
||||
|
||||
print("\n=== SETTINGS ===")
|
||||
for r in cur.execute("SELECT * FROM settings").fetchall():
|
||||
print("Setting:", r)
|
||||
|
||||
PYEOF
|
||||
"""
|
||||
|
||||
_, o, e = c.exec_command(f"echo Katzir476! | sudo -S {py_script}")
|
||||
print(o.read().decode())
|
||||
print(e.read().decode())
|
||||
|
||||
# Check volume mount persistence
|
||||
_, o, _ = c.exec_command("echo Katzir476! | sudo -S ls -la /var/lib/docker/volumes/heimdall_heimdall_config/_data/www/")
|
||||
print("Files in Heimdall www volume:\n", o.read().decode())
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user