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 2009-05-27 00:37:53

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

chkbutton2, a replacement for chkbutton and cleanboot

* This program is intended to replace the original chkbutton and the
* "cleanboot" package, which means that they must not be running when
* trying it.
* The original chkbutton is known for not doing a clean reboot or shutdown,
* leaving the filesystem in a dirty state, whith possible loss of data, and
* cleanboot only works from the command line.
*
* This program was tested on a CH3SNAS, which has identical hardware as the
* DNS323-RevB
*
* When executed, it watchs the unity front button every second, and either
* does a reboot or powers off the unity, without first terminating all
* processes and unmounting the mounted partitions, keeping the filesystem
* clean. It does not avoid your disks to spin-down.
*
* After installing with "funpkg -i chkbutton2-0.1.trg", you must start the
* program with "/ffp/start/chkbutton2.sh start".
*
* When the front button is pressed for 3 seconds, the right led starts
* blinking, and if you release the button a reboot will be done.
* If however you keep the button pressed, after 3 more seconds the left led
* starts blinking, and if you release the button the unity will be powered off.
* If you keep the button pressed for another three more seconds, the
* leds stop flashing and if you release the button no reboot or shutdown will
* happen.
*
* There are command-line equivalents of above actions: the reboot2 and
* poweroff2 commands.
*
* All events are logged to the console (serial link) output.
*
* The reboot and poweroff are the most difficult part of the job, as
* there is only a partial knowledge of the hardware and firmware of the
* DNS323/CH3SNAS and how does it work.
* If it does not work for you, you can try playing with the functions
* poweroff() and reboot() and repost back your results.
*
* Enjoy.


Attachments:
Attachment Icon chkbutton2-0.1.tgz, Size: 6,794 bytes, Downloads: 551

Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#2 2009-05-28 13:12:17

masterz3d
Member
Registered: 2009-04-30
Posts: 5

Re: chkbutton2, a replacement for chkbutton and cleanboot

Sorry for the late reply, but is it GPLed or something? Is it yours? Does it have a license?

I am really glad the source files are included, so may I eventually use it for a 100% Free Software DNS-323 firmware?

Offline

 

#3 2009-05-28 22:06:22

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

Hi, I forgot to add the author, which is me, Joao Cardoso
As for the licence, in the lack of any specific licence, it's in the public domain, you can do whatever you want with it, as long as authorship is preserved.
As for the warranty, no warranty is offered, use as you see fit:

# Author: Joao Cardoso
# This file is in the public domain
# This software is provided as is, use as you fit, no warranty.

Is this compatible with GLP? v2? v2 or later? perhaps V3? :-)

I think its too late to add that now... unless I issue a 0.2 release, if some users give feedback on the poweroff method or I make some other improvements or bug fixes.


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#4 2009-05-29 10:33:00

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

Re: chkbutton2, a replacement for chkbutton and cleanboot

I think the possibility to call some user shutdown script would be useful. People might want to add calls to "smb stop" or "/ffp/etc/rc stop" before everything's killed.

Offline

 

#5 2009-05-29 21:28:48

talkingRock
Member
Registered: 2009-03-26
Posts: 100

Re: chkbutton2, a replacement for chkbutton and cleanboot

I definitely second the need for being able to call a custom script.
I would like to be able to call my "levels" script from someone pushing the front button.

Offline

 

#6 2009-05-30 01:18:07

masterz3d
Member
Registered: 2009-04-30
Posts: 5

Re: chkbutton2, a replacement for chkbutton and cleanboot

Thank you very much for you reply Joao.

# Author: Joao Cardoso
# This file is in the public domain
# This software is provided as is, use as you fit, no warranty.

If you agree, I can add these three comment lines to the source files and then I will see if the sources can be covered under the GPL.

Offline

 

#7 2009-05-30 02:00:08

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: chkbutton2, a replacement for chkbutton and cleanboot

What a great script! I absolutely love it. Thanks very much Joao! ^^

Quick question for the quasi-illiterate: is it recommended that one uninstall cleanboot if chkbutton2 is installed? Does chkbutton2 update the 'halt' and 'shutdown' commands for example that cleanboot does?

Offline

 

#8 2009-05-30 03:47:23

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

> I think the possibility to call some user shutdown script would be useful. People might want to add calls to "smb stop" or "/ffp/etc/rc stop" before everything's killed.

