Entware How do I write my own script for entware

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

swie99

Occasional Visitor
Hello,
I need Your help.
In my Asus RT-AC55U router is installed Entware. It works good (opkg and other commnads).
But I need to write my own sript to be runned at start up router. So in /opt/etc/init.d I have script for dnscrypt-proxy and I need to write another for rclone.
Also for iptables I need to restore my saved rules at start up router.

How do it correctly ?
It must be similar to dnscrypt-proxy script ?
 

bbunge

Part of the Furniture

Entware is started when the thumb drive is detected via script post-mount. You can add to post-mount to run other things.
Google is your friend...
 

ColinTaylor

Part of the Furniture
post-mount is a Merlin-only feature. I think you're referring to the contents of the nvram variable script_usbmount.
 
Last edited:

ColinTaylor

Part of the Furniture
No, you can use post-mount if you point the nvram variable to it.
That was exactly my point. The name "post-mount" doesn't have any special meaning here it could be called anything at all.
 

bbunge

Part of the Furniture
That was exactly my point. The name "post-mount" doesn't have any special meaning here it could be called anything at all.
True. Have not read the Asus/Entware install inst in a while. My feeble mind jumped to what I always use. Another bad day in retirement.
 

swie99

Occasional Visitor
Maybe I need to change something in nvram ?
Look at my nvram show | grep opt
Code:
[email protected]:/tmp/home/root# nvram show | grep opt                            size: 31061 bytes (30379 left)                                                  modem_pincode_opt=1                                                             usb_fat_opt=                                                                    wan1_pppoe_options_x=                                                           wan_pppoe_options_x=                                                            usb_ext_opt=                                                                    usb_ntfs_opt=                                                                   usb_hfs_opt=                                                                    wan_pptp_options_x=                                                             wan1_pptp_options_x=                                                            vpnc_pptp_options_x=                                                            vpnc_pppoe_options_x=                                                           wan0_pppoe_options_x=                                                           ln -sf $1 /tmp/opt                                                              /opt/etc/init.d/rc.unslung start                                                /opt/etc/init.d/rc.unslung stop                                                 wan0_pptp_options_x=                                                            vpnc_pptp_options_x_list=                                                       [email protected]:/tmp/home/root#
 

ColinTaylor

Part of the Furniture
Maybe I need to change something in nvram ?
To do what?

If Entware is already working and you want to run another startup script put it in /opt/etc/init.d and call it something like S99myscript
 

swie99

Occasional Visitor
Thank you. So first 3 characters in file name must be S99 ?
How should looks file inside if I want execute command: iptables-restore /opt/iptables.rules ?
For second command I need to create next file or I can write all in one file ? How do it correctly ?
 

ColinTaylor

Part of the Furniture
Thank you. So first 3 characters in file name must be S99 ?
The first letter must be a capital "S" and be followed by two digits. The files are sorted numerically and executed in that order. By convention user scripts tend to be executed after system scripts, so they would be named something like this:

S95myprog1
S96myprog2
S97myprog3
S98myprog4
S99myprog5


How should looks file inside if I want execute command: iptables-restore /opt/iptables.rules ?
The file is a standard shell script. It can either be a stub that calls another script (like S09dnscrypt-proxy does) or you can put all your code directly into the script. I can't help you with the specific contents because your router is different than mine.

For second command I need to create next file or I can write all in one file ? How do it correctly ?
You can put all your commands in one file if that is appropriate or separate then into different scripts. The choice is yours.
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
P Disable FTP_alg script. ASUSWRT - Official 7

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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