DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-03-07 12:29:24

cliaz
Member
From: Melbourne, Australia
Registered: 2008-11-10
Posts: 55
Website

not all commands in fun_plug.local are run after moving to ffp on usb

After moving ffp to a usb (at /mnt/usb/), certain things aren't working as they used to (when ffp was in /mnt/HD_a2/)

Specifically,
            "crontab -l |sed -e '/rtc\ -c/d' -e '/daylight/d' -e '/rtc\ -s/d' | crontab -"

in fun_plug.local (full file below) doesn't remove the two lines in crontab.

As well as that, /ffp/start/editcron.sh, which used to add some lines to the crontab to enable regular time sync, doesn't work either.
It creates the file, but for some reason doesn't load it into crontab.


last but not least, alias ls='ls --color=auto' doesn't alias permanently as it did before - I have to run it each time. Putting that line into fun_plug.local doesn't work either.


Here's the kicker - if I run either of those commands/files mentioned above (the "crontab | sed" command, the editcron.sh or the alias ls command), they work. Just not in fun_plug.local or on start.

And yes, they have execute rights.



/ffp/etc/fun_plug.local

Code:

#!/ffp/bin/sh
PATH=/ffp/sbin:/ffp/bin
#PATH=/ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin
BINDIR=/ffp/bin
LOGFILE=/mnt/usb/ffp.log
ETCDIR=/etc


# Set local timezone
# For a list of timezone strings see:
# http://www.nas-tweaks.net/CH3SNAS:Tutorials/ntp#Appendix:_Example_Timezone_Strings

# Australia - Melbourne, Camberra, Sydney
TZ=AEST-10AEDT-11,M10.5.0/02:00:00,M4.1.0/03:00:00
export TZ
echo ${TZ} >${ETCDIR}/TZ


# This removes firmware cronjobs that interfere with ntpd.
#crontab -l | grep -vw '/usr/sbin/daylight' | grep -vw '/usr/sbin/rtc' | crontab -
crontab -l |sed -e '/rtc\ -c/d' -e '/daylight/d' -e '/rtc\ -s/d' | crontab -

# executing the time protocol every boot to set correct time during boot up process
/usr/sbin/sntp -r -P no au.pool.ntp/org 1>>${LOGFILE} 2>&1 &

# added this in the hope that it would remove the necessity of aliasing ls with --color option each time. doesn't work.
alias ls='ls --color=auto'

/ffp/start/editcron.sh

Code:

#!/ffp/bin/sh

CRONTXT=/mnt/usb/crontab.txt

# start with existing crontab
/bin/crontab -l > $CRONTXT

# add a job to sync RTC with system time once per day
# and add a job that sets system time using SNTP hourly
/bin/echo "32 2 * * * /usr/sbin/rtc -w" >> $CRONTXT
/bin/echo "2 * * * * /usr/sbin/sntp -r -P no pool.npt.org &" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT

Any ideas?

Cheers,
Klaus

Offline

 

#2 2011-03-07 12:56:57

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: not all commands in fun_plug.local are run after moving to ffp on usb

This one should go into ~/.profile or /ffp/etc/profile: alias ls='ls --color=auto'

For the other mysterious issues, have a look at the end of ffp.log. Look for "* Running /ffp/etc/fun_plug.local ..."

Offline

 

#3 2011-03-08 11:33:35

cliaz
Member
From: Melbourne, Australia
Registered: 2008-11-10
Posts: 55
Website

Re: not all commands in fun_plug.local are run after moving to ffp on usb

From ./ffp.log  (/mnt/usb/ffp.log) (not sure what this one is for...)

Code:

sntp: unable to locate IP address/number
sntp: Success
sntp: unable to locate IP address/number
sntp: Success
sntp: unable to locate IP address/number
sntp: Success
sntp: unable to locate IP address/number
sntp: Success
sntp: unable to locate IP address/number
sntp: Success
sntp: unable to locate IP address/number
sntp: Success

That's the whole log, which doesn't seem quite right to me.
as the line in fun_plug.local calling the sntp link (au.pool.ntp/org) is after the crontab line I'm not sure why that'd cause it to break?
(I am assuming that the line in fun_plug.local which calls the sntp update on boot is the one writing this error)

Meanwhile, in /mnt/HD_a2/.bootstrap/ffp.log

Code:

**** fun_plug script for DNS-323 (2008-08-11 tp@fonz.de) ****
Tue Mar  8 19:04:25 EST 2011
* Running /mnt/HD_a2/.bootstrap/setup.sh ...
Installing USB module and sleeping for 30 seconds
/dev/sde1 mountable and mounted on /mnt/usb
Either /dev/sde6 is already the root partition
     or /mnt/usb/.usb-root not accessible
     or /ffp/boot/reload.sh doesn't exist
