Page 1 of 1

New save.dat every time ports is booted [SOLVED]

Posted: 21 Feb 2015, 23:26
by NevaAlone
Hello,
I have a use case where I need the save.dat from a previous session to be archived and a new/empty save.dat to used every time porteus is booted.
basically i am looking for:
On boot of Porteus:
1. Rename current save.dat to save[last updated time/date].dat
2. cp save_tmp.dat to save.dat
3. Start new save.dat
4. User logins

save_tmp.dat is a previously created file using the create .dat tool

I thought that I could do something with grub, but I don't think that I can cp or mv files using the grub cli

Any help would be awesome.

Cheers
R

Re: New save.dat every time ports is booted

Posted: 22 Feb 2015, 00:06
by brokenman
I think the easiest way to accomplish this would be with a linux file sytem, avoiding the need for a save.dat file. You could then use a shutdown script that moves the changes FOLDER to whatever name you desire. A new fresh changes folder will be generated upon next boot. The other option involves unpacking the initrd.xz and writing something into linuxrc which does the file shuffling before handing over to init.

Re: New save.dat every time ports is booted

Posted: 22 Feb 2015, 00:55
by francois
Welcome to porteus NevaAlone. :)

Presently, what is the set up of your hdd. Can you give us the output of fdisk -l? Then just tell us what you intend to do with each partition. For sure linux filesystem is better with linux os. Less restrictive, more simple to manage.

Re: New save.dat every time ports is booted

Posted: 22 Feb 2015, 09:28
by tome
I think it would be better to do it at shutdown - I can try to do it, if you want. It seems to be simple.

Re: New save.dat every time ports is booted

Posted: 22 Feb 2015, 19:38
by NevaAlone
Thank you for your replies! Awesome :)
If it was able to be done at boot time, that would be great, that way if the system was powered off without proper shut down then I can capture any changes. I need to have the save.dat or a changes folder archived for each session so it can be forensically reviewed if there was a problem.

francois: hello, I don't have a very complicated layout.

Device Boot System
/dev/sda1 * Linux
/dev/sda2 Linux

I would like to move the dated changes folder to /sda2 as I have a decent amount of storage there.

Cheers
Reuben

Re: New save.dat every time ports is booted

Posted: 23 Feb 2015, 01:13
by brokenman
if the system was powered off without proper shut down then I can capture any changes.
Changes are 'real time' so if the system is powered off you will still have access at next boot. If it is essential to be done during boot then editing linuxrc may still be possible.

Re: New save.dat every time ports is booted

Posted: 23 Feb 2015, 03:28
by NevaAlone
Hello,
Thank you,
I have been able to get most of my changes working apart from appending the date_time to the newly moved folder.

It looks like that date isn't available at this stage of the boot. I checked the bin folder with in initrd.xz and isn't date in the folder. I have tried to create a ln -s to busy box and repackage initrd.xz but it doesn't seem to work. I am doing something wrong with the sym linking.

Cheers
R

Re: New save.dat every time ports is booted

Posted: 24 Feb 2015, 02:18
by brokenman
bin/busybox --list shows that date hasn't been compiled in. Perhaps try taking the date binary from /bin/date from standard porteus (001-core.xzm) and put it in initrd.xz.

Re: New save.dat every time ports is booted

Posted: 24 Feb 2015, 02:40
by NevaAlone
Hello,
Thank everyone that helped! :)

I got it going by updating the busybox version in the initrc.xz with the latest, symlinked 'date' to busybox and every worked like a charm!!

I have learned a lot about the boot process :)

Thank you again, you guys rock!

Cheers
R

Re: New save.dat every time ports is booted

Posted: 24 Feb 2015, 14:06
by brokenman
Excellent. Good to see a Kiwi onboard. ;)