From d6b7a869e28ed6d21e1943c6e95e5e1a05738cd1 Mon Sep 17 00:00:00 2001 From: Nicola Peditto Date: Tue, 9 May 2017 19:56:18 +0200 Subject: [PATCH] Guides and scripts updated. --- docs/arduinoyun.md | 18 +++++++++--------- docs/raspberrypi2.md | 1 + docs/raspberrypi3.md | 17 +++++++++-------- docs/ubuntu1404.md | 19 ++++++++++--------- docs/ubuntu1604.md | 17 +++++++++-------- etc/systemd/system/s4t-lightning-rod.service | 2 ++ 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/docs/arduinoyun.md b/docs/arduinoyun.md index ad16d41..c8a5a23 100644 --- a/docs/arduinoyun.md +++ b/docs/arduinoyun.md @@ -74,15 +74,15 @@ source /etc/profile Note that you need the NODE_ID that is the code returned by the IoTronic service after node registration. ``` -cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/iotronic-lightning-rod/settings.json -cp /var/lib/iotronic/iotronic-lightning-rod/modules/plugins-manager/plugins.example.json /var/lib/iotronic/iotronic-lightning-rod/plugins/plugins.json -cp /var/lib/iotronic/iotronic-lightning-rod/modules/drivers-manager/drivers.example.json /var/lib/iotronic/iotronic-lightning-rod/drivers/drivers.json - -sed -i "s/\"device\":.*\"\"/\"device\": \"arduino_yun\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json +cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/settings.json +cp /var/lib/iotronic/iotronic-lightning-rod/modules/plugins-manager/plugins.example.json /var/lib/iotronic/plugins/plugins.json +cp /var/lib/iotronic/iotronic-lightning-rod/modules/drivers-manager/drivers.example.json /var/lib/iotronic/drivers/drivers.json + +sed -i "s/\"device\":.*\"\"/\"device\": \"arduino_yun\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json ``` ##### Configure logrotate diff --git a/docs/raspberrypi2.md b/docs/raspberrypi2.md index 5e37bec..eeb89c3 100644 --- a/docs/raspberrypi2.md +++ b/docs/raspberrypi2.md @@ -68,6 +68,7 @@ mv s4t-lightning-rod iotronic-lightning-rod mkdir plugins && mkdir drivers cp /var/lib/iotronic/iotronic-lightning-rod/etc/systemd/system/s4t-lightning-rod.service /etc/systemd/system/lightning-rod.service +sed -i "s/Environment=\"LIGHTNINGROD_HOME=\"/Environment=\"LIGHTNINGROD_HOME=\/var\/lib\/iotronic\/iotronic-lightning-rod\"/g" /etc/systemd/system/lightning-rod.service chmod +x /etc/systemd/system/lightning-rod.service systemctl daemon-reload diff --git a/docs/raspberrypi3.md b/docs/raspberrypi3.md index 8ec4172..e6e143f 100644 --- a/docs/raspberrypi3.md +++ b/docs/raspberrypi3.md @@ -78,6 +78,7 @@ mv s4t-lightning-rod iotronic-lightning-rod mkdir plugins && mkdir drivers cp /var/lib/iotronic/iotronic-lightning-rod/etc/systemd/system/s4t-lightning-rod.service /etc/systemd/system/lightning-rod.service +sed -i "s/Environment=\"LIGHTNINGROD_HOME=\"/Environment=\"LIGHTNINGROD_HOME=\/var\/lib\/iotronic\/iotronic-lightning-rod\"/g" /etc/systemd/system/lightning-rod.service chmod +x /etc/systemd/system/lightning-rod.service systemctl daemon-reload @@ -92,15 +93,15 @@ source /etc/profile Note that you need the NODE_ID that is the code returned by the IoTronic service after node registration. ``` -cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/iotronic-lightning-rod/settings.json -cp /var/lib/iotronic/iotronic-lightning-rod/plugins.example.json /var/lib/iotronic/iotronic-lightning-rod/plugins/plugins.json -cp /var/lib/iotronic/iotronic-lightning-rod/drivers.example.json /var/lib/iotronic/iotronic-lightning-rod/drivers/drivers.json +cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/settings.json +cp /var/lib/iotronic/iotronic-lightning-rod/plugins.example.json /var/lib/iotronic/plugins/plugins.json +cp /var/lib/iotronic/iotronic-lightning-rod/drivers.example.json /var/lib/iotronic/drivers/drivers.json -sed -i "s/\"device\":.*\"\"/\"device\": \"raspberry_pi\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json +sed -i "s/\"device\":.*\"\"/\"device\": \"raspberry_pi\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json ``` ##### Configure logrotate diff --git a/docs/ubuntu1404.md b/docs/ubuntu1404.md index 1a8da68..3322435 100644 --- a/docs/ubuntu1404.md +++ b/docs/ubuntu1404.md @@ -56,7 +56,8 @@ git clone git://github.com/MDSLab/s4t-lightning-rod.git mv s4t-lightning-rod iotronic-lightning-rod mkdir plugins && mkdir drivers -cp etc/init.d/s4t-lightning-rod_ubu14 /etc/init.d/lightning-rod +cp /var/lib/iotronic/iotronic-lightning-rod/etc/init.d/s4t-lightning-rod_yun /etc/init.d/lightning-rod +sed -i "s//export LIGHTNINGROD_HOME=\/var\/lib\/iotronic\/iotronic-lightning-rod/g" /etc/init.d/lightning-rod chmod +x /etc/init.d/lightning-rod chmod +x /var/lib/iotronic/iotronic-lightning-rod/lr-server.js @@ -70,15 +71,15 @@ source /etc/environment > /dev/null ##### Configure Lightning-rod Note that you will need the IP address of a working instance of a WAMP router (), the IP address of a working instance of a Websocket reverse tunnel server (), and the UUID of the node that you need to have previously registered on the IoTronic (). Also, note that if while installing the IoTronic service, you configured a custom port and realm name for the WAMP router or a custom port for the Websocket reverse tunnel server, you will need to manually change the setting.json, accordingly. ``` -cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/iotronic-lightning-rod/settings.json -cp /var/lib/iotronic/iotronic-lightning-rod/plugins.example.json /var/lib/iotronic/iotronic-lightning-rod/plugins/plugins.json -cp /var/lib/iotronic/iotronic-lightning-rod/drivers.example.json /var/lib/iotronic/iotronic-lightning-rod/drivers/drivers.json +cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/settings.json +cp /var/lib/iotronic/iotronic-lightning-rod/plugins.example.json /var/lib/iotronic/plugins/plugins.json +cp /var/lib/iotronic/iotronic-lightning-rod/drivers.example.json /var/lib/iotronic/drivers/drivers.json -sed -i "s/\"device\":.*\"\"/\"device\": \"laptop\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/local\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json +sed -i "s/\"device\":.*\"\"/\"device\": \"laptop\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/local\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json ``` ##### Configure logrotate diff --git a/docs/ubuntu1604.md b/docs/ubuntu1604.md index 4da2fdc..f957f4b 100644 --- a/docs/ubuntu1604.md +++ b/docs/ubuntu1604.md @@ -66,6 +66,7 @@ mv s4t-lightning-rod iotronic-lightning-rod mkdir plugins && mkdir drivers cp /var/lib/iotronic/iotronic-lightning-rod/etc/systemd/system/s4t-lightning-rod.service /etc/systemd/system/lightning-rod.service +sed -i "s/Environment=\"LIGHTNINGROD_HOME=\"/Environment=\"LIGHTNINGROD_HOME=\/var\/lib\/iotronic\/iotronic-lightning-rod\"/g" /etc/systemd/system/lightning-rod.service chmod +x /etc/systemd/system/lightning-rod.service systemctl daemon-reload @@ -80,15 +81,15 @@ source /etc/environment > /dev/null ##### Configure Lightning-rod Note that you will need the IP address of a working instance of a WAMP router (), the IP address of a working instance of a Websocket reverse tunnel server (), and the UUID of the node that you need to have previously registered on the IoTronic (). Also, note that if while installing the IoTronic service, you configured a custom port and realm name for the WAMP router or a custom port for the Websocket reverse tunnel server, you will need to manually change the setting.json, accordingly. ``` -cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/iotronic-lightning-rod/settings.json -cp /var/lib/iotronic/iotronic-lightning-rod/modules/plugins-manager/plugins.example.json /var/lib/iotronic/iotronic-lightning-rod/plugins/plugins.json -cp /var/lib/iotronic/iotronic-lightning-rod/modules/drivers-manager/drivers.example.json /var/lib/iotronic/iotronic-lightning-rod/drivers/drivers.json +cp /var/lib/iotronic/iotronic-lightning-rod/settings.example.json /var/lib/iotronic/settings.json +cp /var/lib/iotronic/iotronic-lightning-rod/modules/plugins-manager/plugins.example.json /var/lib/iotronic/plugins/plugins.json +cp /var/lib/iotronic/iotronic-lightning-rod/modules/drivers-manager/drivers.example.json /var/lib/iotronic/drivers/drivers.json -sed -i "s/\"device\":.*\"\"/\"device\": \"laptop\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json -sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/iotronic-lightning-rod/settings.json +sed -i "s/\"device\":.*\"\"/\"device\": \"laptop\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"code\":.*\"\"/\"code\": \"\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"bin\":.*\"\"/\"bin\": \"\/usr\/lib\/node_modules\/node-reverse-wstunnel\/bin\/wstt.js\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_wamp\":.*\"\"/\"url_wamp\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json +sed -i "s/\"url_reverse\":.*\"\"/\"url_reverse\": \"ws:\/\/\"/g" /var/lib/iotronic/settings.json ``` ##### Configure logrotate diff --git a/etc/systemd/system/s4t-lightning-rod.service b/etc/systemd/system/s4t-lightning-rod.service index 2e254b8..e33873e 100644 --- a/etc/systemd/system/s4t-lightning-rod.service +++ b/etc/systemd/system/s4t-lightning-rod.service @@ -11,6 +11,8 @@ StandardOutput=journal StandardError=journal WorkingDirectory=/usr/lib/node_modules/iotronic-lightning-rod Environment="NODE_PATH=/usr/lib/node_modules" +Environment="IOTRONIC_HOME=/var/lib/iotronic" +Environment="LIGHTNINGROD_HOME=" ExecStart=/usr/bin/node $LIGHTNINGROD_HOME/lightning-rod.js Restart=always