Add script to add new user debug for remote debugging
authorPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 08:45:38 +0000 (16:45 +0800)
committerPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 08:45:38 +0000 (16:45 +0800)
add-user.sh [new file with mode: 0755]
mqtt-client.py
suanzi-support
suanzi-support.service

diff --git a/add-user.sh b/add-user.sh
new file mode 100755 (executable)
index 0000000..f140ec5
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Add a new user named debug, with password hard2guess for remote debug
+# the suanzi-support daemon will be running as this user
+# run : sudo ./add-user.sh
+
+USER="debug"
+PASS="hard2guess"
+
+echo "Create $USER user"
+useradd -m "${USER}" || exit 1
+
+echo "set the password of $USER"
+echo -e "${PASS}\n${PASS}" | passwd "$USER"  || exit 1
+
+echo "Done"
+
index 59eff28..8a053d0 100644 (file)
@@ -23,7 +23,7 @@ if __name__ == '__main__':
         if msg.topic == id + '-response':
             port = msg.payload
             print 'port is', str(port)
-            print 'run ssh user@autossh.suanzi.ai -p ' + str(port) + ' to connect to  ' + id + ' device'
+            print 'run ssh debug@autossh.suanzi.ai -p ' + str(port) + ' to connect to  ' + id + ' device'
 
     client = mqtt.Client()
     client.on_connect = on_connect
index d016b06..678853d 100755 (executable)
@@ -7,7 +7,6 @@
 from subprocess import call, Popen, PIPE, STDOUT
 import paho.mqtt.client as mqtt
 import shlex
-import os
 import random
 from uuid import getnode as get_mac
 
@@ -67,7 +66,7 @@ class MyClient(mqtt.Client):
 
 if __name__ == '__main__':
     mac = hex(get_mac())
-    id = os.getenv('USER') + '-' + '{:0>12}'.format(mac[2:-1])
+    id = '{:0>12}'.format(mac[2:-1])
     print 'id is: ' , id
     client = MyClient(id)
     client.connect(MQTT_SERVER, MQTT_PORT, 60)
index 87f0081..dbf7a11 100644 (file)
@@ -3,7 +3,7 @@ Description= suanzi support daemon
 After=network-online.target
 
 [Service]
-User=debian
+User=debug
 Type=simple
 ExecStart=/usr/local/bin/suanzi-support
 ExecStop=/usr/bin/pkill -P $MAINPID