6 # Defines the environment variables used by the personalized unix
8 # Author: Chris Koeritz
12 #hmmm: moved from functions.sh; does that hose everything up?
14 # defines a variable within the feisty meow environment and remembers that
15 # this is a new or modified definition. if the feisty meow codebase is
16 # unloaded, then so are all the variables that were defined.
17 # this function always exports the variables it defines.
18 function define_yeti_variable()
20 #hmmm: simple implem just sets it up and exports the variable.
21 # i.e., this method always exports.
24 #hmmm: eventual approach-- if variable exists already, save old value for restore,
25 # otherwise save null value for restore,
26 # have to handle unsetting if there was no prior value of one
28 # add variable name to a list of feisty defined variables.
36 # this section should always run or bash will reset them on us.
37 # these need to be as minimal as possible.
39 # sets the main prompt to a simple default, with user@host.
40 define_yeti_variable PS1='\u@\h $ ';
41 # sets the history length and max file size so we can get some long history around here.
42 define_yeti_variable HISTSIZE=1000000
43 define_yeti_variable HISTFILESIZE=8000000
45 # make the TERM available to all sub-shells.
46 define_yeti_variable TERM
50 # we'll run this again only if we think it's needed.
51 if [ -z "$CORE_VARIABLES_LOADED" ]; then
53 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo variables initialization begins...; fi
57 # start with some simpler things.
59 #hmmm: this needs to come from some configuration item. especially for installs.
60 define_yeti_variable DEFAULT_FEISTYMEOW_ORG_DIR=/opt/feistymeow.org
62 define_yeti_variable SCRIPT_SYSTEM=feisty_meow
64 # OS variable records the operating system we think we found.
66 define_yeti_variable OS=UNIX
68 define_yeti_variable IS_DARWIN=$(echo $OSTYPE | grep -i darwin)
72 # guess the current platform.
73 IS_UNIX=$(uname | grep -i linux)
74 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i unix); fi
75 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i darwin); fi
76 IS_DOS=$(uname | grep -i ming)
77 if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
79 # now if we're stuck in DOS, try to determine the type of system.
80 if [ ! -z "$IS_DOS" ]; then
81 # IS_MSYS will be non-empty if this is the msys toolset. otherwise
82 # we assume that it's cygwin.
83 IS_MSYS=$(uname | grep -i ming)
85 # if not MSYS, then we'll assume cygwin and set the cygwin root var.
86 if [ -z "$IS_MSYS" ]; then
87 define_yeti_variable CYGROOT=$(cygpath -w -m /)
93 # fallbacks to set crucial variables for feisty meow...
95 # set the main root directory variable for the feisty meow codebase.
96 # this is only used for extreme failure modes, when the values were not
97 # pulled in from our auto-generated config.
98 if [ -z "$FEISTY_MEOW_APEX" ]; then
99 if [ -d "/opt/feistymeow.org/feisty_meow" ]; then
100 define_yeti_variable FEISTY_MEOW_APEX="/opt/feistymeow.org/feisty_meow"
101 define_yeti_variable FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_APEX/scripts"
102 elif [ -d "$HOME/feisty_meow" ]; then
103 define_yeti_variable FEISTY_MEOW_APEX="$HOME/feisty_meow"
104 define_yeti_variable FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_APEX/scripts"
108 # main declaration of the transients area.
109 if [ -z "$TMP" ]; then
110 define_yeti_variable TMP=$HOME/.tmp
113 # set up the top-level for all build creations and logs and such.
114 if [ -z "$FEISTY_MEOW_GENERATED_STORE" ]; then
115 define_yeti_variable FEISTY_MEOW_GENERATED_STORE="$TMP/generated-feisty_meow"
117 if [ ! -d "$FEISTY_MEOW_GENERATED_STORE" ]; then
118 mkdir -p "$FEISTY_MEOW_GENERATED_STORE"
120 # set up our effluent outsourcing valves.
121 if [ -z "$TEMPORARIES_PILE" ]; then
122 define_yeti_variable TEMPORARIES_PILE="$FEISTY_MEOW_GENERATED_STORE/temporaries"
124 if [ ! -d "$TEMPORARIES_PILE" ]; then
125 mkdir -p "$TEMPORARIES_PILE"
128 # similarly, make sure we have someplace to look for our generated files, if
129 # we were not handed a value.
130 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
131 # The generated scripts directory is where automatically generated files live.
132 # It is separate from the main body of the shell scripts in order to keep things from
134 define_yeti_variable FEISTY_MEOW_LOADING_DOCK=$HOME/.zz_feisty_loading
139 # set up the color_add variable which is a flag that lets ls know colors work.
141 # test if we can use color in ls...
142 ls --help 2>&1 | grep -i -q color
143 if [ $? -eq 0 ]; then
144 export color_add='--color=auto'
152 # umask sets a permission mask for all file creations. we don't set this for the users any
153 # more; they should set it themselves. this is just documentation.
155 # this mask disallows writes by the "group" and disallows all permissions for "others".
157 # this mask disallows writes by "group" and "others".
159 # this mask allows writes by "group" but not by "others".
162 # ulimit sets user limits. we set the maximum allowed core dump file size
163 # to zero, because it is obnoxious to see the core dumps from crashed
164 # programs lying around everywhere.
169 # user variables, sort of... if they haven't given themselves a name yet,
170 # then we will make one up for them.
172 # define a default name, if one wasn't already set.
173 if [ -z "$NAME" ]; then
174 define_yeti_variable NAME='Unset Q. Namington, Fixley Your Name III'
179 # variables for perl.
181 define_yeti_variable PERLLIB+="/usr/lib/perl5"
182 if [ "$OS" == "Windows_NT" ]; then
183 define_yeti_variable PERLIO=:perlio
184 # choose perl's IO over the ms-windows version so we can handle file
188 # iterate across our sub-directories and find the perl scripts.
189 # this currently only looks one level down.
190 for i in $FEISTY_MEOW_SCRIPTS/*; do
192 # check if there is a perl file present; add the folder to PERLLIB if so.
193 ls $i/*.pl &>/dev/null
194 if [ $? -eq 0 ]; then
195 PERLLIB+=":$(dos_to_unix_path $i)"
199 define_yeti_variable PERL5LIB=$PERLLIB
200 #echo PERLLIB is now $PERLLIB
204 # set this so nechung can find its data.
205 define_yeti_variable NECHUNG=$FEISTY_MEOW_APEX/infobase/fortunes.dat
207 ## # establish a pipe for less to see our beloved syntax highlighting.
208 ## define_yeti_variable LESSOPEN="| source-highlight -f esc -o STDOUT -i %s"
210 # the base checkout list is just to update feisty_meow. additional folder
211 # names can be added in your customized scripts. the space at the end of
212 # this variable is important and allows users to extend the list like:
213 # define_yeti_variable REPOSITORY_DIR+="muppets configs"
214 # see the customize/fred folder for a live example.
215 define_yeti_variable REPOSITORY_LIST="$FEISTY_MEOW_APEX "
217 # add in any active projects to the repository list.
218 if [ -d "$HOME/active" ]; then
219 REPOSITORY_LIST+="$(find "$HOME/active" -maxdepth 1 -mindepth 1 -type d) "
221 # add in any site avenger applications that are in the apps folder.
222 if [ -d "$HOME/apps" ]; then
223 # first, simple projects.
224 REPOSITORY_LIST+="$(find "$HOME/apps" -iname "avenger5" -type d) "
225 # then, site avenger specific projects.
226 REPOSITORY_LIST+="$(find "$HOME/apps" -maxdepth 2 -mindepth 2 -iname "avenger5" -type d) "
229 # the archive list is a set of directories that are major repositories of
230 # data which can be synched to backup drives.
231 define_yeti_variable MAJOR_ARCHIVE_SOURCES=
232 # the source collections list is a set of directories that indicate they
233 # harbor a lot of source code underneath.
234 define_yeti_variable SOURCECODE_HIERARCHY_LIST=
236 # initializes the feisty meow build variables, if possible.
237 function initialize_build_variables()
240 # we need to know the feisty meow directory, or we bail.
241 if [ -z "$FEISTY_MEOW_APEX" ]; then return; fi
242 # pick from our expected generator folder, but make sure it's there...
243 buildvars="$FEISTY_MEOW_SCRIPTS/generator/build_variables.sh"
244 if [ -f "$buildvars" ]; then
245 # yep, that one looks good, so pull in the build defs.
246 source "$buildvars" "$buildvars"
249 # now augment the environment if we found our build variables.
250 if [ $found_build_vars == 1 ]; then
251 # the binary directory contains our collection of handy programs.
252 define_yeti_variable FEISTY_MEOW_BINARIES=$TARGETS_STORE
253 # add binaries created within build to the path.
254 define_yeti_variable PATH="$(dos_to_unix_path $FEISTY_MEOW_BINARIES):$PATH"
255 # Shared libraries are located via this variable.
256 define_yeti_variable LD_LIBRARY_PATH="$(dos_to_unix_path $LD_LIBRARY_PATH):$(dos_to_unix_path $FEISTY_MEOW_BINARIES)"
262 # windoze specific patching up missing things.
264 if [ "$OS" == "Windows_NT" ]; then
265 define_yeti_variable HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z)
270 # load in the build environment.
271 initialize_build_variables
275 # add to the PATH variables used for locating applications. this step is taken after any
276 # potential overrides from the user.
277 define_yeti_variable PATH="$(dos_to_unix_path $FEISTY_MEOW_LOADING_DOCK):$PATH:$(find /usr/local/games -maxdepth 1 -type d -exec echo -n {}: ';' 2>/dev/null)/sbin"
281 # set the SHUNIT_PATH so our shunit tests can find the codebase.
282 define_yeti_variable SHUNIT_PATH="$FEISTY_MEOW_SCRIPTS/shunit"
286 define_yeti_variable CORE_VARIABLES_LOADED=true
288 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo variables initialization ends....; fi
293 # pull in the custom overrides for feisty_meow scripts. this is done almost
294 # last, because we want to set everything up as expected, then let the user
295 # override individual variables and definitions. we also don't guard this
296 # to avoid running it again, because we don't know what mix of functions and
297 # aliases they want to define in there.
298 for i in $FEISTY_MEOW_LOADING_DOCK/custom/*.sh; do
299 if [ ! -f "$i" ]; then
300 # skip it if it's not real.
303 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
304 echo "loading customization: $(basename $(dirname $i))/$(basename $i)"
311 # a late breaking action is to set the editor, if we can.
312 # we will fallback to whatever we can find on the host.
314 if [ ! -z "$DISPLAY" ]; then
315 # only try to add bluefish, a gui editor, if there is an X display for it.
316 if [ -z "$EDITOR" ]; then
317 EDITOR="$(which bluefish)"
320 if [ -z "$EDITOR" ]; then
321 EDITOR="$(which gvim)"
322 if [ ! -z "$EDITOR" ]; then
323 # if we found gvim, then add in the no forking flag.
327 if [ -z "$EDITOR" ]; then
328 EDITOR="$(which vim)"
330 if [ -z "$EDITOR" ]; then
334 # out of ideas about editors at this point.
336 # set the VISUAL variable from EDITOR if we found an editor to use.
337 if [ ! -z "$EDITOR" ]; then