fixed a couple more things that needed to be set again.
[feisty_meow.git] / scripts / core / variables.sh
1 #!/bin/bash
2
3 ##############
4
5 # variables script:
6 #   Defines the environment variables used by the personalized unix
7 #   environment.
8 # Author: Chris Koeritz
9
10 ##############
11
12 # this section should always run or bash will reset them on us.
13 # these need to be as minimal as possible.
14
15 # sets the main prompt to a simple default, with user@host.
16 export PS1='\u@\h $ ';
17 # sets the history length and max file size so we can get some long history around here.
18 export HISTSIZE=1000000
19 export HISTFILESIZE=2000000
20   
21 ##############
22   
23 # we'll run this again only if we think it's needed.
24 if [ -z "$NECHUNG" ]; then
25
26   if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi
27   
28   ##############
29   
30   # start with some simpler things.
31   
32   export SCRIPT_SYSTEM=feisty_meow
33   
34   # OS variable records the operating system we think we found.
35   if [ -z "$OS" ]; then
36     export OS=UNIX
37   fi
38   export IS_DARWIN=$(echo $OSTYPE | grep -i darwin)
39   
40   ##############
41   
42   # fallbacks to set crucial variables for feisty meow...
43   
44   # set the main root directory variable for the feisty meow codebase.
45   # this is only used for extreme failure modes, when the values were not
46   # pulled in from our auto-generated config.
47   if [ -z "$FEISTY_MEOW_DIR" ]; then
48     if [ -d "$HOME/feisty_meow" ]; then
49       export FEISTY_MEOW_DIR="$HOME/feisty_meow"
50       export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts"
51     fi
52   fi
53   
54   # similarly, make sure we have someplace to look for our generated files, if
55   # we were not handed a value.
56   if [ -z "$FEISTY_MEOW_GENERATED" ]; then
57     # The generated scripts directory is where automatically generated files live.
58     # It is separate from the main body of the shell scripts in order to keep things from
59     # exploding.
60     export FEISTY_MEOW_GENERATED=$HOME/.zz_auto_gen
61   fi
62   
63   ##############
64   
65   # umask sets a permission mask for all file creations.  the mask used here
66   # disallows writing by the "group" and "others" categories.
67   umask 022
68   # ulimit sets user limits.  we set the maximum allowed core dump file size
69   # to zero, because it is obnoxious to see the core dumps from crashed
70   # programs lying around everywhere.
71   ulimit -c 0
72   
73   ##############
74   
75   # user variables, sort of...  if they haven't given themselves a name yet,
76   # then we will make one up for them.
77   
78   # define a default name, if one wasn't already set.
79   if [ -z "$NAME" ]; then
80     export NAME='Unset Q. Namington, Fixley Your Name III'
81   fi
82   
83   ##############
84   
85   # variables for perl.
86   
87   export PERLLIB
88   if [ "$OS" != "Windows_NT" ]; then
89     PERLLIB+="/usr/lib/perl5"
90   else
91     export PERLIO=:perlio
92       # choose perl's IO over the ms-windows version so we can handle file
93       # bytes properly.
94   fi
95   
96   # iterate across our sub-directories and find the perl scripts.
97   # this currently only looks one level down.
98   for i in $FEISTY_MEOW_SCRIPTS/*; do
99     if [ -d "$i" ]; then
100       # check if there is a perl file present; add the folder to PERLLIB if so.
101       ls $i/*.pl &>/dev/null
102       if [ $? -eq 0 ]; then
103         PERLLIB+=":$i"
104       fi
105     fi
106   done
107   #echo PERLLIB is now $PERLLIB
108   
109   ##############
110   
111   # set this so nechung can find its data.
112   export NECHUNG=$FEISTY_MEOW_DIR/database/fortunes.dat
113   
114   # ensure we use the right kind of rsh for security.
115   export CVS_RSH=ssh
116   
117   # the base checkout list is just to update feisty_meow.  additional folder
118   # names can be added in your customized scripts.
119   export REPOSITORY_LIST="feisty_meow"
120   
121   # set the editor for subversion if it hasn't already been set.
122   if [ -z "$SVN_EDITOR" ]; then
123   #hmmm: not sure what original reason for having these different was...
124     if [ "$OS"  == "Windows_NT" ]; then
125       export SVN_EDITOR=$(which gvim)
126     else
127       export SVN_EDITOR=$(which vi)
128     fi
129   fi
130   
131   # initializes the feisty meow build variables, if possible.
132   function initialize_build_variables()
133   {
134     found_build_vars=0
135     # we need to know the feisty meow directory, or we bail.
136     if [ -z "$FEISTY_MEOW_DIR" ]; then return; fi
137     # pick from our expected generator folder, but make sure it's there...
138     buildvars="$FEISTY_MEOW_DIR/scripts/generator/build_variables.sh"
139     if [ -f "$buildvars" ]; then
140       # yep, that one looks good, so pull in the build defs.
141       source "$buildvars" "$buildvars"
142       found_build_vars=1
143     fi
144     # now augment the environment if we found our build variables.
145     if [ $found_build_vars == 1 ]; then
146       # the binary directory contains handy programs we use a lot in yeti.  we set up the path to it
147       # here based on the operating system.
148       # note that yeti has recently become more dependent on hoople.  hoople was always the source of
149       # the binaries, but now we don't ship them with yeti any more as pre-built items.  this reduces
150       # the size of the code package a lot and shortens up our possible exposure to compromised
151       # binaries.  people can bootstrap up their own set from hoople now instead.
152       export BINDIR=$FEISTY_MEOW_DIR/production/binaries
153   
154       # add binaries created within build to the path.
155 #    export PATH="$(dos_to_msys_path $BUILD_TOP/build/bin):$PATH"
156       export PATH="$BINDIR:$PATH"
157   
158       # Shared libraries are located via this variable.
159 #    export LD_LIBRARY_PATH="$(dos_to_msys_path $LD_LIBRARY_PATH):$(dos_to_msys_path $BINDIR)"
160       export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BINDIR"
161     fi
162   }
163   
164   # load in the build environment.
165   initialize_build_variables
166   
167   ##############
168   
169   # windoze specific patching up missing things.
170   
171   if [ "$OS" == "Windows_NT" ]; then
172     export HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z)
173   fi
174   
175   ##############
176   
177   # pull in the custom overrides for feisty_meow scripts.  this is done last,
178   # because we want to set everything up as expected, then let the user
179   # override individual variables and definitions.
180   for i in $FEISTY_MEOW_GENERATED/custom/*.sh; do
181     if [ ! -f "$i" ]; then
182       # skip it if it's not real.
183       continue;
184     fi
185     if [ ! -z "$SHELL_DEBUG" ]; then
186       echo "loading customization: $(basename $(dirname $i))/$(basename $i)"
187     fi
188     source $i
189   done
190   
191   ##############
192   
193   # set the path for locating applications.  this is done after any
194   # potential overrides from the user.
195   #export PATH="$(dos_to_msys_path $BINDIR):$(dos_to_msys_path $FEISTY_MEOW_GENERATED):$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:."
196   export PATH="$FEISTY_MEOW_GENERATED:$PATH:/sbin:."
197 ###noise! :/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:.
198   
199   ##############
200   
201   if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi
202
203 fi
204