Ultra Fast Shutdown

Using applications, configuring, problems
Message
Author
User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

Ultra Fast Shutdown

#1 Post by Smithy »

I am adapting this little bit of code, and going to add it to the shutdown menu.

.

Code: Select all

#!/bin/sh
# skips rc.shutdown and powers off computer without saving the session.
Xdialog --title "script $0" --yesno "\n\nPower-off computer WITHOUT saving?\n\n" 0 0
[ $? -eq 0 ] && rm /initrd/pup_ro1/etc/.XLOADED && rm /etc/.XLOADED
exec /bin/busybox poweroff


Can anyone add a refinement to it, so that if you press No it just closes the dialogue and you carry on as before?

Currently, it will shut down even if you press No, anyways if you drop the file in root and click on it you will see what I mean,
(caution, unmount any drives you have open, because it is as fast as a rat up a drainpipe and will power off your computer in a flash- even if you say NO :wink:

Oops, forum doesn't allow *.sh files, or txt files for that matter. :roll:

Jasper

#2 Post by Jasper »

Hi Smithy,

I like it and I like it even better at its fastest - having hashed out the Yes/No option.

Saves me some 15 seconds versus my usual Power-off.

My regards and thanks

Edit: following a later post from mikeb I have (in a second file) substituted "reboot" for "poweroff" at the last word in the code of the opening post above - so now I also have a have a fast "no save" reboot.
Last edited by Jasper on Mon 14 Oct 2013, 09:59, edited 1 time in total.

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#3 Post by Smithy »

: Hi Jasper, glad it's useful to you (it originated from forum member Backi)
I like it too.

Next will be how to get Puppy to boot in 15 secs involving string, rabbits, a hat, a glamorous assistant and some old static ram :wink:

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#4 Post by 01micko »

Ok, nice "idea" and all.. but.. what prevents corruption of anything mounted? Seriously, you could potentially wipe a drive.
Puppy Linux Blog - contact me for access

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#5 Post by mikeb »

How about a less crude option...get the script to change PUPMODE to 5 so the default is to not save but all the shutdown cleanups are run..... and puppy is dirty enough without skipping those as well.

Can't remember if the 'make a save?' option has a timeout but would be worth adding one.

mike

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#6 Post by backi »

Hi !
Maybe there are risks shutting down so fast .......in case there is risk in it .... please let me know ..

uptill now i never did encounter any problem ... but not quite sure ...

Cheers !

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#7 Post by Smithy »

Well if you could add the code Backi, that just closes the dialogue when you hit NO.
That would be good for starters.

Then there was this code from Musher:

Code: Select all

#PREPARATION - unmount devices already mountd during boot
sleep 2
# ~/my-applications/bin/umount-only-disks.sh
####Musher0 code to unmount only disks
df -H -T -x squashfs -x tmpfs -x rootfs -x aufs -P | grep "/mnt/s" | cut -f2 -d'm' > spc_dsq.txt
while read line
do
umount /m$line
done < spc_dsq.txt
rm -f spc_dsq.txt
sleep 2
Maybe some Code expert could give it the once over and see if this would do the job.
Maybe remove the sleeps?
I did mention this in a thread but no b**ger replied.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#8 Post by MochiMoppel »

Smithy wrote:it originated from forum member Backi
Backi? Hmm...I'm afraid it originated here. It was preceded by a discussion how to focus the No button by default to avoid this funny question, but there seems to be a bug in Xdialog and the -default-no option doesn't work here.

I use this dialog every day, but I made some changes. I added a timer and I made sure that "No" or pressing Escape just close the dialog and do nothing:

Code: Select all

#!/bin/sh
# skips /usr/bin/wmpoweroff => rc.shutdown Powers off computer without saving the session.

Xdialog  --timeout 5 --no-close --title "script $0" --yesno "\n\nAre you sure to power-off computer WITHOUT saving?\n\n(Defaults to YES after 5 sec)" 0 0
[ $? != 1 ] && exec /bin/busybox poweroff
Above is what I use. I go immediately to poweroff without deleting .XLOADED because I don't use a pupsave file, but "normal" users should add the rm /etc/.XLOADED statement. The /initrd/pup_ro1/etc/.XLOADED statement added by Backi(?) makes no sense to me. If there is an .XLOADED there, which I doubt, it would be read-only.

Edit 2013-10-14:
Looking again at the 3 mistakes in the customized code of the initial post I probably should make clear where the .XLOADED stuff should go:

Code: Select all

[ $? != 1 ] && rm /etc/.XLOADED && exec /bin/busybox poweroff
Edit 2013-10-20
Following on jrb's nice idea (see his post on Oct.14) I now change to PUPMODE 12 on shutdown. It's about 2sec slower than the brute force method, but it's fast enough and it gives peace of mind. No need anymore to care for .XLOADED:

Code: Select all

#!/bin/sh
Xdialog  --timeout 5 --no-close --title "Power-off" --icon "/usr/local/lib/X11/pixmaps/question.xpm" --yesno "\nAre you sure to power-off WITHOUT saving?\n\n(Defaults to YES after 5 sec)" 0 0
if [ $? != 1 ] ; then
	sed -i 's|PUPMODE=[0-9]*|PUPMODE=12|' /etc/rc.d/PUPSTATE
	exec wmpoweroff
fi
---------
Last edited by MochiMoppel on Sat 21 Jun 2014, 01:14, edited 4 times in total.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#9 Post by mikeb »

hmm default is to offer to save.... forgot that glorious shutdown script which is why you all look for shortcuts..... it could be changed so the default is to not save and add a timeout but then you might as well improve the lot.
But if you are creating a script to mimic rc.shutdown then why not use it in some fashion?

Problems?...just the unmounting of drives... scripts in puppy are continually writing to temp files ...hit the wrong moment and it may upset it.

I did have a instant shutdown button years ago but only used it with a multisession harddriveless machine so there was nothing to potentially mess up

this bu**er must have missed yer thread :D

mike

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#10 Post by Smithy »

excellent MochiMoppel, I was just going to mention that it would be good for Puppy on a stick or CD, but I see you have covered all this back in 2011, and now.

Nice one mike!

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#11 Post by Sylvander »

mikeb wrote:...it could be changed so the default is to not save and add a timeout
I have various Puppies set to offer the option "to save or not to save"...
With the default as "Don't save..."...
And unfortunately, no timeout....YET. :(
Here's the code I use in...
/etc/rc.d./rc.shutdown

Code: Select all

  #the above are in unionfs at /.
  dialog --defaultno --yesno "Save this session?" 0 0 >/dev/console
  if [ $? -eq 0 ]; then
  echo "Saving session to $SAVEFILE (${SAVEPART})..." >/dev/console
  /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
  fi
  ;;

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#12 Post by backi »

Hi MochiMopel !
You are right .

No the script did not originated from forum member Backi.. thats right .

Saved it somewhere but could not find tread anymore ...so i just posted the script .....

Thanks ...helped me a lot .

But the question is .....is there any danger in using it ?

Cheers !!

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#13 Post by mikeb »

@ sylvander

--timeout 8
just add that to the dialog line

Note with 'timeout' it carries on even if you select the alternative ..ie selecting the alternative but not hitting 'enter' still selects the default

I have first boot set to default to not save and once a save is present the default is to save (multisession and archive only of course)...both have timeouts so hands off they follow the expected path and only human intervention will change that.

mike

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#14 Post by MochiMoppel »

mikeb wrote:hmm default is to offer to save
No, it's not. The script isn't even able to save
mikeb wrote:it could be changed so the default is to not save and add a timeout
Are you actually answering to my post???
mikeb wrote:But if you are creating a script to mimic rc.shutdown then why not use it in some fashion?
It doesn't mimic rc.shutdown and for my reasons to stop using rc.shutdown see the first link
backi wrote:But the question is .....is there any danger in using it ?
I personally feel safe because without a pupsave file and everything running in RAM I always start with a clean slate, no matter how messy I power off. This doesn't help me though when I'm shutting down in the middle of a download or still have an unsaved document open. Just be carefull...but this applies the same to the regular shutdown. I remember that - long time ago - I made some tests while running a dummy pupsave file and the script never gave me problems. You could test yourself.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#15 Post by mikeb »

@MochiMoppel........I was not answering your post ... we happened to post at the same time.... you can sleep safely at night
Be chuffed you get answers :D
mike

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#16 Post by jrb »

mikeb wrote:How about a less crude option...get the script to change PUPMODE to 5 so the default is to not save but all the shutdown cleanups are run.....
I don't have a pupsave file but use this

Code: Select all

sed -i 's|PUPMODE=5|PUPMODE=12|' /etc/rc.d/PUPSTATE
in a script in /etc/init.d/. It's in my custom built adrive with PHATslacko5502. When I shut down Puppy tells me all changes are already saved. :wink:

In other puppies I rename the stock puppy_xxx.sfs to zdrv_xxx.sfs and then create my own small puppy_xxx.sfs, much like an adrive.

Works a treat. :D

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#17 Post by Sylvander »

mikeb wrote: --timeout 8
just add that to the dialog line

Note with 'timeout' it carries on even if you select the alternative ..ie selecting the alternative but not hitting 'enter' still selects the default
I did this and clicked the "Save..." icon on the desktop to save the change.
Then at reboot the choice "to save or not to save" was no longer offered. :(
It just shutdown and rebooted without any notifacation that a save was taking place.
So I've no idea whether it saved or not.

I've reverted the file to the previous arrangement, and it is now working as before I added this timeout change.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#18 Post by Flash »

As for the possibility that a sudden shutdown might somehow hurt the computer, I'd expect any computer designer to make sure his creation could handle a power failure without damage. The only exception would be if something is being written at the time. If I don't have anything I want to save to my multisession DVD, I simply turn off the power to my computer. I've been doing that for something like 8 years, without any damage that I'm aware of. I've even turned off my computer with hard disk drives mounted. They were just sitting there doing nothing, so no harm was done.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#19 Post by mikeb »

I don't have a pupsave file but use this
Code:
sed -i 's|PUPMODE=5|PUPMODE=12|' /etc/rc.d/PUPSTATE
in a script in /etc/init.d/. It's in my custom built adrive with PHATslacko5502. When I shut down Puppy tells me all changes are already saved.
ah ha...now thats neat... case determines what save method.... 12 does nothing as such ...job sorted..... thats the bunny to use... fast shutdown but with clean unmounting.
I think in this case PUPMODE=13 would be needed instead of 5 to bypass the snapmerge stuff.

@ sylvander...hmm perhaps check the syntax... here's a working examplefrom my pup I am on now...

Code: Select all

dialog --timeout 8 --defaultno --no-label "NO_SAVE" --yes-label "SAVE" --yesno "Press ENTER key or wait 8 seconds blah blah..." 0 0
you can test this stuff in a terminal to avoid live testing

Mike

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#20 Post by Ted Dog »

mikeb wrote:hmm default is to offer to save.... forgot that glorious shutdown script which is why you all look for shortcuts..... it could be changed so the default is to not save and add a timeout but then you might as well improve the lot.
But if you are creating a script to mimic rc.shutdown then why not use it in some fashion?

Problems?...just the unmounting of drives... scripts in puppy are continually writing to temp files ...hit the wrong moment and it may upset it.

I did have a instant shutdown button years ago but only used it with a multisession harddriveless machine so there was nothing to potentially mess up

this bu**er must have missed yer thread :D

mike
Lol, Done the same, the power cord was easier to reach and with multisession DVD on a driveless machine, shutdown in Zero seconds. But burned myself once after pulling files from a windows machine harddrive.
I rewrote multisession to default 'yes' 'yes' no wait, since no, no with a powercord so close was redundant. :wink:

Post Reply