Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 02 Sep 2014, 03:41
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to save to Savefile only on demand in Puppy 5.2
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 3 [33 Posts]   Goto page: 1, 2, 3 Next
Author Message
login123

Joined: 22 Jun 2010
Posts: 9

PostPosted: Sun 20 Feb 2011, 10:49    Post subject:  How to save to Savefile only on demand in Puppy 5.2  

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. Smile
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. Smile

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, 13:13; edited 3 times in total
Back to top
View user's profile Send private message 
shadow of viper`


Joined: 27 Aug 2010
Posts: 25
Location: Hyderabad, India

PostPosted: Mon 21 Feb 2011, 08:33    Post subject:  

Hi login123,

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

http://murga-linux.com/puppy/viewtopic.php?t=61482&sid=dec05c1ecb35e8300dbf5e2dcdbde424

Very Happy
Back to top
View user's profile Send private message 
login123

Joined: 22 Jun 2010
Posts: 9

PostPosted: Mon 21 Feb 2011, 10:04    Post subject:  

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. Embarassed

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.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3428
Location: West Lothian, Scotland, UK

PostPosted: Mon 21 Feb 2011, 12:16    Post subject:  

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, 19:07; edited 1 time in total
Back to top
View user's profile Send private message 
login123

Joined: 22 Jun 2010
Posts: 9

PostPosted: Mon 21 Feb 2011, 18:23    Post subject:  

Lots of goodies indeed. I'll check them out. Smile

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:
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.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3428
Location: West Lothian, Scotland, UK

PostPosted: Tue 22 Feb 2011, 04:44    Post subject:  

1. Your code is wrong.

2. Mine was originally like this:
Code:
  #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:
  #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
  ;;
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 371
Location: Japan

PostPosted: Tue 22 Feb 2011, 12:30    Post subject:  

Here is a slightly different version, defaulting to 'No', so you just have to hit ENTER to end your session without saving:
Code:
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:
#!/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.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3428
Location: West Lothian, Scotland, UK

PostPosted: Tue 22 Feb 2011, 13:16    Post subject:  

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?
Back to top
View user's profile Send private message 
login123

Joined: 22 Jun 2010
Posts: 9

PostPosted: Tue 22 Feb 2011, 14:30    Post subject:  

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.
Back to top
View user's profile Send private message 
sergey

Joined: 23 Aug 2010
Posts: 6

PostPosted: Tue 22 Feb 2011, 21:38    Post subject: Save Savefile on demand
Subject description: using PUPMODE in PUPSTATE file to disable Savefile
 

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.)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 371
Location: Japan

PostPosted: Tue 22 Feb 2011, 22:40    Post subject:  

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.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3428
Location: West Lothian, Scotland, UK

PostPosted: Wed 23 Feb 2011, 04:37    Post subject:  

@MochiMoppel
Thanks for the explanation. Very Happy
Back to top
View user's profile Send private message 
login123

Joined: 22 Jun 2010
Posts: 9

PostPosted: Wed 23 Feb 2011, 06:48    Post subject:  

Yes, thank you, shadow of viper & Sylvander & MochiMoppel, & sergey. Understanding is increasing ... Smile
Back to top
View user's profile Send private message 
sergey

Joined: 23 Aug 2010
Posts: 6

PostPosted: Sat 26 Feb 2011, 18:24    Post subject: Save to Pup Savefile only on demand
Subject description: Use PUPMODE=77
 

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?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 371
Location: Japan

PostPosted: Sat 26 Feb 2011, 23:18    Post subject: Re: Save to Pup Savefile only on demand
Subject description: Use PUPMODE=77
 

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 3 [33 Posts]   Goto page: 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1042s ][ Queries: 13 (0.0063s) ][ GZIP on ]