I agree, and I wiil implement it soon: read  the first non-blank/comment line from /ffp/etc/chkbutton2.conf and execute it, setting an alarm just in case the executed command never returns (5 secs?), ignoring its termination status, and then killing any leftover process and doing the reboot/shutdown.

> If you agree, I can add these three comment lines to the source files and then I will see if the sources can be covered under the GPL.

Sure, but it is, as it doesn't impose any limitations.
I will add those lines for version 0.2

>What a great script! I absolutely love it.
Quick question for the quasi-illiterate: is it recommended that one uninstall cleanboot if chkbutton2 is installed? Does chkbutton2 update the 'halt' and 'shutdown' commands for example that cleanboot does?

It's not a script, but a compiled program ;-)
It does not interact with cleanboot, but cleanboot's shutdown will not work, as it relies on the original chkbutton, which watch the existence of a file named /tmp/shutdown.

This makes me wonder if chkbutton2 should'nt also look for the presence of that file... yes, maybe...


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#9 2009-05-30 11:52:15

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

Re: chkbutton2, a replacement for chkbutton and cleanboot

Another idea for your program. A little weird maybe. What if your program could 'detect' morse-code-like sequences, i.e. a sequence of short and long presses. Then, in the config file, you allow to assign script files to codes ( . = short, - = long), e.g.:
--- /path/tp/shutdown-script
-.- /path/to/reboot-script
... /path/to/start-backup-now
-.. /path/to/trigger-music-library-rescan
etc.

Offline

 

#10 2009-05-30 13:39:55

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: chkbutton2, a replacement for chkbutton and cleanboot

jcard wrote:

> I think the possibility to call some user shutdown script would be useful. People might want to add calls to "smb stop" or "/ffp/etc/rc stop" before everything's killed.

I agree, and I wiil implement it soon:

Thanks for the great little tool. Since installing it I have noticed the light behind the power button no long dim's to indicate the unit is asleep. Does this mean the unit isn't going to sleep?

I'm looking forward to the those shutdown scripts!


Bob Blackwell
Pickering, ON

Offline

 

#11 2009-05-30 16:51:37

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: chkbutton2, a replacement for chkbutton and cleanboot

rcblackwell wrote:

Since installing it I have noticed the light behind the power button no long dim's to indicate the unit is asleep. Does this mean the unit isn't going to sleep?

I think the unit is going to sleep, but is not showing it. I can see the drives go to sleep via 'logread' but of course would like to see it via the LED as well! wink

Many thanks to your great work.

Offline

 

#12 2009-05-30 19:08:51

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

krimb1 wrote:

rcblackwell wrote:

Since installing it I have noticed the light behind the power button no long dim's to indicate the unit is asleep. Does this mean the unit isn't going to sleep?

I think the unit is going to sleep, but is not showing it. I can see the drives go to sleep via 'logread' but of course would like to see it via the LED as well! wink

Many thanks to your great work.

The program doesn't depend on anything which is on disk; ir runs from memory, is compiled against the unity firmware libraries and invoke the firmware busybox for a reboot.

As for the leds, in my CH3SNAS the power led doesn't dim when the disks spindow, and I can't manage that led... it's a firmware difference between dlink and conceptronic.

To know if the disks are or not spindown I just put my hand on the unity and feel or don't feel the motor disks  working... high tech last resort :-O

I have contradictory feelings about disk spindown -- energy saving for one side versus disk life for another.
I used to keep all my PCs always on, 24/7, and only once I got a disk failure; my disks last for 5 or 6 years! and I only replaced them because they become "small".

The problem is the number of start/stop and head retract cycles, which are limited for a given disk -- most of the time disks fail because of mechanical failure related with those problems.
Thus, the problem is: what is cheaper (for my pocket and the planet): save a few cents of electricity / planet resources during two or three years, or have to buy/exaust planet resources every two or three years when buying a new disk?
I'm sure that someone has that bill done, but I don't know the results


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#13 2009-05-30 19:17:03

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

fonz wrote:

Another idea for your program. A little weird maybe. What if your program could 'detect' morse-code-like sequences, i.e. a sequence of short and long presses. Then, in the config file, you allow to assign script files to codes ( . = short, - = long), e.g.:
--- /path/tp/shutdown-script
-.- /path/to/reboot-script
... /path/to/start-backup-now
-.. /path/to/trigger-music-library-rescan
etc.

