How to save to Savefile only on demand in Puppy 5.2

How to do things, solutions, recipes, tutorials
Message
Author
login123
Posts: 13
Joined: Tue 22 Jun 2010, 18:45

How to save to Savefile only on demand in Puppy 5.2

#1 Post by login123 »

Hello. First post here. Thank you for the excellent software Puppy 520. It is the best thing since sliced bread.
I am new to this linux business, and certainly not a coder, so if I say something goofy please correct me. :-)
I am running Puppy 5.20 (now 5.25) on a 4 gb usb stick w/ 2 partitions: ext3 and fat32, changes saved to ext3.

Have been seeking a simple way to control saving sessions, in case of a mistake or an unwanted installation. Am assuming that:
- - like me, readers have limited knowledge of the OS and of script editing.
- - Puppy is on a usb stick, and not used as a permanent working OS, like on a HD.

If you make the 3 edits below, these 3 changes happen:
1. Session changes can still be saved at any time by clicking on the "Save" bullseye icon.
2. Session changes will not automatically save at shutdown.
3. At startup, you will get a warning message which says "X seems to have exited uncleanly the last time you ran puppy..." but no harm is done, just the changes you did not deliberately save are lost.
- - Click on "Ignore" and you will be in Puppy as it was at shutdown.

The lines to edit:
1. Open the console and type "geany /etc/rc.d/rc.shutdown" without quotes.
- - This opens the shutdown code for editing
2. Type cntrl f to search for "/usr/sbin/snapmergepuppy" without quotes.
- - /usr/sbin/snapmergepuppy is in my unaltered installation 3 times,
- - at line 817, line 847, and line 853.
3. Comment out each line that has it by typing #myrem in front of that line. The # sign alone comments it out, but use #myrem so you can find it later if you need to. :-)

So for each line (3 of'em) that originally said
/usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
you now have
#myrem /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw

4. Save the file.

5. Added Feb 22 (should have been in this post from the start): "Go to "Menu->System->Puppy Event Manager->save session->save Interval", and set the value to zero [actually 0] minutes, and OK that."

Did I get it right?
It worked here. It is based on the solutions of many other members. Thank you.

edited May 3rd 2011 for clarity.
Last edited by login123 on Tue 03 May 2011, 17:13, edited 3 times in total.

User avatar
shadow of viper`
Posts: 113
Joined: Sat 28 Aug 2010, 00:47
Location: Hyderabad, India

#2 Post by shadow of viper` »

Hi login123,

I think you got it right, however you might like to go through the below link

http://murga-linux.com/puppy/viewtopic. ... 2dcdbde424

:D

login123
Posts: 13
Joined: Tue 22 Jun 2010, 18:45

#3 Post by login123 »

Thank you. I just checked your link. Thats where the idea really came from. Couldn't find it before.

I had forgotten to mention that part by Sylvander about "Go to "Menu->System->Puppy Event Manager->save session->save Interval", and set the value to zero [actually 0] minutes, and OK that.". Did it but forgot to mention it. :oops:

Also, I had tried that code to get a dialog at shutdown, couldn't get it to work. Maybe that I didn't have the indent spaces right, will try the dialog code again soon.

Thanks again. That dialog would be a good feature to have built in to Puppy. Would allow to save as you go, and make a decision at shut down.

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

#4 Post by Sylvander »

When the pupsave file is held on a Flash Drive:
1. To prevent periodic [default is every 30 min] "saves" [actually a "copy"] back to a pupsave file on a [partition on a] Flash Drive.

2. To be given the choice at shutdown "to save or not to save".
When you click on the link to be taken to the instructions, the post 2 above those instructions tells of the location of the /etc/rc.d/rc.shutdown file to be edited.
Copy the existing file [add _orig on the end of the name] somewhere handy [I make /00].
I right-click on the file within Xfe, and choose to "Open with..." and choose "Leafpad".
If it isn't listed, I navigate to the program at /usr/bin/leafpad and choose it.
I always copy the code from the Puppy forum post...
Delete the old code...
Paste in the new code...
Move the beginnings of each line of the new code 2 spaces to the right to line up with all the other code.
Close the file and choose to save the changes.
Copy the new file [add _new on the end of the name] to sit beside the _orig copy.

3. Remember to click the "Save" icon on the desktop to manually save these changes DURING THE SESSION, otherwise, when you shut down you won't be offered any choice "to save or not to save".
And the changes will be gone when you go back in.
So you'd need to do them all over again.
And if again you fail to save them during the session...
And round and around you go, getting nowhere!
:wink:

------------------------------------------------------------------------------------

When the pupsave file is held on a HDD:
4. How I succeeded in editing the isolinux.cfg file within a Puppy ISO file [used to make the "live" Puppy optical disk], so as to make the Puppy treat its pupsave on a HDD as though it were a pupsave on a Flash Drive.
When booting the optical disk made using this changed ISO file, there aught to be a "Save..." icon on the desktop.
This really does work.
I've been using it for a long time now, and so far see no problems.
Remember, a pupsave on a HDD works faster than a pupsave on a USB2 Flash Drive.
So you get the speed of the HDD, with the ability to choose not to save the session changes back to the pupsave.

------------------------------------------------------------------------------------

5. Here's the present last page [#14 at this time] of my Puppy Linux thread.
Lots of Puppy goodies there.
Scan quickly back through the posts to see if there's anything useful to you.
Last edited by Sylvander on Mon 27 May 2013, 23:07, edited 1 time in total.

login123
Posts: 13
Joined: Tue 22 Jun 2010, 18:45

#5 Post by login123 »

Lots of goodies indeed. I'll check them out. :-)

Sadly, cannot get the dialog code to work in Puppy 5.20.
Went back and un commented all the lines I had done before.
Went to "#the above are in unionfs at /." and inserted the code.
That section now reads like this, copied directly from rc.shutdown:

Code: Select all

13) #PDEV1 and PUPSFS and PUPSAVE
  #/initrd/pup_rw has tmpfs, pup_ro1 has ${DISTRO_FILE_PREFIX}save.2fs file (PUPSAVE), pup_ro2 has PUPSFS file.
  #the above are in unionfs at /.
  echo "Saving session to $SAVEFILE (${SAVEPART})..." >/dev/console
  #myrem /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
  #myrem New code is below two spaces added at front
  dialog --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
  ;;
