What's new

Custom scripts no longer running

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

thelonelycoder

Part of the Furniture
I am having problems getting custom scripts to run in 378.53.
Over in http://www.snbforums.com/threads/adblocking-with-combined-hosts-file.15309/ in the Advanced method I am calling in services-start the following:
Code:
#!/bin/sh

sleep 10
/opt/etc/init.d/rc.unslung start

cru a UpdateHosts "00 00 * * 5 /jffs/scripts/update-hosts.sh"

#!/bin/bash
sleep 5
source  /jffs/scripts/update-hosts.sh
The problem are the last three lines, it runs the update-hosts.sh script.
This worked fine with prior Asuswrt-Merlin 378.52 but now on .53 it does not run anymore.
Strange as it seems: If I also add the following to post-mount along with the above services-start it works fine:
Code:
#!/bin/sh

if [ $1 = "/tmp/mnt/sda1" ]
then
  ln -sf $1/entware /tmp/opt
fi

#!/bin/bash
sleep 5
source  /jffs/scripts/update-hosts.sh
The double calling of update-hosts.sh in the scripts post-mount and services-start seem to do the trick.
If I remove the last three lines in one of the two scripts it will not work.

Any suggestion what could cause this?
Also, how would I best log it in the syslog, I am not sure how to activate logger for these entries.
 
I'd start by putting the following line immediately before you call update-hosts.sh
Code:
logger -t DEBUG "STARTING UPDATE"
Then reboot and look at the syslog to check that the WAN interface is fully up at the time the script is called.
 
Maybe the external mount location is slower coming on line for some reason (doing a file system check?).....Maybe check for the existence of the input files and sleep for a few seconds if they are not found?
 
oddly, I just upgraded to 378.53 last night and adblock still functional. I have a slight difference in postmount (without sleep since it is inside the external mount exists condition...)

Code:
if [ $1 = "/tmp/mnt/ext2" ]
then
  ln -sf $1/entware /tmp/opt
  . /jffs/scripts/adblock.sh
fi
 
Since my last post. I had a chance to reboot tonight while everyone is in bed and found out my post-mount doesn't work as expected either.

sequence in log below:
My first USB ext2 partition mounted to /tmp/mnt/ext2, follow by first post-mount.
NTP time resync.
dnsmasq restarted (I think it is not by post-mount but by rc_service).
My second USB ***32 partition mounted to /tmp/mnt/ASUS, follow by a second run of post-mount.
... in this second run, adblock.sh inside post-mount did not executed due to $1 not matching!

Code:
Dec 31 19:00:27 hotplug[648]: USB ext2 fs at /dev/sda1 mounted on /tmp/mnt/ext2
Dec 31 19:00:27 custom script: Running /jffs/scripts/post-mount (args: /tmp/mnt/ext2)
Dec 31 19:00:28 dhcp client: bound 96.127.218.68 via 96.127.218.65 during 53488 seconds.
Dec 31 19:00:28 ntp: start NTP update
May  6 22:38:19 rc_service: ntp 690:notify_rc restart_upnp
May  6 22:38:19 rc_service: ntp 690:notify_rc restart_diskmon
May  6 22:38:19 disk monitor: be idle
May  6 22:38:25 rc_service: service 757:notify_rc restart_dnsmasq
May  6 22:38:25 dnsmasq[274]: exiting on receipt of SIGTERM
May  6 22:38:25 custom config: Appending content of /jffs/configs/dnsmasq.conf.add.
May  6 22:38:25 rc_service: hotplug 648:notify_rc restart_nasapps
May  6 22:38:25 rc_service: waitting "restart_dnsmasq" via  ...
May  6 22:38:25 dnsmasq[760]: started, version 2.73rc1 cachesize 1500
May  6 22:38:25 dnsmasq[760]: warning: interface ppp1* does not currently exist
May  6 22:38:25 dnsmasq[760]: asynchronous logging enabled, queue limit is 5 messages
May  6 22:38:25 dnsmasq-dhcp[760]: DHCP, IP range 192.168.1.4 -- 192.168.1.254, lease time 1d
May  6 22:38:25 dnsmasq[760]: using local addresses only for domain rainbow
May  6 22:38:25 dnsmasq[760]: read /etc/hosts - 5 addresses
May  6 22:38:25 dnsmasq[760]: failed to load names from /mnt/ASUS/hosts/blacklist.txt: No such file or directory
May  6 22:38:25 dnsmasq[760]: failed to load names from /mnt/ASUS/hosts/hosts.blocked.txt: No such file or directory
May  6 22:38:25 dnsmasq[760]: read /etc/hosts.dnsmasq - 0 addresses
May  6 22:38:25 dnsmasq-dhcp[760]: read /etc/ethers - 39 addresses
May  6 22:38:25 dnsmasq[760]: using nameserver 74.116.184.29#53 for domain local
May  6 22:38:25 dnsmasq[760]: using nameserver 74.116.184.28#53 for domain local
May  6 22:38:25 dnsmasq[760]: using local addresses only for domain rainbow
May  6 22:38:25 dnsmasq[760]: using nameserver 74.116.184.28#53
May  6 22:38:25 dnsmasq[760]: using nameserver 74.116.184.29#53
May  6 22:38:26 FTP Server: daemon is stopped
May  6 22:38:27 Samba Server: smb daemon is stopped
May  6 22:38:27 Samba Server: daemon is started
May  6 22:38:28 hotplug[670]: USB v*** fs at /dev/sdb1 mounted on /tmp/mnt/ASUS
May  6 22:38:28 custom script: Running /jffs/scripts/post-mount (args: /tmp/mnt/ASUS)
May  6 22:38:28 rc_service: hotplug 670:notify_rc restart_nasapps
May  6 22:38:28 FTP Server: daemon is stopped
May  6 22:38:28 Samba Server: smb daemon is stopped
May  6 22:38:28 Samba Server: daemon is started
May  6 22:38:48 kernel: eth2: received packet with  own address as source address
May  6 22:38:51 crond[280]: time disparity of 181598 minutes detected

so what was wrong? It was because adblock.sh tried to access both blacklist.txt and hosts.blocked.txt from my ***32 drive (ASUS) which was not mounted at the same time as the ext2 drive (ext2) used for entware and script.

changing post-mount to executed adblock.sh only when /tmp/mnt/ASUS is found make this works again:
Code:
#!/bin/sh

if [ $1 = "/tmp/mnt/ext2" ]
then
  ln -sf $1/entware /tmp/opt
fi

if [ $1 = "/tmp/mnt/ASUS" ]
then
  . /jffs/scripts/adblock.sh
fi

sorry, I had to edit *** to post this since the forum software insist on banning the abreviated word of "File Allocation Table" (note to Admin!) :)
 

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