eheh... weird indeed. Than you would need a postit with the sequence attached to the unity.

For backups, I would use the reset button -- start a script when pressed. chkbutton2 could do that.
One would only need to make the button more accessible, perhaps gluing a longer "stick" on top of it.


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#14 2009-05-31 16:23:30

iazmin
Member
Registered: 2008-09-10
Posts: 55

Re: chkbutton2, a replacement for chkbutton and cleanboot

I installed it but unfortunately had to disable it since after have this running, I can not access the standard DNS Web GUI. I have ffp running from USB drive. my Web GUI run at port 81 since the port 80 is used for lighttpd web hosting.

Offline

 

#15 2009-06-01 01:27:41

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

iazmin wrote:

I installed it but unfortunately had to disable it since after have this running, I can not access the standard DNS Web GUI. I have ffp running from USB drive. my Web GUI run at port 81 since the port 80 is used for lighttpd web hosting.

There is nothing in chkbutton2 thats makes other services stop working.

However, the init script /ffp/start/chkbutton2.sh stops the standard chkbutton, as it makes no sense to have both working.

In the standard firmware, there is a chain of processes launching other processes, and some processes check to see if other are running and re-launch them if they aren't. Perhaps the standard chkbutton launchs or re-launchs the web process?

As I have a Conceptronics CH3SNAS (which has the DNS323-revB hardware), I dont kown what processes launch other processes in DLINK's DNS323.

If you have some linux knowledge, perhaps you could try to diagnose the problem? For example, starting "chkbutton2" directly from the command line, instead of starting if from "/ffp/start/chkbutton2 start", and checking that you still have web services? then, terminating the standard chkbutton with the command "kill $(pidof chkbutton)" and see if you still have web?

What firmware version do you have?


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#16 2009-06-01 05:38:55

iazmin
Member
Registered: 2008-09-10
Posts: 55

Re: chkbutton2, a replacement for chkbutton and cleanboot

jcard wrote:

iazmin wrote:

I installed it but unfortunately had to disable it since after have this running, I can not access the standard DNS Web GUI. I have ffp running from USB drive. my Web GUI run at port 81 since the port 80 is used for lighttpd web hosting.

There is nothing in chkbutton2 thats makes other services stop working.

However, the init script /ffp/start/chkbutton2.sh stops the standard chkbutton, as it makes no sense to have both working.

In the standard firmware, there is a chain of processes launching other processes, and some processes check to see if other are running and re-launch them if they aren't. Perhaps the standard chkbutton launchs or re-launchs the web process?

As I have a Conceptronics CH3SNAS (which has the DNS323-revB hardware), I dont kown what processes launch other processes in DLINK's DNS323.

If you have some linux knowledge, perhaps you could try to diagnose the problem? For example, starting "chkbutton2" directly from the command line, instead of starting if from "/ffp/start/chkbutton2 start", and checking that you still have web services? then, terminating the standard chkbutton with the command "kill $(pidof chkbutton)" and see if you still have web?

What firmware version do you have?

i am using FW 1.06. I will try to troubleshoot tonight. your proposed troubleshooting make sense to know the error.

Offline

 

#17 2009-06-01 11:52:06

iazmin
Member
Registered: 2008-09-10
Posts: 55

Re: chkbutton2, a replacement for chkbutton and cleanboot

iazmin wrote:

jcard wrote:

iazmin wrote:

I installed it but unfortunately had to disable it since after have this running, I can not access the standard DNS Web GUI. I have ffp running from USB drive. my Web GUI run at port 81 since the port 80 is used for lighttpd web hosting.

There is nothing in chkbutton2 thats makes other services stop working.

However, the init script /ffp/start/chkbutton2.sh stops the standard chkbutton, as it makes no sense to have both working.

In the standard firmware, there is a chain of processes launching other processes, and some processes check to see if other are running and re-launch them if they aren't. Perhaps the standard chkbutton launchs or re-launchs the web process?

As I have a Conceptronics CH3SNAS (which has the DNS323-revB hardware), I dont kown what processes launch other processes in DLINK's DNS323.

If you have some linux knowledge, perhaps you could try to diagnose the problem? For example, starting "chkbutton2" directly from the command line, instead of starting if from "/ffp/start/chkbutton2 start", and checking that you still have web services? then, terminating the standard chkbutton with the command "kill $(pidof chkbutton)" and see if you still have web?

What firmware version do you have?

i am using FW 1.06. I will try to troubleshoot tonight. your proposed troubleshooting make sense to know the error.

I discovered that the chkbutton2 will work with Web GUI working, if I launch the chkbutton2 manually (outside of /ffp/start by running it from command line). Initially I tried to run it by placing the sh /anywhere/chkbutton2.sh start in fun.plug.local but the problem still persist.

Last edited by iazmin (2009-06-01 11:56:37)

Offline

 

#18 2009-06-01 18:47:01

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

Here is version 0.2:

*  - The box back button is also monitorized for momentary pressing.
*  - Added one or two optional command line arguments, that must be the
*    absolute path name of executable scripts, owned by root and not
*    writable by anybody else.
*    The first script is executed before any other action is taken by this
*    program, and can do any cleanup needed before rebooting or shutdown.
*    The script must be completed in 5 seconds.
*    The second optional argument is the name of a script to execute when
*    the back button is momentary pressed and both front leds start flashing;
*    it can be used to start a backup, mount or umount an external USB disk...
*    This program does not wait for the termination of such script.
*
*    If you only need the second argument, just write the name of a
*    non-existing file as the first argument

By default, /ffp/start/chkbutton2.sh uses the do-nothing (but with instructions) scripts cleanup.sh and backup.sh found at /ffp/share/chkbutton2, but that can obviously be changed.

At least on my CH3SNAS there is no problem using the back reset button, as it needs to be pressed only momentary, and for a real reset it must be pressed for at least ten seconds (during bootup, I believe). But your firmware can be different -- backup your configuration first.

If it is not working for you, start first syslogd, "sh /ffp/start/syslogd.sh start" and watch the messages logged at /var/log/messages.

Enjoy,


Attachments:
Attachment Icon chkbutton2-0.2.tgz, Size: 8,592 bytes, Downloads: 530

Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#19 2009-06-01 22:23:00

Geckozr
Member
Registered: 2009-04-02
Posts: 8

Re: chkbutton2, a replacement for chkbutton and cleanboot

I have a little question :
Does anyone know if it will work on a DNS-313 ?

(cleanboot did not)
thanks

Offline

 

#20 2009-06-23 02:01:04

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: chkbutton2, a replacement for chkbutton and cleanboot

iazmin wrote:

I discovered that the chkbutton2 will work with Web GUI working, if I launch the chkbutton2 manually (outside of /ffp/start by running it from command line). Initially I tried to run it by placing the sh /anywhere/chkbutton2.sh start in fun.plug.local but the problem still persist.

I'm running into a similar problem. If chkbutton2 is launched during boot, at the appropriate spindown time, the fans and disks whir up to full speed and the DNS-323 will never sleep. It works just fine if I ssh into the box and launch chkbutton2 manually.

At first I started the script via the normal chmod a+x'ing it at run time in the /ffp/start folder, but when that didn't work I tried adding it to the fun_plug.local to see if that would do the trick. Didn't work at all.

Are others experiencing this as well? I hope I don't have to login each time to start this great script. I'm running on the 1.08 beta firmware at the moment.

Offline

 

#21 2009-06-23 02:26:05

rcblackwell
Member
From: Pickering, ON
Registered: 2008-05-19
Posts: 204
Website

Re: chkbutton2, a replacement for chkbutton and cleanboot

krimb1 wrote:

Are others experiencing this as well? I hope I don't have to login each time to start this great script. I'm running on the 1.08 beta firmware at the moment.

I'm not seeing this behaviour. I'm running 1.07 FW.  < ---- I Just double checked the FW version. MADE A MISTAKE roll. That should have been revision 1.06 not 1.07.

Bob Blackwell

Last edited by rcblackwell (2009-06-29 00:39:15)


Bob Blackwell
Pickering, ON

Offline

 

#22 2009-06-23 03:12:56

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

I'm running into a similar problem. If chkbutton2 is launched during boot, at the appropriate spindown time, the fans and disks whir up to full speed and the DNS-323 will never sleep.

You mean that everything (chkbutton2 included ! ) works OK until spindown time?
And when the fan starts at full speed, does chkbutton2 still works?

When launched through ffp/start/, can you login, do a "ps" and see if the original chkbutton is running simultaneously with chkbutton2? It shouldn't.