So skipping reloading kernel...
Running FFP from *USB* and linking /ffp -> /mnt/usb...
ln -snf /mnt/usb/ffp /ffp
* Running /ffp/etc/fun_plug.init ...
* Running /ffp/etc/fun_plug.local ...
* Running /ffp/etc/rc ...
* /ffp/start/syslogd.sh ...
Starting /ffp/sbin/syslogd -O /mnt/USB/var/log/messages
Starting /ffp/sbin/klogd -c 3
* /ffp/start/SERVERS.sh inactive
* /ffp/start/portmap.sh inactive
* /ffp/start/unfsd.sh inactive
* /ffp/start/nfsd.sh inactive
* /ffp/start/ntpd.sh inactive
* /ffp/start/smartd.sh inactive
* /ffp/start/LOGIN.sh inactive
* /ffp/start/telnetd.sh inactive
* /ffp/start/svnserve.sh inactive
* /ffp/start/sshd.sh ...
Starting /ffp/sbin/sshd 
* /ffp/start/rsyncd.sh inactive
* /ffp/start/mysqld.sh inactive
* /ffp/start/mediatomb.sh ...
Starting /ffp/bin/mediatomb -d --interface egiga0  --home /ffp/var --cfgdir mediatomb --add /mnt/HD_a2/home/media
2011-03-08 19:04:59    INFO: Loading configuration from: /ffp/var/mediatomb/config.xml
2011-03-08 19:04:59    INFO: Checking configuration...
2011-03-08 19:04:59    INFO: Setting filesystem import charset to ASCII
2011-03-08 19:04:59    INFO: Setting metadata import charset to ASCII
2011-03-08 19:04:59    INFO: Setting playlist charset to ASCII
2011-03-08 19:04:59    INFO: Configuration check succeeded.
* /ffp/start/kickwebs.sh inactive
* /ffp/start/lighttpd.sh inactive
* /ffp/start/inetd.sh inactive
* /ffp/start/editcron.sh ...
* /ffp/start/dnsmasq.sh inactive
* /ffp/start/btpd.sh inactive
*  OK

Aliasing ls works when put in /ffp/etc/profile, thanks for that smile

Offline

 

#4 2011-03-08 16:54:56

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: not all commands in fun_plug.local are run after moving to ffp on usb

/etc/rc.sh starts crond well before it runs your fun_plug. But crond puts itself in the background and may run pretty slowly while the rest of /etc/rc.sh is running, including your fun_plug.  It is possible that your crontab modification is happening before crond gets around to setting the default crontab.  So crond is overwriting your crontab.

You probably changed the timing profile of all this by moving ffp to USB.  The file access timing changed to the point where your fun_plug and crontab modifications beat crond.  The read from USB may have been faster than off the hard disk, which may have been busy doing I/O for other tasks that were starting up.

This actually affects a lot of people, and it all depends on the timing and what fun_plug is doing.

Many people put a sleep for a few seconds in their script just before they modify the crontab, to let crond have a chance to get started.


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#5 2011-03-12 07:25:48

cliaz
Member
From: Melbourne, Australia
Registered: 2008-11-10
Posts: 55
Website

Re: not all commands in fun_plug.local are run after moving to ffp on usb

Left /ffp/start/editcron.sh as is.

added "sleep 10" to /ffp/etc/fun_plug.local:

Code:

#!/ffp/bin/sh
PATH=/ffp/sbin:/ffp/bin
#PATH=/ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin
BINDIR=/ffp/bin
LOGFILE=/mnt/usb/ffp.log
ETCDIR=/etc

# sleep in order to let crond start properly so that it won't overwrite the changes made below
sleep 10

# Set local timezone
# For a list of timezone strings see:
# http://www.nas-tweaks.net/CH3SNAS:Tutorials/ntp#Appendix:_Example_Timezone_Strings

# Australia - Melbourne, Camberra, Sydney
TZ=AEST-10AEDT-11,M10.5.0/02:00:00,M4.1.0/03:00:00
export TZ
echo ${TZ} >${ETCDIR}/TZ


# This removes firmware cronjobs that interfere with ntpd.
#crontab -l | grep -vw '/usr/sbin/daylight' | grep -vw '/usr/sbin/rtc' | crontab -
crontab -l |sed -e '/rtc\ -c/d' -e '/daylight/d' -e '/rtc\ -s/d' | crontab -

# executing the time protocol every boot to set correct time during boot up process
/usr/sbin/sntp -r -P no au.pool.ntp/org 1>>${LOGFILE} 2>&1 &

result:

Code:

root@NAS:/mnt/usb/ffp/home/root# crontab -l
30  2  *  *  * /usr/sbin/stime&
*/60  *  *  *  * /usr/sbin/getdhcp&
32 2 * * * /usr/sbin/rtc -w
2 * * * * /usr/sbin/sntp -r -P no pool.npt.org &

= success!
Thanks Fonz & Karlrado smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB