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 2007-02-24 16:56:00

costal
New member
Registered: 2007-02-24
Posts: 3

little misstake with telnet access

hello everyone,

i've telneted to the dns-323 and deleted perhaps the crontab for the root user...
i took the following command to show the crontab:

      crontab -d root

instead of

      crontab -e root


can someone of you with telnet access to your box can tell me the output of

      crontab -e root

so i can recover mine...
and please tell me how to set correctly own cronjobs in the dsn-323...

best regards
costal

ps: "sorry for my really bad english"

Offline

 

#2 2007-02-24 19:51:59

costal
New member
Registered: 2007-02-24
Posts: 3

Re: little misstake with telnet access

solved the problem with reflashing...
also i managed to get my own cronjob working...

regards
costal

Offline

 

#3 2007-02-24 19:53:49

frodo
Member
From: Stockholm, Sweden
Registered: 2007-01-17
Posts: 259

Re: little misstake with telnet access

Costal.

Did you try a reboot? A reboot should have solved it....

Offline

 

#4 2007-02-24 20:05:03

costal
New member
Registered: 2007-02-24
Posts: 3

Re: little misstake with telnet access

oooohh...

yes youre right, the crontab file gets restored after reboot...
so my cronjob is gone...

how can i make a cronjob that persists, or how can i write it back after a boot?

any ideas?

regards
costal

Offline

 

#5 2007-02-24 21:35:46

frodo
Member
From: Stockholm, Sweden
Registered: 2007-01-17
Posts: 259

Re: little misstake with telnet access

This is a task for fun_plug. Everything in the DNS gets restored after a reboot. Anything you want to be persistent has to be fixed by the fun_plug script.

Offline

 

#6 2007-02-25 01:55:07

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: little misstake with telnet access

There is a little problem with modifying crontab via fun_plug.  You can't just have the
script edit the existing /var/spool/cron/crontabs/root file, because the crond process won't
know the crontab file on disk has changed and will not process the additional crontab entries.

A work around for this issue, is to use a temporary file to make your changes.
See the following code snippet...

Code:

CRONTXT=/mnt/HD_a2/crontab.txt

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

# make your modifications to the $CRONTXT file
# this example adds a time sync script, which I wrote...
# add ntp_sync.sh (system & rtc time sync with ntp server)
# [runs once a day at 2:05am ]
/bin/echo "5 2 * * * /mnt/HD_a2/ntp_sync.sh" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT

Last edited by mig (2007-02-28 00:30:06)


DNS-323 • 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB • RAID1 • FW1.03 • ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#7 2007-02-25 05:03:50

someguy
Member
Registered: 2007-01-17
Posts: 47

Re: little misstake with telnet access

frodo wrote:

This is a task for fun_plug. Everything in the DNS gets restored after a reboot. Anything you want to be persistent has to be fixed by the fun_plug script.

Cool, so just to confirm, all changes made by a fun_plug are made to the file system image in ram, not the rom-image -- which is always loaded every reboot?

Last edited by someguy (2007-02-25 05:04:30)

Offline

 

#8 2007-02-25 12:36:17

frodo
Member
From: Stockholm, Sweden
Registered: 2007-01-17
Posts: 259

Re: little misstake with telnet access

Yes configs are not stored in RAM. But be careful anyway.

Offline

 

#9 2007-09-24 12:12:14

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

Howdy,

So I would like rsync to copy all files from Volume 1 to Volume 2 at 1pm every night.  I use the command manually:

rysnc -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2

which is working fine, but how do I get the cronjob working?  Do I just copy the code above, edit it with my rsync command, and then save it as a txt file in the root of HD_a2.... but then what?  How do I run that automatically?  Does it need to be in the funplug start folder?

Cheers,
Chumby

Offline

 

#10 2007-10-23 08:45:56

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

Howdy again,

Very keen to get this going... just not sure how to modify the script above for rsync and where to include it.  Do I append it to the end of the fun_plug script found in the /mnt/HD_a2 ?

Any help warmly welcome.

Thanks,
Chumby

Offline

 

#11 2007-10-23 09:27:15

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: little misstake with telnet access

Chumby,

The above example is just a code snippet, not an actual script file.
To create a script file you can use an unix editor like vi http://en.wikipedia.org/wiki/Vi
and create a file (you can name it anything, but should end in .sh) in the
/mnt/HD_a2/fun_plug.d/start directory.  In this example I'll use 'editcron.sh'
Create the 'editcron.sh' file

  #vi /mnt/HD_a2/fun_plug.d/start/editcron.sh