Saved the session, restarted.
No dialog. No Idea what I have done wrong.
Don't want to be a bother, but if you see a glitch in that code tell me what it is.
Thank you for helping.

edit: Something went wrong. Usb Stick would neither shut down nor restart. Had to reinstall using the iso. Might be because of the new version, 5.20, maybe?? For now must stay with the 3 line edits I started with.. They lock it down well enough for me.

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

#6 Post by Sylvander »

1. Your code is wrong.

2. Mine was originally like this:

Code: Select all

  #the above are in unionfs at /.
  echo "Saving session to $SAVEFILE (${SAVEPART})..." >/dev/console
  /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
  ;;
And I changed it to this:

Code: Select all

  #the above are in unionfs at /.
  dialog --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
  ;;

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

#7 Post by MochiMoppel »

Here is a slightly different version, defaulting to 'No', so you just have to hit ENTER to end your session without saving:

Code: Select all

dialog --defaultno --title "/etc/rc.d/rc.shutdown"  --yesno "\n Save session? " 0 0 >/dev/console 
		ANSWER=$? 
		if [ $ANSWER -eq 0 ]; then
		   dialog --infobox   "Saving session to \n$SAVEFILE (${SAVEPART})..." 0 0 >/dev/console
		   /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw 
		else
		   dialog --infobox   "Nothing saved! \nBye, have a nice day!"   0 0 >/dev/console
		fi 
  ;; 
I stopped using this code myself because this method has some drawbacks:
1) You mess with an important system file
2) You can't cancel and go back to the X desktop (well, maybe possible, but I don't know how)
3) If the console stays black (happens to me whenever I use suspend to RAM) you won't see the dialog

As an alternative I propose that you leave rc.shutdown as is and make a little script that lets you shutdown (or reboot) directly without saving - and let's you confirm your choice. Put an icon for this script on your desktop and use it for your normal shutdown. If however you want to save before shutting down, just use the normal options provided by the menu:

