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

Non release banter
Post Reply
NevaAlone
White ninja
White ninja
Posts: 4
Joined: 21 Feb 2015, 18:58
Distribution: Porteus 3.1
Location: NZ

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

Post#1 by NevaAlone » 21 Feb 2015, 23:26

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

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: New save.dat every time ports is booted

Post#2 by brokenman » 22 Feb 2015, 00:06

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.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
francois
Contributor
Contributor
Posts: 4901
Joined: 28 Dec 2010, 14:25
Distribution: kde xfce porteus manjaro kubun
Location: Enfin l'été, le changement climatique attendu: le soleil.

Re: New save.dat every time ports is booted

Post#3 by francois » 22 Feb 2015, 00:55

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.
Voltaire: Le mieux est l'ennemi du bien.

tome
Contributor
Contributor
Posts: 561
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Poland
Contact:

Re: New save.dat every time ports is booted

Post#4 by tome » 22 Feb 2015, 09:28

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.

NevaAlone
White ninja
White ninja
Posts: 4
Joined: 21 Feb 2015, 18:58
Distribution: Porteus 3.1
Location: NZ

Re: New save.dat every time ports is booted

Post#5 by NevaAlone » 22 Feb 2015, 19:38

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

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: New save.dat every time ports is booted

Post#6 by brokenman » 23 Feb 2015, 01:13

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.
How do i become super user?
Wear your underpants on the outside and put on a cape.

NevaAlone
White ninja
White ninja
Posts: 4
Joined: 21 Feb 2015, 18:58
Distribution: Porteus 3.1
Location: NZ

Re: New save.dat every time ports is booted

Post#7 by NevaAlone » 23 Feb 2015, 03:28

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

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: New save.dat every time ports is booted

Post#8 by brokenman » 24 Feb 2015, 02:18

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.
How do i become super user?
Wear your underpants on the outside and put on a cape.

NevaAlone
White ninja
White ninja
Posts: 4
Joined: 21 Feb 2015, 18:58
Distribution: Porteus 3.1
Location: NZ

Re: New save.dat every time ports is booted

Post#9 by NevaAlone » 24 Feb 2015, 02:40

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

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: New save.dat every time ports is booted

Post#10 by brokenman » 24 Feb 2015, 14:06

Excellent. Good to see a Kiwi onboard. ;)
How do i become super user?
Wear your underpants on the outside and put on a cape.

Post Reply