It works just fine if I ssh into the box and launch chkbutton2 manually.

At first I started the script via the normal chmod a+x'ing it at run time in the /ffp/start folder, but when that didn't work I tried adding it to the fun_plug.local to see if that would do the trick. Didn't work at all.

This seems to indicate a problem with the order of the script execution... or permission problems.
To manually start the script do you login as root or as another user?
Have you changed the owner/permissions of the executable?

[edited] When you start it manually, do you do it using "/ffp/start/chkbutton2.sh start" or do you invoke it directly?

I have no clues...

Does chkbutton2 works for anybody  with FW-1.08? Positive answers are wellcome.

Last edited by jcard (2009-06-23 03:18:12)


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

#23 2009-06-23 04:23:27

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: chkbutton2, a replacement for chkbutton and cleanboot

Thanks very much Blackwell for your positive feedback. It's encouraging to know there might yet be a way.

jcard wrote:

You mean that everything (chkbutton2 included ! ) works OK until spindown time?

Yes indeed! For example if I run 'logread' I can see that chkbutton2 is correctly checking for activity via cron.

jcard wrote:

And when the fan starts at full speed, does chkbutton2 still works?

By this if you mean, "Can you still use a command like 'reboot2'?" then you are correct. The logread output still shows the successive cron checks and all the binaries work properly.

jcard wrote:

When launched through ffp/start/, can you login, do a "ps" and see if the original chkbutton is running simultaneously with chkbutton2? It shouldn't.

You are correct: the original chkbutton is not running when chkbutton2 is launched via /ffp/start/ at runtime

jcard wrote:

This seems to indicate a problem with the order of the script execution... or permission problems.

To manually start the script do you login as root or as another user?
Have you changed the owner/permissions of the executable?
When I login to run the script manually I am under 'root'. fun_plug must also operate at the root level as well, no? I double-checked the ownership of the chkbutton2.sh script and it is all root.

jcard wrote:

When you start it manually, do you do it using "/ffp/start/chkbutton2.sh start" or do you invoke it directly?

I generally use 'sh /ffp/start/chkbutton2.sh start' but yours works as well.

Many thanks to all your help! I'll keep digging for clues. wink

Edit: Here's another puzzle piece. If chkbutton2 is run at boot via /ffp/start/ I can get the DNS-323 to sleep properly by logging into the web GUI and re-applying the "Power Management" setting. The same is true if I run something via the command line like 'dns-323 spindown 30'. Weird huh?

Last edited by krimb1 (2009-06-23 05:31:18)

Offline

 

#24 2009-06-23 21:06:49

krimb1
Member
Registered: 2008-01-05
Posts: 65

Re: chkbutton2, a replacement for chkbutton and cleanboot

I just realized something. When I upgraded to FW 1.08 beta, I reformatted my drives with ext3. Could that be the problem by any chance?

Offline

 

#25 2009-06-23 23:38:23

jcard
Member
From: Portugal
Registered: 2008-09-21
Posts: 289

Re: chkbutton2, a replacement for chkbutton and cleanboot

By this if you mean, "Can you still use a command like 'reboot2'?" then you are correct. The logread output still shows the successive cron checks and all the binaries work properly.

No, I mean using the front-button.
When you invoke reboot2/poweroff2 you are launching a new program; what I want to know is if the running chkbutton2 is still working.

What do you mean with "successive cron checks" in the above sentence? You are not running chkbutton2 through cron, aren't you?

Here's another puzzle piece. If chkbutton2 is run at boot via /ffp/start/ I can get the DNS-323 to sleep properly by logging into the web GUI and re-applying the "Power Management" setting. The same is true if I run something via the command line like 'dns-323 spindown 30'. Weird huh?

Yes it is. chbutton2 does not touch the disk in any way. But it is an interesting hint, as all those programs use the same ioctl interface as chkbutton2 does. yes...
Some positive answers (that chkbutton works) from other users could be very usefull...

I just realized something. When I upgraded to FW 1.08 beta, I reformatted my drives with ext3. Could that be the problem by any chance?

No, I use ext3 (on a CH3SNAS)


Please consider discussing Alt-F at http://groups.google.com/group/alt-f/topics
Please consider filling Alt-F bugs at http://code.google.com/p/alt-f/issues/list

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB