• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Question for Admins


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
akohan
Asked:
akohan
  • 5
  • 3
  • 2
1 Solution
 
Kerem ERSOYPresidentCommented:
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
 
akohanAuthor Commented:

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
 
Kerem ERSOYPresidentCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
kyle_in_taiwanCommented:
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
 
akohanAuthor Commented:

Thank you. It totally makes sense.
0
 
akohanAuthor Commented:


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
 
kyle_in_taiwanCommented:
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
 
akohanAuthor Commented:

But sometimes find command brings up more than one path. Then what?
0
 
kyle_in_taiwanCommented:
If all the paths are valid, then just pick one.

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

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now