dump-session: too many error messages
- ncmprhnsbl
- DEV Team
- Posts: 4253
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
dump-session: too many error messages
another updated version:
zz-changes-exit-test.xzm
timeout/skip action disabled for in-session commit (in line with the original dump-session)
some excess tests removed
(on shutdown/reboot) in the case of space warning, instead of adding sleep 5 to the 3 of timeout, the total timeout is set to 5.
when no space warning the default 3 timeout is used.
space amounts in human readable (Kb/Mb/Gb)
added redirect 1>/dev/tty1 after command in rc.6, this seems to work for if you use poweroff or reboot from a terminal in X session. (and isn't a problem with corrected elogind exiting)
zz-changes-exit-test.xzm
timeout/skip action disabled for in-session commit (in line with the original dump-session)
some excess tests removed
(on shutdown/reboot) in the case of space warning, instead of adding sleep 5 to the 3 of timeout, the total timeout is set to 5.
when no space warning the default 3 timeout is used.
space amounts in human readable (Kb/Mb/Gb)
added redirect 1>/dev/tty1 after command in rc.6, this seems to work for if you use poweroff or reboot from a terminal in X session. (and isn't a problem with corrected elogind exiting)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44
-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
Yes, that fixed it: now the rc.6 output is on vt1.
I've also added in .bashrc:
Code: Select all
alias reboot="loginctl reboot"
alias poweroff="loginctl poweroff"
I've actually commented it out, and it still runs and displays colored messages and without delay -- perhaps that sleep isn't needed anymore (now that I've learnt to use the `loginctl poweroff`

-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
OK. At the moment, one would need to press the "any other key" twice, because initrd/cleanup would still try to run its own changes-commit block because the /mnt/live/tmp/changes-exit wouldn't have been removed. But I understand in the future initrd that block will be commented out completely.ncmprhnsbl wrote: ↑17 Jul 2024, 00:50the decision to skip/not skip is(or should be) made well before shutdown, with the user ready with their finger on either enter/space(to skip the countdown) or any other key(to skip the save(and the countdown))
Anyway, here's my own `my-changes-commit` dangerously stripped of all the checks:
Code: Select all
#!/bin/bash
# Commits live session (RAM) to the active changes folder
# Script takes action only when 'changes=EXIT' cheatcode is used.
# Edit /etc/changes-exit.conf to in/exclude files and folders.
# Upstream: ncmprhnsbl's changes-commit
# Customized by rych
# Check if 'changes=EXIT' cheatcode is active
test -f /mnt/live/tmp/changes-exit || { echo "'changes=EXIT:' cheatcode is not active - exiting..."; exit; }
## Variables:
DEST="$(cat /mnt/live/tmp/changes-exit)"; NAME="$(basename $DEST)"
MNAME=/mnt/live/memory/images/changes ; INAME=/mnt/live/memory/images
CHNEXIT_CONF=/etc/changes-exit.conf ; EXCL=/tmp/save.excl.tmp
SFILES=/tmp/save.sfiles.tmp ; UPDATE=/tmp/save.update.tmp
# Fix folder names and make `egrep' interpret wildcards
fixdir() { sed -e 's_\._\\._g' -e 's_?_._g' -e 's_*_.*_g' -e 's@..@^@'; }
# Fix whiteout names so `egrep' doesn't interpret special characters as regex
fixwh() { sed -e 's_\._\\._g' -e 's_?_\\?_g' -e 's_+_\\+_g' -e 's_*_\\*_g' -e 's_\$_\\$_g' -e 's_\[_\\[_g' -e 's_(_\\(_g' -e 's_\&_\\&_g' -e 's@^@^@'; }
# Folders to save: argument for `find' & check that they exist.
FOLDERS="$(for x in $(grep ^/ $CHNEXIT_CONF | sed s/.//); do test -e /mnt/live/memory/changes/$x && echo $x; done)"
# Folders to exclude: argument for `egrep'
grep ^!/ $CHNEXIT_CONF | fixdir > $EXCL
## Save session:
echo "Syncing what's left in buffers"
sync
# Remount aufs with 'udba=notify' flag:
mount -o remount,udba=notify /
echo "saving changes to $DEST - this may take a while..."
cd /mnt/live/memory/changes
# Handle filenames with spaces.
IFS="
"
# Remove deleted files and non matching whiteouts
for y in $(find $FOLDERS -name ".wh.*"); do
f="$(echo $y | sed 's@\.wh\.@@g')"
test -e "$MNAME/$f" && rm -rf "$MNAME/$f";
test -e "$INAME/"*"/$f" || { echo "$y" | fixwh >> $EXCL; test -e "$MNAME/$y" && rm -f "$MNAME/$y"; }
done
# Copy new and modified files -- skip excluded whiteouts and folders
{ test -s "$EXCL" && find $FOLDERS -not -type d | egrep -vf $EXCL || find $FOLDERS -not -type d; } > $SFILES
cp -uafv --parents $(cat $SFILES) $MNAME > $UPDATE
# Remove conflicting whiteouts
for y in $(find $MNAME -name ".wh.*"); do
f="$(echo $y | sed -e 's^$MNAME^^g' -e 's^\.wh\.^^g')";
test -e "$f" && rm "$y";
done
# Reset IFS to default
unset IFS
# Remount aufs with 'udba=none' flag:
mount -o remount,udba=none /
echo "Session saved"
Code: Select all
mv -f /mnt/live/tmp/changes-exit /mnt/live/tmp/changes-exitDONE
- ncmprhnsbl
- DEV Team
- Posts: 4253
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
dump-session: too many error messages
interesting, i havn't witnessed this myself.. could be desktop dependent, ie. some desktops might take longer for elogind to deal with, stopping processes and such..
note the other thing i added to the last update: an stdout redirect to tty1in rc.6 for changes-commit:
Code: Select all
# Run changes-commit for changes=EXIT:
[ -f /mnt/live/tmp/changes-exit ] && /opt/porteus-scripts/changes-commit 6 1>/dev/tty1
ah, good point (didn't notice in my basic tests by not bothering to skip :p)rych wrote: ↑20 Jul 2024, 10:50OK. At the moment, one would need to press the "any other key" twice, because initrd/cleanup would still try to run its own changes-commit block because the /mnt/live/tmp/changes-exit wouldn't have been removed. But I understand in the future initrd that block will be commented out completely.
easily fixed by moving the rm part out of the conditional. and as you say, this is only a temporary measure for backward compatibilty with unmodified initrds.
which highlights the benefit of moving this action out of initrd, making it easier for users to tweak it to their liking..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44
-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
Having done all these tweaks, and same others perhaps (e.g. excluding /var path in its entirety from changes-exit.conf so it's never saved in /changes) to minimize saved changes... a curious thing happens. My bash history is no longer saved: not only between different instances of "sakura" terminal, as I think used to be the case, but now also after reboot: the command line history of last session isn't here. Basically, the new history is never committed, unless I explicitly issue `history -w`... or close the current terminal properly. Perhaps, that sleep 3 to the beginning of rc.6 is in deed needed for things like this... I'll keep investigating.
UPDATE. Interesting! Sakura only commits its CLI command history to the .bash_history file after it closes. Now what if in this instance of Sakura we 1) changes-commit, 2) clear the changes-exit flag by e.g.,
Code: Select all
mv -f /mnt/live/tmp/changes-exit /mnt/live/tmp/changes-exitDONE
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
dump-session: too many error messages
You could try closing Sakura, running your backup script which could backup your /home/guest/.bash_history file then run your shutdown script. Or maybe adding the backup of the /home/guest/.bash_history file to your shutdown script. But then a script to restore it would be needed. 

-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
I've decided that committing changes should better happen at the system shutdown after all the apps have exited and flushed their states into changes. Sakura is only one example of such an app, many others while open won't be updating their storage, and the only way we have them all flushed is if we close them.
My syncing script ( synchronizing my frugal and USB installation or Porteus to be identical) that calls changes_commit now postpones changes synchronization:
Code: Select all
echo "Postponing changes sync until after changes-commit at system shutdown in rc.6"
echo "$PORTDIR/changes/ $Dest/$PortFolder/changes/" > /mnt/live/tmp/changes-syncFromTo
Code: Select all
[ -f /mnt/live/tmp/changes-syncFromTo ] && changes-sync
Code: Select all
rsync -a --delete --stats $(cat /mnt/live/tmp/changes-syncFromTo) | grep "Number of"
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
dump-session: too many error messages
But won't this jink your 2 second shutdown ?

And if the other folder is full??
Basically back to the current changes=EXIT and save.dat file situation.

-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
The /changes folder is expected to be on a large enough partition and the user is advised to keep an eye on how big that folder grows. I keep my /changes small. So, it commits and syncs very fast. If the target folders were ever full then either cp or rsync would return an error rather than saving or synching the changes and the user would be noticing that the new changes aren't preserved. I don't see a problem even in that very unlikely event.
No, again: the changes-commit script was fixed by ncmprhnsbl, unified, and taken out of initrd to rc.6 where people like me can customize it and follow it with an optional synchronization.
This thread can now be closed as [Solved].
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
dump-session: too many error messages
I always use changes=EXIT for faster performance and normally use a save.dat file, currently 512MB, and in the past I've lost a lot of saved files: scripts, tweaks, bookmarks, screen prints, etc when I shutdown Porteus and the changes were bigger than the save.dat file. On USB drives I have a single partition for all Porteus folders and changes, the USB drives are old and small, 4GB - 8GB and formatted to FAT32, and I have lost data on them also when shutting down. So having the shutdown process check for space before writing to the drive, or file, and stopping if there isn't enough space is important for users who do stupid things without checking space usage effects.

-
- Warlord
- Posts: 766
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
dump-session: too many error messages
Yes, and that's another useful addition to the new, soon to be official changes-commit script. It's going to warn the user if the save.dat or /changes is getting full, so the next session they should do something about it. I've just customized it away for my case.