and add the following commands to the file

Code:

#!/bin/sh

CRONTXT=/mnt/HD_a2/crontab.txt

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

# add the Rsync job to execute at 2:05 am
/bin/echo "5 2 * * * /mnt/HD_a2/fun_plug.d/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT

The line !#/bin/sh must be the first line in the script file 'editcron.sh'.
To have the fun_plug script execute the 'editcron.sh' file, the 'editcron.sh'
file must be executable and located in the /mnt/HD_a2/fun_plug.d/start directory

  #chmod a+x /mnt/HD_a2/fun_plug.d/start/editcron.sh

After the 'editcron.sh' script is run (either manually or on boot-up)
you should see your rsync line in the output of the command

  #crontab -l

If you want your rsync job to execute a another time you can look at 
http://en.wikipedia.org/wiki/Cron to modify the crontab entry.

Last edited by mig (2008-01-12 09:13:43)


DNS-323 • 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB • RAID1 • FW1.03 • ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#12 2007-10-23 11:39:16

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

Thanks Mig for putting that together... managed to get it all set up.

To follow from this... is there a way I can check that my timezone on my DNS 323 is set correctly?  I am in Australia.  Do I edit the timezone.sh file or something?

Thanks heaps,
Chumby.

Offline

 

#13 2007-10-23 12:02:25

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

Re: little misstake with telnet access

Chumby wrote:

To follow from this... is there a way I can check that my timezone on my DNS 323 is set correctly?  I am in Australia.  Do I edit the timezone.sh file or something?

Afaik, the DNS does not have working DST support which is why I added the timezone.sh script. You have to edit the file and set the timezone description for your area. When run, it'll set the timezone and query a timeserver (which you should also change according to your region).

But: The firmware runs two cronjobs (rtc -s and daylight) that will probably interfere. And there's the large clock drift.

To get accurate time, I removed all the cronjobs, measured the clock drift, adjusted the 'tick' value with adjtimex, and run ntpd. It's quite a lot of effort, but it seems to pay off. Winter time starts on 1st of november here, I hope, it'll work...

Instead of running ntp, running timezone.sh hourly via cron could keep your clock offset within a couple seconds. Measuring the drift and using adjtimex helps even more (mine drifts less than 5 secs a day with adjtimex -t 9665).

Offline

 

#14 2007-10-23 12:53:20

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

OK , thanks Fonz... looks a little complex for me. sad

I have set the time using the admin interface to sync with the clock on my computer.... it seems to work for what I need - setting a time to schedule the backup,

I tried to find the timezone for Australia, but couldn't locate that either sad

Thanks for you help with this entire project!

Cheers
Chumby.

Offline

 

#15 2007-10-23 13:19:09

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

Re: little misstake with telnet access

Chumby wrote:

I tried to find the timezone for Australia, but couldn't locate that either sad

http://dns323.kood.org/forum/p3617-2007 … html#p3617

Was it Australia changing DST recently? Don't know if the above link is correct, then.

Offline

 

#16 2007-10-23 23:47:30

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

Thanks for that Fonz... I will check that link out.  I am in Tasmania which is 1 hr ahead (DST) of EAST at the moment.

Just one other thing - I have the rysnc working in the crontab well now (great!), but how can I see what changes have been made during the copy.  Is there a logfile created?

Thanks
Chumby.

Offline

 

#17 2007-10-23 23:55:44

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

Re: little misstake with telnet access

Chumby wrote:

Just one other thing - I have the rysnc working in the crontab well now (great!), but how can I see what changes have been made during the copy.  Is there a logfile created?

Cron normally sends job output via mail, but that's probably not working. You can redirect output to a file, though. Change your crontab entry to sth like:

Code:

5 2 * * * /mnt/HD_a2/fun_plug.d/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2 >/mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1

I added the ">/mnt/....... 2>&1" part which will redirect normal and error output of rsync to the rsync.last.log file. Of course, you could also redirect normal and error output to different files, if you like: >/.../out.log 2>/..../err.log

Offline

 

#18 2007-10-24 01:00:25

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: little misstake with telnet access

Hi Fonz,

Thanks for that - great!  I will try it out tonight.  Appreciate your help with this!

Chumby

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB