Author |
Message |
Smithy

Joined: 12 Dec 2011 Posts: 853
|
Posted: Sun 13 Oct 2013, 05:34 Post subject:
Ultra Fast Shutdown Subject description: Use with caution |
|
I am adapting this little bit of code, and going to add it to the shutdown menu.
. Code: | #!/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
Oops, forum doesn't allow *.sh files, or txt files for that matter.
|
Back to top
|
|
 |
Jasper
Joined: 25 Apr 2010 Posts: 1350 Location: England
|
Posted: Sun 13 Oct 2013, 06:28 Post subject:
|
|
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.
_________________ Desktop (1998 with 2002 Motherboard replacement) @ 2.0 GHz with 640 MB (SDRAM) - no swap facility needed.
Precise 5.6 with Multi-session-CD + Quirky unicorn on USB2-stick + W98SE on HD for rare printing needs.
Last edited by Jasper on Mon 14 Oct 2013, 05:59; edited 1 time in total
|
Back to top
|
|
 |
Smithy

Joined: 12 Dec 2011 Posts: 853
|
Posted: Sun 13 Oct 2013, 07:10 Post subject:
|
|
: 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
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 13 Oct 2013, 07:17 Post subject:
|
|
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
|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11107
|
Posted: Sun 13 Oct 2013, 09:37 Post subject:
|
|
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
|
Back to top
|
|
 |
backi
Joined: 27 Feb 2011 Posts: 1458 Location: GERMANY
|
Posted: Sun 13 Oct 2013, 10:30 Post subject:
|
|
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 !
|
Back to top
|
|
 |
Smithy

Joined: 12 Dec 2011 Posts: 853
|
Posted: Sun 13 Oct 2013, 10:47 Post subject:
|
|
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: | #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.
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1503 Location: Japan
|
Posted: Sun 13 Oct 2013, 11:06 Post subject:
|
|
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: | #!/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: | [ $? != 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: | #!/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 Fri 20 Jun 2014, 21:14; edited 4 times in total
|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11107
|
Posted: Sun 13 Oct 2013, 11:10 Post subject:
|
|
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
mike
|
Back to top
|
|
 |
Smithy

Joined: 12 Dec 2011 Posts: 853
|
Posted: Sun 13 Oct 2013, 11:29 Post subject:
|
|
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!
|
Back to top
|
|
 |
Sylvander
Joined: 15 Dec 2008 Posts: 4328 Location: West Lothian, Scotland, UK
|
Posted: Sun 13 Oct 2013, 11:29 Post subject:
|
|
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 [I know next-to-nothing about coding] in...
/etc/rc.d./rc.shutdown
Code: | #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
;; |
|
Back to top
|
|
 |
backi
Joined: 27 Feb 2011 Posts: 1458 Location: GERMANY
|
Posted: Sun 13 Oct 2013, 11:33 Post subject:
|
|
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 !!
|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11107
|
Posted: Sun 13 Oct 2013, 12:01 Post subject:
|
|
@ 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
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1503 Location: Japan
|
Posted: Sun 13 Oct 2013, 12:16 Post subject:
|
|
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.
|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11107
|
Posted: Sun 13 Oct 2013, 12:20 Post subject:
|
|
@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
mike
|
Back to top
|
|
 |
|