feat: add various infrastructure check and automation scripts
This commit is contained in:
41
scripts/test_proper_escape.py
Normal file
41
scripts/test_proper_escape.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import paramiko
|
||||
|
||||
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.81", username="rancher", key_filename=SSH_KEY, timeout=10)
|
||||
|
||||
def run_cmd(cmd):
|
||||
full_cmd = f"echo Katzir476! | sudo -S sh -c '{cmd}'"
|
||||
_, o, e = c.exec_command(full_cmd)
|
||||
return o.read().decode().strip(), e.read().decode().strip()
|
||||
|
||||
# Remove the bad unit
|
||||
run_cmd("rm -f /etc/systemd/system/var-lib-harvester-extrax2ddisks*")
|
||||
|
||||
# Write the properly named unit
|
||||
unit_name = r"var-lib-harvester-extra\x2ddisks-sdb.mount"
|
||||
content = """[Unit]
|
||||
Description=Harvester Extra Disk disk-sdb
|
||||
Before=rke2-server.service rke2-agent.service
|
||||
|
||||
[Mount]
|
||||
What=/dev/disk/by-uuid/b5471f4d-aa33-409a-8ba4-2330b98ebe80
|
||||
Where=/var/lib/harvester/extra-disks/sdb
|
||||
Type=ext4
|
||||
Options=defaults
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
"""
|
||||
run_cmd(f"cat << 'EOF' > '/etc/systemd/system/{unit_name}'\n{content}\nEOF")
|
||||
|
||||
out, err = run_cmd("systemctl daemon-reload && systemctl start 'var-lib-harvester-extra\\x2ddisks-sdb.mount' && systemctl status 'var-lib-harvester-extra\\x2ddisks-sdb.mount'")
|
||||
print("Status output:\n", out)
|
||||
if err: print("Error:\n", err)
|
||||
|
||||
out, _ = run_cmd("df -h | grep extra-disks")
|
||||
print("df -h output:\n", out)
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user