Linux / OpenWRT - run bash script with console / stdout output

2

I have a OpenWRT System for which I've wrote a small interactive shell script which displays a menu and based on the input, displays appropriate info to stdout.

For example:

== Please Select Option ==
[1] Display IP address
[2] Display VPN Status
[3] Display something else

Please enter your choice?

When I run the script manually (menu.sh) then it seems to work fine. However, I need to find a way for the script to launch automatically when the OS is booted. So instead of seeing a shell propmpt, the user will see the output of the script, in this case, the menu system.

How do I go it?

Shaf

Posted 2015-09-30T10:31:35.450

Reputation: 21

Answers

2

OpenWRT uses the Busybox ash as its shell, which seems to run the commands in /etc/profile on login.

If you want the script to run automatically when anyone logs in (which is probably only going to be root if this is a router), I think adding this to the bottom of your /etc/profile will work:

/full/path/of/menu.sh

and if you don't want the menu dropping to the shell when its completed, you need some additional logic to support that.

LawrenceC

Posted 2015-09-30T10:31:35.450

Reputation: 63 487

Perfect! Never occured to me to try the /etc/profile Works perfect! Thank you very much! – Shaf – 2015-10-01T11:40:33.063