Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Programming & Scripting
Reload this Page /root/.bashrc with "only run once" part
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Programming & Scripting C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Reply
 
Thread Tools Display Modes
Old 07-01-2007   #1 (permalink)
Rava
Just Joined!
 
Rava's Avatar
 
Join Date: Jul 2007
Location: hacking 127.0.0.1
Posts: 3
Question /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
Rava is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
KDE doesn't start after rebuild fli3818 Linux Desktop / X-Windows 1 06-28-2004 04:49 AM
will Mplayer will playing windows media player format too ?? hasan Linux Newbie 30 10-02-2003 03:20 AM




All times are GMT. The time now is 02:14 PM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0