User:Kutschke: Difference between revisions

From Mu2eWiki
Jump to navigation Jump to search
(Created page with "Mu2e uses the '''bash''' linux shell exclusively for the interactive command line and shell scripting. In general, this is the most powerful shell and the professional's choi...")
 
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
Mu2e uses the '''bash''' linux shell exclusively for the interactive command line and shell scripting.  In general, this is the most powerful shell and the professional's choice.
Rob's working space.


==Setup scripts==
[https://mu2ewiki.fnal.gov/wiki/User:Kutschke/Draft_WikiTips Draft WikiTips]


These are also known as login scripts.
Check that this changed: setup mu2e


If you are a bash expert and want to roll your own, read this section and make your own decisions. See also [[#Expert Only]], below. If you are not a bash expert, follow the steps described here.  We also suggest that you familiarize your self with the information in  the section [[#How Bash Startup Scripts Run]].
[[User:Kutschke/Draft_SL7_EOL]]


When you first get a Mu2e computing account, we recommend that you copy two example files, .bash_login and .bashrc,  to your home directory.  The funcationality provided by these scripts is described below. 
[[User:Kutschke/testpage2]]


First, check to see if you have already have existing versions of these files:
[[User:Kutschke/Mu2eEnvironments]]
> cd ~
> ls .bash_profile .bashrc
.bash_profile .bashrc
If you have these files, make backup copies because the next steps will overwrite them:


> cd ~
[[Category:ReplaceTest]]
> mv .bash_profile .bash_profile.sav  # only if needed
> mv .bashrc .bashrc.sav              # only if needed
> curl -O https://github.com/kutschke/Bootstrap/blob/retireUPS/dotFiles/.bash_profile
> curl -O https://github.com/kutschke/Bootstrap/blob/retireUPS/dotFiles/.bashrc
 
In the above, the option argument to curl is a capital letter O, not the numeral zero.  You can also click on the links to look at the files before your download them.
 
Here are some comments about each of these files.
* Example [https://github.com/kutschke/Bootstrap/blob/retireUPS/dotFiles/.bash_profile ~/.bash_profile]
** This file is executed by the system at the start of each login shell.
** If ~/.bashrc file exists, it sources ~/.bashrc.  This ensures that a login shell has all of the functionality of a non-login shell. For all Mu2e computing work this is what you want.
** If you wish to supply your own customizations to ~/.bash_profile we suggest that you create a file named ~/.my_bash_profile and add your content to that file.  The example .bash_profile looks for ~/.my_bash_profile and, if it exists, sources it.  We recommend this so that you keep your customizations separate from the recommended basic .bash_profile.  This will simplify future evolution of the recommended base .bash_profile.
** If you had a previously existing .bash_profile, read the section [[#Obsolete setup patterns]] and then merge the still-useful content of your old .bash_profile into .my_bash_profile.  Be careful not to needlessly duplicate content already present in your new .bash_profile.
* Example [https://github.com/kutschke/Bootstrap/blob/retireUPS/dotFiles/.bashrc ~/.bashrc]
** It defines the environment variable BASH_ENV to ensure that subshells have the same configuration as non-login shells.
** It defines the alias, '''mu2einit'''.  When you run the command '''mu2einit''', it create the Mu2e computing environment in your current shell.
** It sources /etc/bashrc which is needed to make some Fermilab provided software available in your shell.
** It enables two strongly recommended safety features.  This also serves as an example of how to configure your environment differently for interactive and non-interactive shells.
** As for .bash_profile, we recommend that you put personal configuration in .my_bashrc.
** If you had a previously existing .bashrc, read the section [[#Obsolete setup patterns]] and then merge the still-useful content of your old .bashrc into .my_bashrc.  Be careful not to needlessly duplicate content in your new .bashrc.
** .my_bashrc is the file in which to put things like setting your prompt, defining aliases etc
 
We strongly recommend that you '''not''' run '''mu2einit''' in your login scripts.  This is particularly important if you work on more than one Fermilab experiment.  Experience has shown that you should keep your login scripts generic and define aliases, or functions, like
'''mu2einit''' that you can
 
We strongly recommend you '''not''' setup UPS packages (other than UPS itself) in your login scripts.  Experience has shown that this will sometimes interfere with the correct operation of Mu2e software.  In particular, if your login scripts source login/setup scripts from other experiments you should remove them from your login scripts. The recommended pattern is to keep your login scripts free of experiment specific code and to maintain separate per-experiment scripts that you source by hand after logging in; you should only source one of these scripts in any given shell.
 
 
 
Other notes:
# The Fermilab maintained systems execute  /etc/profile.d/*.sh for login shells and /etc/bashrc for non-login shells.  This may be different on other machines.
# We recommend that you '''not''' use ~/.login, ~/.profile, ~/.shrc or ~/.cshrc .  There is no reason for them to be present in a Mu2e environment.
 
=== Verify that Your Login Scripts Work Correctly ===
To verify that the login scripts have correctly setup UPS, logout and log in again.  Then do:
> printenv PRODUCTS
/cvmfs/fermilab.opensciencegrid.org/products/common/db
> type setup
setup is a function
setup ()
{
    . `/cvmfs/mu2e.opensciencegrid.org/artexternals/ups/v6_1_1/Linux64bit+3.10-2.17/bin/ups setup "$@"`
}
> ups active
Active ups products:
ups              v6_0_7          -f Linux64bit+3.10-2.17                    -z /cvmfs/fermilab.opensciencegrid.org/products/common/db
If everything matches, modulo version numbers, it worked correctly.
 
===Obsolete setup patterns===
It is common to find that you have inherited an old .bash_profile with setup patterns like these
<pre>
pa=/grid/fermiapp/products/common/etc
if [  -r "$pa/setups.sh" ]
then
  . "$pa/setups.sh"
  if ups exist login
  then
      setup login
  fi
fi
</pre>
 
<pre>
if [  -f "/afs/fnal.gov/ups/etc/setups.sh" ]
then
    . "/afs/fnal.gov/ups/etc/setups.sh"
    if ups exist login
    then
        setup login
    fi
fi
</pre>
 
These are obsolete and should be updated as described above.
 
===Expert Only===
 
If you choose that your login scripts will not setup UPS as described above, you will need to remember to do the following: everywhere that the Mu2e instructions tell you to
 
> setup mu2e
 
you should instead:
> source /cvmfs/mu2e.opensciencegrid.org/setupmu2e-art.sh

Latest revision as of 19:57, 7 August 2024