2021/9/2

mender : modify product device to use local demo server

先啟動 demo server。
在 source code 中找到 demo.crt
修改 /etc/mender/mender/conf :
參考mender.io build and install client from sources 看設定為 demo 的 conf:

device 的部份:
  • 依照 mender.conf 的 Servers : ServerURL 作為 update server
  • ServerCertificate 有的話,用這個作為 跟 server 溝通的憑證
# diff /data/backup/mender.conf /etc/mender/mender.conf 
--- /data/backup/mender.conf
+++ /etc/mender/mender.conf
@@ -24,13 +24,13 @@
     "StateScriptRetryTimeoutSeconds": 0,
     "StateScriptRetryIntervalSeconds": 0,
     "ModuleTimeoutSeconds": 0,
-    "ServerCertificate": "",
+    "ServerCertificate": "/data/demo.crt",
     "ServerURL": "",
     "UpdateLogPath": "",
-    "TenantToken": "eyJI......",
+    "TenantToken": "",
     "Servers": [
         {
-            "ServerURL": "https://hosted.mender.io"
+            "ServerURL": "https://docker.mender.io"
         }
     ]
 }
ServerURL 好像一定要概,不然會出現 Error:
level=error msg="Failure occurred while executing authorization request: Method: Post, URL: https://host.mender.io/api/devices/v1/authentication/auth_requests" func="github.com/mendersoftware/me
level=error msg="Authorize failed: transient error: authorization request failed: transient error: authorization request failed: Unknown url.Error type: Host validation error" func="github.com/m
level=info msg="State transition: authorize [Sync] -> authorize-wait [Idle]" func=github.com/mendersoftware/mender/app.transitionState file="/home/pi/mender-src/app/mender.go:461"
一定要用 docker.mender.io 的原因可能是因為 demo server 的 hosts 有加:
127.0.0.1 s3.docker.mender.io
127.0.0.1 docker.mender.io
demo.crt copy 過來,mender.conf只要改成這樣, demo server 上就可以看到 request device

demo server 基本照這個
其中,docker 的機器要改 /etc/hosts,加上上面的 mender.io 指到 127.0.0.1

沒有留言:

張貼留言