What's new
  • 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!

can i remove sleep 20 in my services-start script

chu

Occasional Visitor
i have a usb flash disk plug in my asus ac 1900p,the services-start i wote andas below:

#!/bin/sh
sleep 20
modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
/opt/etc/init.d/rc.unslung start
 
i have a usb flash disk plug in my asus ac 1900p,the services-start i wote andas below:

#!/bin/sh
sleep 20
modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
/opt/etc/init.d/rc.unslung start
No, however I suggest you to put a simple loop in your script so entware will be started asap:
Code:
#!/bin/sh
RC='/opt/etc/init.d/rc.unslung'
i=30
until [ -x "$RC" ] ; do
  i=$(($i-1))
  if [ "$i" -lt 1 ] ; then
    logger "Could not start Entware"
    exit
  fi
  sleep 1
done
$RC start

modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
 
I wait until my two USB-Sticks are mounted to start Entware. Here an excerpt of my post-mount user script:

if [ $1 = "/tmp/mnt/ac87u" ] # Entware partition
then
ln -nsf $1/entware-ng.arm /tmp/opt
if mount | grep /tmp/mnt/Data > /dev/null; # Data partition for Transmission
then
/opt/etc/init.d/rc.unslung start
else
/usr/bin/logger -t START_$(basename $0) "USB stick Data partition not mounted yet!"
fi
fi


Maybe this is the more save and clean solution as it really waits until the needed partitions are mounted... :rolleyes:
 
No, however I suggest you to put a simple loop in your script so entware will be started asap:
Code:
#!/bin/sh
RC='/opt/etc/init.d/rc.unslung'
i=30
until [ -x "$RC" ] ; do
  i=$(($i-1))
  if [ "$i" -lt 1 ] ; then
    logger "Could not start Entware"
    exit
  fi
  sleep 1
done
$RC start

modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080

thanks, can i execute below script first? seemed it does'nt depends on entware.
modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
 
thanks, can i execute below script first? seemed it does'nt depends on entware.
Mine was just an example. If you want to be executed first, you can put those 3 lines at the top of your script. It doesn't change much btw.
 
Don't put iptables rules in services-start, because they will be overwritten every time the firewall gets restarted.
 
Don't put iptables rules in services-start, because they will be overwritten every time the firewall gets restarted.

hmm, so put these in "firewall-start" ?

including the "modprobe xt_set.ko" line too?

for example can i do below?

firewall-start
#!/bin/sh
modprobe xt_set.ko
ipset -N setgoogle iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
 
Last edited:
firewall-start
 
The modprobe and ipset commands can be kept in services-start since they only needs to be executed once.

nat PREROUTING rules should ideally be put in nat-start (not firewall-start).
 
The modprobe and ipset commands can be kept in services-start since they only needs to be executed once.

nat PREROUTING rules should ideally be put in nat-start (not firewall-start).

dear rmerlin, is this ok?

services-start
#!/bin/sh
modprobe xt_set.ko
ipset -N setgoogle iphash

RC='/opt/etc/init.d/rc.unslung'
i=30
until [ -x "$RC" ] ; do
i=$(($i-1))
if [ "$i" -lt 1 ] ; then
logger "Could not start Entware"
exit
fi
sleep 1
done
$RC start

nat-start

#!/bin/sh
iptables -t nat -A PREROUTING -p tcp -m set --match-set setgoogle dst -j REDIRECT --to-port 8080
 
Should be good.
 

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!
Back
Top