Skip to content

installing 01 termux, node red, termux serives

yOyOeK1 edited this page Jan 28, 2022 · 2 revisions

First of all we need some stuff :) termux is a first thing to install. It will provide us witch linux shell where we can run apps, scripts, ..... It's nice if you have android > 7.0 then you can get newest version of termux from f-droid. Why f-droid not play store. hymmm rules and regulations ? Me by you can do do many things with it :P

  • termux assuming that you have android >= 7.0 go to termux.com Get some reading or jump to f-droid and get latest com.termux. When I'm writing it 0.118 is the newest version available. ~97Mb install it on the device (android based). you will get a termux icon and after starting it you will be welcomed with black window and text / terminal.

instructions:

$ date - command is "date" it's a command formatting

@pc$ date - command is "date" execute at pc/desktop

steps to make

For now we will use phone... in termux terminal you will have ~$ |

~ - is your current directory ~ mean home directory

$ - is there

and blinking currsor sine

first update upgrade and sshd to start using laptop or pc with keyboard and mouse not the screen. But you will be able to write all steps direcly in termux terminal.

$ pkg update

will update termux installd things to up to date versions.

$ pkg install termux-services openssh mc wget

will install termux-services app it will maintain services and other apps what we will have running in background providing us with some services sshd, mqtt, mysql, bash scripts, python scripts, ..... more info on subject https://wiki.termux.com/wiki/Termux-services

openssh (optional) I don't whant to write a lot of things on phone so in my case is to have a way to make editing and have access to termux terminal from my laptop It need file editing

$ nano ../usr/var/service/sshd/run you will have a starting sentence of sshd I'm adding -p 2222 to have port 2222 for sshd CTRL + x y entre restart termux

mc nice file manager

wget for downloading things from internet.

$ passwd

to set password for your oiyshTerminal - ssh client password login

$ sv-enable sshd

$ sv up sshd

restart termux

getting ip adress

in android setting -> wifi -> advanced or settings -> about phone -> status you will find wifi ip address in my case it's 192.168.43.241 yours can be different

testing sshd

in termux terminal execute command $ ps -aux | grep sshd

you shoud have a list of process's running with sshd sentence. one of those should be .../sshd -p 2222 -D -e -R .....

#!/data/data/com.termux/files/usr/bin/sh exec sshd -p 2222 -D -e 2>&1

If so ! GOOD

now on laptop or pc use ssh client to log to your phone / tablet to check if it's working.

I'm using linux so in my case it's operation of opening terminal and command. On windows machines you can use putty.

@pc$ ssh -p 2222 192.168.43.241

It's first login I'm prompt with a authontication steps for public ssh [Yes] and prompt for password. If all is ok you will see same content of terminal as on the phone/tablet. !

restarting termux

from termux terminal on device CTRL - d then setting in android -> apps -> find termux "force stop"

Termux is install'd it's a beginning...

installing node-red

from now it's you choice to do it from phone/tablet or by using ssh client to be login in termux

termux need to be running. wee need termux terminal or ssh to it. In termux command:

$ pkg install nodejs-lts will install nodejs as a must for running nodered. Now we will have npm package manager and nodejs. To test it write

$ node -v

I'm getting

v16.13.2 - yours may varies. no worries important is that that you have node!

now commands

_$ cd ~_

go to home directory

$ mkdir nodeRed

make a directory named "nodeRed"

$ cd nodeRed

enter nodeRed directory

_$ npm install -g node-red

install node-red yyy I think you can call it a service

(optional)

$ npm install -g node-red-contrib-sun-position node-red-contrib-termux-api node-red-contrib-ui-svg node-red-dashboard node-red-node-mysql

it's for having dashboard, svg, other useful thinks

testing node-red

in termux terminal write

$ node-red

If all is good you will have log on screen and server now running at .... information. Default port for nodeRed id :1880

So on laptop or pc or different device it can be the same open web browser and type in adress ip adress of your device in my case is 192.168.43.241:1880 (how to chk ip adress of my oiyshTerminal)

you shooed gate welcome screen from node red service :) NICE! go back to terminal and press CTRL-z - it will kill process

adding service to puzzles

We need to runn services like node-red in background all the time to have ability to proces data or make some logic working. Let's add node-red as a service.

in termux terminal $ cd $PREFIX/var/service/

change directory to service directory

$ ls

will show all services at https://wiki.termux.com/wiki/Termux-services there is a discription how to add service but I'm doing it sooo....

$ mkdir node-red

$ mkdir -p ./node-red/log

$ ln -sf $PREFIX/share/termux-services/svlogger $PREFIX/var/service/node-red/log/run

$ cp sshd/run ./node-red/

$ nano ./node-red/run

in it. line

exec node-red 2>&1

instead of sshd :P CTRL-x y enter

$ sv up node-red

$ sv-enable node-red

restart your termux

now after restart termux you will be able to login to http://192.168.43.241:1880 your ip address can be different. And see node red running !

Clone this wiki locally