What's new

Which user script to use to start a daemon at boot-up?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

chetstone

Occasional Visitor
I want to start shell2http which I installed with entware. I thought services-start would be a good place to start it. I can see in the logs that services-start runs at boot, but it either has an error which is not reported or the service starts and does not keep running. If I run /jffs/scripts/services-start from the command line after boot it does start up and stay running. What is the recommended way to do this?

Here is my services-start script:
```
#!/bin/sh
logger -t "services-start" -c "XXXX" -p user.notice

shell2http -port XXXX /wifioff /jffs/scripts/w0.sh /wifion /jffs/scripts/w1.sh&

```
And here is the log entry showing the script runs at boot:
```
May 4 23:05:26 dropbear[2686]: Running in background
May 4 23:05:26 custom_script: Running /jffs/scripts/services-start
May 4 23:05:26 services-start: XXXX
May 4 23:05:26 custom_script: Running /jffs/scripts/wan-event (args: 0 init)
May 4 23:05:26 wan-event: WAN0, eventType=init
```


And here is me logging in and seeing shell2http is not running, then starting it by hand:
```
ASUSWRT-Merlin RT-AX86U_PRO 3004.388.5_0 Sat Dec 2 17:49:53 UTC 2023
admin@RT-AX86U_Pro-85B8:/tmp/home/root# ps |grep shell
491 admin 0 SW [kbdmf_shell]
4816 admin 5972 D grep shell
admin@RT-AX86U_Pro-85B8:/tmp/home/root# /jffs/scripts/services-start
admin@RT-AX86U_Pro-85B8:/tmp/home/root# 2024/09/05 12:48:07 register: /wifion (/jffs/scripts/w1.sh)
2024/09/05 12:48:07 register: /wifioff (/jffs/scripts/w0.sh)
2024/09/05 12:48:07 register: / (index page)
2024/09/05 12:48:07 listen http://localhost:XXXX/

admin@RT-AX86U_Pro-85B8:/tmp/home/root# ps |grep shell
491 admin 0 SW [kbdmf_shell]
5227 admin 1200m S shell2http -port XXXX /wifioff /jffs/scripts/w0.sh /wifion /jffs/sc
5264 admin 5972 S grep shell
```
 
I don't know anything about shell2http but Entware services would normally be started and stopped by putting an "S script" in /opt/etc/init.d.
 
my guess is that is too early to start it up and keep it running.. i had to start something in whatever script is run on mounting an ssd previosly as that is much later.
 
@ColinTaylor thanks for the reminder about the S* scripts. I found this with more info. Unfortunately I ran into the same problem. The process still dies somewhere before the boot finishes.

@Igkahn, if you mean the post-mount script, that won’t work either because that is the script that initializes entware and runs the S* scripts.

Apparently others have had this problem. Last year I worked with @MissingTwins to document his zerotier installation. (https://github.com/MissingTwins/merlin_zerotier). He must have had a very difficult time getting that going, because his startup scripts are very complicated. He has two S* scripts, and a cron entry that runs them every minute after wan-start. And then another Cron entry that periodically checks and corrects the crontab if it has gotten corrupted!!

So since I have zerotier installed, I’ve decided to just piggyback on that and add my (simpler) S* script to his cron stuff. That should keep things running. So far so good.

Thank you both for your help.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top