Auto-start Node Application When Termux Plug-in Starts

image

I’m now able to start theta-termux-node without having to ssh into the camera. Using the OLED of the Z1, I can see the IP address and then point my web browser to the camera IP at port 3000.

This technique only works when the camera first is powered off. The node application does not auto-start when you wake the camera from sleep.

The process is:

  1. Camera is powered off (must be off and not in sleep)
  2. Power camera on with the physical power button
  3. Press the lower mode button for longer than 2 seconds to put camera in plug-in mode
  4. If you are using a Z1, the IP address will appear on the OLED. If you’re using a V, you need to use discovery to find the IP address.

Termux:Boot

You need to install Termux:Boot for this technque.

Get Termux:Boot from F-Droid

Create a new file ~/.termux/boot/startup and add add these lines:

#!/data/data/com.termux/files/usr/bin/sh
/data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/home/Development/theta-termux-node/index.js

Make sure you have the full path of node index.js . The node command and the index.js file name need to be on the same path.

Adjust the path to the location of your index.js file

.bashrc

sshd
alias l='ls -F'
alias la='ls -a'
alias ll='ls -l'
array=$(ip -4 a | grep inet | grep wlan0 | grep -oP '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(?=\/)')
echo $array
am broadcast -a com.theta360.plugin.ACTION_OLED_TEXT_SHOW -e text-middle 'Oppkey Node Server'
am broadcast -a com.theta360.plugin.ACTION_OLED_TEXT_SHOW -e text-bottom $array

The buttons will now display the processed image in the browser window with A-Frame.