48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
import paramiko
|
|
import os
|
|
|
|
files_to_sync = [
|
|
("templates/operator.html", "/home/jetson/karung/templates/operator.html"),
|
|
("templates/monitoring.html", "/home/jetson/karung/templates/monitoring.html"),
|
|
("templates/base.html", "/home/jetson/karung/templates/base.html"),
|
|
("counter_dashboard.py", "/home/jetson/karung/counter_dashboard.py"),
|
|
("predict.py", "/home/jetson/karung/predict.py"),
|
|
(".env", "/home/jetson/karung/.env")
|
|
]
|
|
|
|
def run():
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect('192.168.192.96', username='jetson', password='jetson', timeout=10)
|
|
|
|
sftp = client.open_sftp()
|
|
|
|
print("Uploading updated files to Jetson...")
|
|
for local_f, remote_f in files_to_sync:
|
|
print(f"Uploading {local_f} -> {remote_f}")
|
|
sftp.put(local_f, remote_f)
|
|
|
|
sftp.close()
|
|
print("All files uploaded successfully!")
|
|
|
|
print("Restarting services on Jetson...")
|
|
cmd = "echo jetson | sudo -S systemctl restart karung-counter karung-counter-dashboard"
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
print("STDOUT:", stdout.read().decode('utf-8', errors='ignore'))
|
|
print("STDERR:", stderr.read().decode('utf-8', errors='ignore'))
|
|
|
|
# Check status
|
|
stdin, stdout, stderr = client.exec_command("systemctl status karung-counter-dashboard karung-counter --no-pager")
|
|
print("=== SERVICE STATUS ===")
|
|
print(stdout.read().decode('utf-8', errors='ignore').encode('ascii', errors='ignore').decode())
|
|
|
|
# Check listening ports
|
|
stdin, stdout, stderr = client.exec_command("netstat -tuln | grep -E '5000|5721'")
|
|
print("=== LISTENING PORTS ===")
|
|
print(stdout.read().decode('utf-8', errors='ignore'))
|
|
|
|
client.close()
|
|
|
|
if __name__ == '__main__':
|
|
run()
|