Browse Source

上傳檔案到 'KDAIS17'

allen 4 years ago
parent
commit
e63e7923f7
1 changed files with 24 additions and 3 deletions
  1. 24 3
      KDAIS17/aisky-mqttd

+ 24 - 3
KDAIS17/aisky-mqttd

@@ -262,16 +262,35 @@ def system_update_code():
     time.sleep(1)
     os.system('sudo chmod 777 /usr/sbin/aisky-mqttd')
     os.system('sudo chmod 777 /home/pi/udp_client.py')
-    time.sleep(5)
+    time.sleep(2)
     server_log('a033', '1')
     os.system('sudo reboot')
     time.sleep(10)
 
+def monitor():
+    os.system('sudo su')
+    os.system('rm -rf /home/pi/KDAIS')
+    os.system('git clone -b KDAIS17 --single-branch http://60.250.156.230:3000/fatwolf/KDAIS.git /home/pi/KDAIS')
+    time.sleep(3)
+    os.system('pip3 install psutil')
+    time.sleep(3)
+    os.system('pip3 install gpiozero')
+    time.sleep(3)
+    os.system('cp /home/pi/KDAIS/proc-wdtd.conf /etc/')
+    os.system('cp /home/pi/KDAIS/get_cpuusage.py /home/pi/')
+    time.sleep(1)
+    os.system('sudo chmod 777 /home/pi/get_cpuusage.py')
+    time.sleep(2)
+    server_log('a057', '1')
+    os.system('sudo reboot')
+    time.sleep(10)
+
 def stream0(msg):
     os.system('sudo su')
-    os.system('cd /hmoe/pi')
-    os.system('sudo nohup python3.5 /home/pi/udp_client.py>/home/pi/nohup.out 2>&1 &')
+    os.system('cd /home/pi')
+    os.system("ps aux | grep /home/pi/udp_client.py | awk '{print $2}' | xargs kill -9")
     time.sleep(2)
+    os.system('sudo nohup python3.5 /home/pi/udp_client.py>/home/pi/nohup.out 2>&1 &')
     server_log('a053', '1')
 
 def stream1(msg):
@@ -763,6 +782,8 @@ def on_message(client, userdata, msg):
         vpn_disconnect()
     elif (jsonmsg['command'] == 'a055'):
         timecheck(jsonmsg)
+    elif (jsonmsg['command'] == 'a057'):
+        monitor()
     elif (jsonmsg['node_id'] == "GTW009002017"):
         if (jsonmsg['command'] == 'a000'):
             call(jsonmsg)