Code: Select all

#!/bin/sh

# skips rc.shutdown and powers off computer without saving the session.
Xdialog --title "script $0" --yesno "\n\nAre you sure to power-off computer WITHOUT saving?\n\n" 0 0
[ $? -eq 0 ] && exec /bin/busybox poweroff
To reboot replace 'poweroff' with 'reboot'.

One last advise: When you save your session only via the 'Save' button, but not at shutdown via menu, you will be greeted with a nasty "X seems to have exited uncleanly.." message the next time you boot up. To avoid the message, delete the file /etc/.XLOADED before you use the Save button (its a hidden file, so make hidden files visible in your file manager). Though .XLOADED is intended to be useful, I still can't think of a scenario (for frugal installs on a stick!) which would justify to keep it.

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

#8 Post by Sylvander »

1. "Though .XLOADED is intended to be useful, I still can't think of a scenario (for frugal installs on a stick!) which would justify to keep it."
What about when my lupu-520 on CD-RW is using a lupusave on an internal HDD, but lupu-520 has been altered to make it act as though the lupusave is on a Flash Drve?

login123
Posts: 13
Joined: Tue 22 Jun 2010, 18:45

#9 Post by login123 »

I must say that members here are very knowledgeable and helpful. Thanks very much for coming forward to help a guy on his first post.

Sylvander, I fixed that code. You were right, It did have errors. Got it right, character for character this time. Still no joy. Later I want to try those edits again, yours and MochiMoppel's, but not right now. Brain is tired.

I think ?? that if I simply rem out the 3 lines with "/usr/sbin/snapmergepuppy" in them, and configure the autosave option to zero, then no saves happen unless I click on the save icon. Unless I'm missing something at some deeper level. Am I?

A question please. Is it true that the warning at startup "X...exited uncleanly..." is harmless? After several restarts the OS still seems OK. If it is harmless then I'll just stay with that first configuration until I learn more about what I am doing. If it works, It can be a little ugly for now.

sergey
Posts: 6
Joined: Mon 23 Aug 2010, 21:26

Save Savefile on demand

#10 Post by sergey »

1. Elegant solution with Dialogue didnt work for me in Lighthouse Pup Linux
(deservingly called "the Gold Standard." of Pups). Probably my fault, but
I did COPY the code. Maybe because I'm on HDD Frugal instal?

2. My current method, learned from misc writings of the elders of
Puppydom:
FIRST: Open /etc/rc.d/PUPSTATE file in Geany. Edit first line,
making PUPMODE=5
SECOND: Close Geany with PUPSTATE file still loaded and active.
THIRD: Put Symlink for Geany in /root/Startup folder

RESULT: on bootup, Geany is open on the desktop with PUPSTATE
looking at me. If I want to disable saving, I change PUPMODE to "5"

3. Someone with more shell smarts than I could put a TOGGLE
SAVEFILE Icon on desktop that would execute a shell script
to change PUPMODE. (Making PUPSTATE read-only did not work.)

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

#11 Post by MochiMoppel »

Hi Sylvander and login123:
Yes, the warning is harmless, i.e.you won't break anything if you ignore it. Here is what happens - as far as my limited knowledge allows me to comprehend:
.XLOADED is created, used (for the warning) ,deleted or set to 'false' in the script /usr/bin/xwin. When you start the X desktop, the file is created with value 'true', when you exit X, it's set to 'false'. So when you use the 'Save' button to save your session, you do this while X is running, consequently your session is saved with .XLOADED having the value 'true'. When you now shutdown without the "normal" shutdown process (which would exit X, run rc.shutdown, clear .XLOADED and save the session) and then reboot, Puppy runs xwin to start X, finds .XLOADED being 'true'and says "hey, wait a minute, .XLOADED is 'true', so X is already running. You'd better check before I try to start X". Your only chance to clear this message is to delete .XLOADED and save again. Puppy is not designed to be shutdown only with an intermediate saving, it is designed to be shutdown with rc.shutdown AND the included saving mechanism.

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

#12 Post by Sylvander »

