Global Script Best Practices


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Global Script Best Practices
# 1  
Old 08-31-2012
Global Script Best Practices

Hey there.

I am a relative rookie when it comes to Linux/Unix Administration and have been learning to adapt my meager coding skill to working with shell scripts in the 'nix realms. I have done some exhausting searches for and found plenty of information on making scripts globally available but cannot seem to find any cohesive best practices. Would anyone here care to take a stab at pointing me in the right direction?

Thanks in advance,
T
# 2  
Old 08-31-2012
Are you talking about deployment of scripts? This is really code managment or playing code librarian. A decent app like Serena allows you to set up complex rules for pushing code into use. There are also some opensource applications for this on sourceforge.net

Best practices for this start with the least privilege principle. Only grant the minimum privilege required and only to those that need it. Same goes for scripts.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 08-31-2012
It comes down to "keep your stuff obviously yours, and obviously separate". UNIX has many options available for doing so; you can take it as far as you like.

You can keep your scripts in /home/myusername/bin/ and add that to your own PATH ( by modifying ~/.profile or whatever equivalent file your shell uses ) so your scripts are available to your own user without typing the absolute path every time. This is easy, safe, secure, and convenient. You enjoy the effects of having a script installed globally without having to actually do so, letting you modify them without elevated permissions, which greatly reduces your chances of making a system-wrecking mistake or causing confusion with other users.

You also could install in /usr/local/sbin/ instead of /usr/sbin/ to keep your files apart from the system's. /usr/local/ is generally empty and reserved for things like this; you may need to add it to your PATH. If you absolutely must install them globally, this is a bare minimum IMHO.

You could also install into /opt/myapplication like large commercial applications frequently do, keeping your files REALLY far apart from the system stuff. This is probably the best option if you have a really big set of interdependent parts that must be system-global yet kept together in one place. Sets of things like this often have big trees of files under /opt/myapplication, with their own set of PATH's and other variables which must be loaded before the app can be used.

If for some reason I really, really must install into /usr/sbin or what have you, what I do is install into /opt/myappdir anyway, and just make /usr/sbin/myapp a symbolic link to /opt/myappdir/myapp. If I need to find and remove everything belonging to myappdir later, I've at least given myself a straightforward way to do so.

You can even put things in a chroot, isolating your stuff hermetically apart from the rest of the system.

For your purposes as a beginner, the very first option is probably the best, easy and safe and useful.

Last edited by Corona688; 08-31-2012 at 12:47 PM..
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Date and time change in global and non global zone

Hi, If I change date and time in global zone, then it will affect in non global zones. During this process what files will get affect in non global zones and which mechanism it's using to change. gloabl zone:Solaris 11.3 X86 TIA (1 Reply)
Discussion started by: Sumanthsv
1 Replies

2. Solaris

Global and non-global zone resource sharing - tricky

hi all, Just a simple question but i cant get the answers in the book - In my globalzone , assuming i have 4 cpus (psrinfo -pv = 0-3), if i set dedicated-cpu (ncpus=2) for my local zone Is my globalzone left with 2 cpus or still 4 cpus ? Does localzone "resource reservation.e.g. cpu in... (6 Replies)
Discussion started by: javanoob
6 Replies

3. UNIX for Dummies Questions & Answers

Global - Local script??

Hi, I have a script which can be called from any path on the machine. It kind of acts like a global script. How do I achive this? :confused: The path from which I call it is different from the path where it exists. (where <script name> ) Thanks and Regards, Preetham R. (1 Reply)
Discussion started by: preethgideon
1 Replies

4. Solaris

How to identify a global or non-global Solaris server?

Hi, I have Solaris zone configured with Solaris 9 and 10. In Solaris 10(non global), I use the command “zonename” to get whether it is global or non-global server. For Solaris 9, what command I can use to get whether it is global or non-global server. Regards, Kalai :confused: (25 Replies)
Discussion started by: kalpeer
25 Replies

5. Solaris

How to see global hostname by logging in non global zones?

Hi guru Could any one help me by letting me know, how to see global hostname by logging in non global zones Regards (2 Replies)
Discussion started by: girish.batra
2 Replies

6. Solaris

How to access ENV variables of non global zones in global zone???

Hi Guys, My requirement is I have file called /opt/orahome/.profile in non global zone. PATH=/usr/bin:/usr/ucb:/etc:/usr/sbin:/usr/local/bin:/usr/openwin/bin:. export PATH PS1="\${ORACLE_SID}:`hostname`:\$PWD$ " export PS1 EDITOR=vi export EDITOR ENV=/opt/orahome/.kshrc export ENV... (1 Reply)
Discussion started by: vijaysachin
1 Replies

7. Solaris

Is there two different kernel`s running in global and non global zone?

Hi All, I want to know for non global zone there will be different kernal running? (1 Reply)
Discussion started by: vijaysachin
1 Replies

8. Solaris

How can we copy a directory from Global to Non-global zone?

Hi All, How can we copy a directory from global zone to non-global zone using SCP command? (8 Replies)
Discussion started by: vijaysachin
8 Replies

9. Shell Programming and Scripting

Global Variable in a script?

How to create a Global variable within a script file. say i want a varaible called LOGFILE to be used within all the script. how to do that? (2 Replies)
Discussion started by: skyineyes
2 Replies

10. Shell Programming and Scripting

dynamic global script

Hi, I have to create a global dynamic script which should ask for the env or some other variables and then create the soft links. let's say that I have to create ten soft links and the path for these soft links is different for each env for e.g: WDEV: /d02/app/applmgr/wdev/appl/CDCRM/bin... (2 Replies)
Discussion started by: isingh786
2 Replies
Login or Register to Ask a Question