5 # Fred Hamster's Feisty Meow Concerns Ltd. Startup Profile.
7 # This file is useful within .profile or other initialization scripts.
9 # Author: Chris Koeritz
13 # DEBUG_FEISTY_MEOW: if this variable is non-empty, then it causes the feisty meow
14 # scripts to print more diagnostic information when they run. not all
15 # scripts support this, but the core ones do.
17 #export DEBUG_FEISTY_MEOW=true
21 # this script cannot handle figuring out where it lives, so approaches that
22 # get the WORKDIR will fail. this is a consequence of this always being used
23 # in bash's 'source' directive, which does not pass the script name as
24 # argument 0. instead, we just check for the bad condition of a malconfigured
25 # script system and try to repair it.
27 # we start out thinking things are good.
28 NO_REPAIRS_NEEDED=true
30 # check if any crucial folder is hosed. we will torch the existing config
31 # to the extent we can.
32 if [ ! -d "$FEISTY_MEOW_APEX" ]; then
34 unset NO_REPAIRS_NEEDED
35 # wipe out the offending variable(s).
36 unset FEISTY_MEOW_SCRIPTS FEISTY_MEOW_APEX
37 # clean out any unfortunate wrongness that may exist in our generated areas.
38 if [ -d "$FEISTY_MEOW_LOADING_DOCK" ]; then \rm -rf "$FEISTY_MEOW_LOADING_DOCK"; fi
39 if [ -d "$FEISTY_MEOW_GENERATED_STORE" ]; then \rm -rf "$FEISTY_MEOW_GENERATED_STORE"; fi
40 # also wipe any values from the variables pointing at generated stuff.
41 unset FEISTY_MEOW_LOADING_DOCK FEISTY_MEOW_GENERATED_STORE
44 The feisty meow configuration is damaged somehow. Please change to the
45 directory where it is stored, e.g.:
47 cd /opt/feistymeow.org/feisty_meow
49 and execute this command:
51 export FEISTY_MEOW_APEX=\"\$(pwd)\"; export FEISTY_MEOW_SCRIPTS=\"\$(pwd)/scripts\"; bash scripts/core/reconfigure_feisty_meow.sh && exec bash -i -c \"source \$(pwd)/core/launch_feisty_meow.sh; bash\"
56 if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
58 # we believe it's safe to run through the rest of this script.
62 # some preconditions we want to establish before loading anything...
64 # make sure that aliases can be used in non-interactive shells.
65 shopt -s expand_aliases
67 # patch the user variable if we were launched by one of our cron jobs.
68 if [ -z "$USER" -a ! -z "$CRONUSER" ]; then
69 export USER="$CRONUSER"
74 export ERROR_OCCURRED=
75 # there have been no errors to start with, at least. we will set this
76 # to non-empty if something bad happens.
78 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
79 # FEISTY_MEOW_LOADING_DOCK is where the generated files are located.
80 # this is our single entry point we can use without knowing any variables
81 # yet in the initialization process.
82 export FEISTY_MEOW_LOADING_DOCK="$HOME/.zz_feisty_loading"
83 #hmmm: the above is kind of a constant. that's not so great.
85 # make sure our main variables are established.
86 FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
87 if [ ! -f "$FEISTY_MEOW_VARIABLES_LOADING_FILE" ]; then
90 The feisty meow scripts need initialization via the bootstrap process. For\n\
91 example, if the feisty meow folder lives in '$DEFAULT_FEISTYMEOW_ORG_DIR', then this\n\
92 command bootstraps feisty meow:\n\
94 bash $example_dir/feisty_meow/scripts/core/reconfigure_feisty_meow.sh\n\
102 if [ -z "$ERROR_OCCURRED" ]; then
104 # pull in our generated variables that are the minimal set we need to find
105 # the rest of our resources.
106 source "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
108 # Set up the temporary directory.
109 source "$FEISTY_MEOW_SCRIPTS/core/create_tempdir.sh"
116 if [ -z "$ERROR_OCCURRED" ]; then
118 # load the larger body of standard feisty meow variables into the environment.
119 # we actually want this to always run also; it will decide what variables need
121 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
125 # include helpful functions. we do this every time rather than making it part
126 # of variable initialization, because functions cannot be exported to
127 # sub-shells in bash.
128 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
130 # load some helper methods for the terminal which we'll use below.
131 source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
135 # check hash table before searching path.
137 # don't check path for sourced files.
139 # ignore duplicate lines.
140 HISTCONTROL=ignoredups
141 # append to the history file.
143 # automatically update window size if needed.
144 shopt -s checkwinsize
148 # make history writes immediate to avoid losing history if bash is zapped.
149 echo $PROMPT_COMMAND | grep -q history
150 if [ $? -ne 0 ]; then
151 # we only change the prompt command if we think it hasn't already been done.
152 export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
157 # perform the bulkier parts of the initialization process.
159 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo "heavyweight init begins..."; fi
161 # set up the aliases for the shell, but only if they are not already set.
162 type CORE_ALIASES_LOADED &>/dev/null
163 if [ $? -ne 0 ]; then
164 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
165 echo "the aliases were missing, now they are being added..."
167 source "$FEISTY_MEOW_LOADING_DOCK/fmc_core_and_custom_aliases.sh"
170 #echo before the new labelling, terminal titles have:
171 #show_terminal_titles
173 # a minor tickle of the title of the terminal, unless we already have some history.
174 label_terminal_with_info
176 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo "heavyweight init is done."; fi
178 if [ -z "$ERROR_OCCURRED" ]; then
179 # set a sentinel variable to say we loaded the feisty meow environment.
180 export FEISTY_MEOW_SCRIPTS_LOADED=true
183 fi # no error occurred.
185 fi # "$NO_REPAIRS_NEEDED" was == "true"