@MochiMoppel
Thanks for the explanation. :D

login123
Posts: 13
Joined: Tue 22 Jun 2010, 18:45

#13 Post by login123 »

Yes, thank you, shadow of viper & Sylvander & MochiMoppel, & sergey. Understanding is increasing ... :)

sergey
Posts: 6
Joined: Mon 23 Aug 2010, 21:26

Save to Pup Savefile only on demand

#14 Post by sergey »

Following on my post above, if PUPMODE set to 77,
this signals a multisession DVD; therefore Pup
saves only with manual save command and
at shutdown.

But how do you give a manual save command?

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

Re: Save to Pup Savefile only on demand

#15 Post by MochiMoppel »

sergey wrote: But how do you give a manual save command?
There should be a "Save" icon on your desktop. You are supposed to push it. But since you are on a frugal HD install (PUPMODE=12 ?) the script that puts the icon on your desktop (/etc/rc.d/rc.sysinit) had already decided that you don't need one when you afterwards change the PUPMODE to 77, hence no icon. How Puppy achieves saving for each PUPMODE you can see in /etc/rc.d/rc.shutdown.

My personal opinion: Changing PUPMODEs in the middle of a session is a bad idea - particularly if you have no clue what you are doing. If you only want to be master of your savings, avoiding automatic saving, then you should edit your syslinux.cfg file and add parameter pmedia=usbflash. This will put you into PUPSTATE=13, the dialog (see previous posts) will work and you will have a 'Save' button on your desktop as a bonus.

nancy reagan
Posts: 544
Joined: Thu 22 Jan 2009, 14:20

why not use this ready made tool ?

#16 Post by nancy reagan »


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

#17 Post by Sylvander »

Because that tool doesn't give you the option "to save or not to save" at shutdown?

With the arrangement I presently use...
I can choose to save manually at some chosen point in time DURING THE SESSION...
And then:
Either choose to NOT SAVE after that, not even at shut-down/reboot.
OR...
I might go to shut-down, and suddenly realise I NEED to save during shut-down.

nancy reagan
Posts: 544
Joined: Thu 22 Jan 2009, 14:20

#18 Post by nancy reagan »

Sylvander wrote: Because that tool doesn't give you the option "to save or not to save" at shutdown?

With the arrangement I presently use...
I can choose to save manually at some chosen point in time DURING THE SESSION...
And then:
Either choose to NOT SAVE after that, not even at shut-down/reboot.
OR...
I might go to shut-down, and suddenly realise I NEED to save during shut-down.
It is my experience that you can do this all with shinobar's pet

http://www.murga-linux.com/puppy/viewtopic.php?t=60678

If you want to save -during- session press the fat red circle on the desktop.

You can organize the util so that it still will ask you at shutdown to, or not to save.

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

#19 Post by Sylvander »

OK, I'll try installing it in Wary-511, and see how it goes. :D

I'm back.
Did that...
And the program warned me that I already had a pupsave made and in use, and gave me only the option to close the program.
So I guess it would be necessary to scrap my existing pupsave, lose all the work invested in that, begin afresh.
I'll think about it, but doubt if I'd want to begin again.
I'll try it with the next new Puppy that comes along.

sergey
Posts: 6
Joined: Mon 23 Aug 2010, 21:26

Save or not save to Savefile in Pup Linux

#20 Post by sergey »

Setting pmedia=usbflash does not work in the latest Puppy
versions I use -- Lighthouse 500-G, Quirky 1.4, Wary5.1.1

Puppy doesnt boot: can't find media -- it must be looking
for a USB something, because it spends some time looking.

I'm using Grub so I applied your suggestion in menu.lst and
tried all variations in syntax based on Grub's README,
For example, on kernel line using (hd0,1)/quirky140.

My method of setting PUPSTATE=5 described in my earlier post
has worked in Lighthouse, Quirky, and Wary for months for me.
It's easy although lacking the characteristic s-m-o-o-t-h,
elegance of Puppy operations.

BTW, Wary 5.1.1 is very fast to reboot, which saved me
lots of time as I rebooted dozens of times for these
experiments.

Post Reply