Solved

Question for Admins

Posted on 2006-10-20
10
188 Views
Last Modified: 2013-12-16

Hello,

I have written a backup/recovery script which uses rsync. However, it requires to have a config file. the config file will be created automatically when user run it for the first time. Now my question is where should the script place it? next to itself in this same directory or in a different directory?

What is right policy for this?

Thanks
0
Comment
Question by:akohan
  • 5
  • 3
  • 2
10 Comments
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 17777949
Hi,

There's no policy with that. Generally Scripts either include some other script or just run and create a file. I generally create the file in /tmp only when it is complete I tranfer it where it will stay. Then I delete these files since /tmp is just a common place...
0
 

Author Comment

by:akohan
ID: 17777982

thanks but this is not assumed as a temp file to be placed under /tmp. From the time of config creating on it will be used. it contains sensitive informatoin that all script operations are based on it so I don't think tmp is a good place for it.
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 17778192
ok just create a folder called tempscr "chmod 600" it and keep your file there when you are done transfer it to another safe place whre tyour script will be.

BTW nobody will use a plain text file to keep very sensitive info (unless he/she is younger than 12 and very naive).. These are readable to any person shuould he has some way to open it.
0
 
LVL 5

Accepted Solution

by:
kyle_in_taiwan earned 50 total points
ID: 17789357
Actually, there *is* a policy for scripts.

They generally get placed in /usr/local/bin or .../sbin, and their config scripts can be placed either in /etc or, if you prefer, in /usr/local/include (depending on how important you think the scripts are).  It's also possible to put them in the system path -- /bin or /sbin directly -- if you think they're important enough for it.  That, though, is generally against policy, since those trees are typically reserved for root-system binaries only.

Sometimes folks place 'em in /usr/share, as well, but again that's not really policy;  the /usr/share tree is for widely available files that are available to general users, and the /usr/local tree is for files that are available for users but peculiar to the local machine (and meant to stay that way).   Since there really isn't any other place to put local files, though, it also gets used to store tailored scripts of every sort.

My backup scripts are in /usr/local/bin, for example, and their config scripts are in /etc both for convenience as well as by virtue of their importance.

If you're working on a production machine then it really wouldn't be good form to put 'em just anywhere, since that complicates the next sysadmin's life considerably.
0
 

Author Comment

by:akohan
ID: 17790023

Thank you. It totally makes sense.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:akohan
ID: 17790282


Hello again,

Still one question I need to ask you. In my script I'm using  "rsync" and other common commands such as  cat, logger, crontab, service, gawk and ...

Now, since every machine might have placed these files under different directories so I'm going to run a find command (one-time) at the beginning of the script to find them and save them in the cofig file (let's call it initializatoin) . Then the config file will be like:

#config file
RSYNC=/usr/bin/rsync
SERVICE=/sbin/service
and ...

As I said the reason I'm doing this is because I noticed there are other machines that their filesystem structure in terms of location of these files is different. On Machine A  RSYNC in under /usr/bin  but on Machine B, RSYNC is located under /bin  and this script will be running on different machine.

Am I on a right track or no? please explain if you have a better suggestions

Thanks

 


0
 
LVL 5

Expert Comment

by:kyle_in_taiwan
ID: 17793460
That looks pretty similar to the ones i've got on my machines, so yeah -- i think that's the right track.

I never have had to run a config-script like you do, but i've still got the commands declared at the beginning of the script because i use it over ssh; consequently, the root path gets stripped and all of the commands must be declared with the full path, every time.

Running a find command that configures the full path for each system is the answer i'd use, as well.
0
 

Author Comment

by:akohan
ID: 17793694

But sometimes find command brings up more than one path. Then what?
0
 
LVL 5

Expert Comment

by:kyle_in_taiwan
ID: 17793791
If all the paths are valid, then just pick one.

A simple "read" function will take the first entry and drop the rest.
0
 

Author Comment

by:akohan
ID: 17799224

I don't agree with you in this one :)

since I did so it returned two files with the same name but different sizes! way different applications.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now