Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: GNUser on February 24, 2020, 10:49:11 AM
-
curaga and juanito,
Some of my configuration directories restored from mydata.tgz quickly accumulate extraneous files while the system is running (~/.mozilla and ~/.thunderbird are notorious in this regard).
Because of how tar works, running filetool.sh -r does not get rid of the extraneous files. Therefore, if I want to restore my configuration directories to their pristine state (as found in mydata.tgz) after the system has been running for a while, I have to manually delete a bunch of directories and only then run filetool.sh -r . This is inconvenient.
Therefore, I created a patch for /usr/bin/filetool.sh (see attached) that adds a -z flag to delete ("zero out") all items listed in /opt/.filetool.lst. Now running filetool.sh -zr does exactly what I need.
I hope the patch is useful.
[EDIT]: Patch removed. Safer patches are attached in later posts. Rich
-
Hi GNUser
You don't use a persistent home directory?
-
No. My /opt is persistent, but not /home.
I dislike the accumulation of files whose function is unknown to me. Call me a clean freak ;D
-
Hi GNUser
You do know there is also an /opt/.xfiletool.lst for files and subdirectories you want to exclude from your backup.
-
I know, Rich. Thank you.
I prefer to include only what I know I want (rather than exclude what I know I don't want). It keeps things as neat and tiny as possible.
-
Hi GNUser
So if I understand this patch correctly, if someone executes:
filetool.sh -zIt will read the list of all the files/directories they care about and then delete them.
If that's the case, I would strongly recommend against that patch, at least in its current state. It's too easy for someone to shoot
themselves in the foot.
-
...will read the list of all the files/directories they care about and then delete them.
That's correct. I guess it is a dangerous patch as currently written.
The operation is not dangerous when -z is combined with -r
I'll rework it and submit a safer patch.
-
Here you go. Now -z can only be used if combined with -r
-
Patch with better placement of the safety check is attached.
-
Hi GNUser
Since it tests for an illegal condition, I would change this:
+if [ "$ZERO" ] && [ ! "$RESTORE" ]; then
+ echo "-z should only be used with -r"
+fi
+To that:
+if [ "$ZERO" ] && [ ! "$RESTORE" ]; then
+ echo "-z should only be used with -r"
+ exit 3
+fi
+
I will remove the patch you attached in your original post.
-
Since it tests for an illegal condition...
Good idea. Updated patch attached.
I will remove the patch you attached in your original post.
Thank you. Best not to have the dangerous version of the patch lying around.
-
Maybe too few users would have any use for the -z option? If so, feel free to ignore the patch.
It would be easy enough for the few users who might need this to use a shell script (cleanup followed by filetool.sh -r) instead.
-
Hi GNUser
Maybe too few users would have any use for the -z option? If so, feel free to ignore the patch. ...
I was going to mention that your patch may not get accepted as being too specialized. Using restore to do a file system cleanup
on a running system is a new one on me.
-
This is the first time this has come up, and I believe a safer/more obvious way to get the same result is to reboot. So right now I'm not inclined to add the patch.
-
I figured the patch might be rejected in favor of achieving the same thing (yes, in a safer/more obvious way) with a reboot. Fair enough.
You guys do a great job at keeping TCL tiny and beautiful. Thank you :)
-
Things also don't change that often, making it easy to keep custom patches ;)
-
Things also don't change that often...
That's one of TCL's many qualities--it is conservative and therefore quite resistant to fads :)