What's new

Entware How do I write my own script for entware

  • 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!

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 ?
 
Asus or Merlin firmware?
 

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...
 
post-mount is a Merlin-only feature. I think you're referring to the contents of the nvram variable script_usbmount.
 
Last edited:
post-mount is a Merlin-only feature. It think you're referring to the contents of the nvram variable script_usbmount.
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.
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.
 
I don't have in jffs folder called scripts:
Bash:
admin@RT-AC55U:/jffs# ls                                                        fixsamba      smb.conf      syslog.log    syslog.log-1  usericon                admin@RT-AC55U:/jffs# cd scripts                                                -sh: cd: can't cd to scripts                                                    admin@RT-AC55U:/jffs#
So what I should do ?
 
Maybe I need to change something in nvram ?
Look at my nvram show | grep opt
Code:
admin@RT-AC55U:/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=                                                       admin@RT-AC55U:/tmp/home/root#
 
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 ?
 
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
G Script not working anymore after upgrade to 24198 ASUSWRT - Official 31

Similar threads

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!

Staff online

Top