/root/.bashrc with "only run once" part The goal:
Creation of a /root/.bashrc which runs only for the first time started (meaning first root login), then it starts another script.
That ran script will (besides other stuff) alter the ~/.bashrc. [1]
My favorite approach:
Check the /root/.bashrc against its known md5sum. But how to include the md5sum in the file of which the md5sum is created?
I see no chance for that. [2]
I could create a empty file named e.g. ~/.bashrc_md5sum_* where the "*" part is the md5sum of the ~/.bashrc. Then ~/.bashrc checks itself against that checksum: if the same: start the other script, if differs: skip that part.
[Here the .bashrc could be altered and only the ~/.bashrc_md5sum_* must be set to the new md5sum] [3]
I could check the ~/.bashrc against its date & size.
[Now the code must be altered every time the ~/.bashrc changes, so approach [2] is much better than [3]] [4]
I could create a certain empty file like ~/.bashrc_ok
The ~/.bashrc first checks if that file exists, if yes: "echo -n ~/.bashrc_ok", other script started.
If no: ~/.bashrc skips that part.
[The code needn't altering if ~/.bashrc changes; It is possible to rerun the other script with next root login by simply deleting the ~/.bashrc_ok file. But that will never be needed as the ran scipt will complain when ran more than once and ask if already existing files really should be re-copied to.]
So to me idea [1] and [2] are the best for that purpose.
Has anybody an idea of how the [1] idea could be managed? Or a new approch for that goal I wasn't thinking of?
Please excuse my bad English and / or possible typos as I am no native speaker.
__________________
Yours Rava
|