ac@wrt wrote:Thanks...following is my sample script., any problem in syntax ?
/etc/init.d$ vi testlog
#!/bin/sh /etc/rc.common
START=00
boot() {
/etc/init.d/testlog enable
uci set system.@system[0].hostname=NewHostName
uci commit system
}
Yes, many problems.
Firstly, as I told you previously in another thread, you set the hostname by editing the file /etc/config/system and changing the hostname option to your desired hostname. You can also change the hostname by using Luci. Go to Luci --> System --> System and change the value in the Hostname field. Using an init.d script to make this change is the WRONG way to go about doing it.
Secondly, your script should implement a start(), stop() and restart() method. NOT a boot() method.
Thirdly, you are recursively calling your own script in the first line. You enable an init.d script ONCE from the command line by invoking it with the command /etc/init.d/scriptname enable. You do not embed this call within the script itself.
Fourthly, you cannot start your script with a 00 number. The system script is executed with priority 10. This script sets the hostname. If you try to execute your init.d script before the system script, then the system script will undo your changes. Your script needs to be numbered AFTER the system script. So START should have a value > 10....
Really - I suggest taking a little more time to read the answers you're given on this forum and also browse through the openwrt wiki. It has a lot of information that is very helpful.
(Last edited by dl12345 on 16 Nov 2016, 21:33)