Merge branch 'release-2.140.109'
[feisty_meow.git] / scripts / core / reconfigure_feisty_meow.sh
1 #!/bin/bash
2 #
3 # reconfigure_feisty_meow:
4 #
5 # This script creates the directory for auto-generated scripts and gets
6 # the current user's account ready to use the feisty meow scripts.
7 #
8 # Note: this does not yet ensure that the profile is executed on shell
9 # startup.  that can be added manually by editing your .bashrc file.
10 # read the files infobase/feisty_inits for more details.
11
12 ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && /bin/pwd )"
13 CORE_SCRIPTS_DIR="$(echo "$ORIGINATING_FOLDER" | tr '\\\\' '/' )"
14 THIS_TOOL_NAME="$(basename "$0")"
15
16 # set up the feisty_meow dir.
17 pushd "$CORE_SCRIPTS_DIR/../.." &>/dev/null
18 source "$CORE_SCRIPTS_DIR/functions.sh"
19
20 #echo originating folder is $ORIGINATING_FOLDER
21 export FEISTY_MEOW_APEX="$(/bin/pwd)"
22 #echo feisty now is FEISTY_MEOW_APEX=$FEISTY_MEOW_APEX
23
24 # make the variables script run again.
25 unset CORE_VARIABLES_LOADED
26
27 # repetitive bit stolen from variables.  should make a file out of this somehow.
28 #IS_DOS=$(uname | grep -i ming)
29 #if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
30 ## now if we're stuck in DOS, then fix the feisty meow variable name.
31 #if [ ! -z "$IS_DOS" ]; then
32 #  FEISTY_MEOW_APEX="$(cmd /c chdir | tr A-Z a-z | sed -e 's/\\/\//g')"
33 #echo feisty meow dos is: $FEISTY_MEOW_APEX
34 #  FEISTY_MEOW_APEX="$(dos_to_unix_path "$FEISTY_MEOW_APEX")"
35 #echo new feisty meow fixed dir is: $FEISTY_MEOW_APEX
36 #fi
37
38 popd &>/dev/null
39
40 export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_APEX/scripts"
41
42 # FEISTY_MEOW_LOADING_DOCK is where the generated files feisty_meow uses are located.
43 export FEISTY_MEOW_LOADING_DOCK="$HOME/.zz_feisty_loading"
44 if [ ! -d "$FEISTY_MEOW_LOADING_DOCK" ]; then
45   mkdir -p "$FEISTY_MEOW_LOADING_DOCK"
46 fi
47 # need to add some paths explicitly until we've bootstrapped ourselves.
48 #hmmm: this is tasty reusable code...
49 export PERLLIB=$(echo $PERLLIB | sed -e "s?\([:]*\)\([^:]*feisty_meow[^:]*\)\([:]*\)??g")
50
51 PERLLIB=$PERLLIB:"$FEISTY_MEOW_SCRIPTS/core":"$FEISTY_MEOW_SCRIPTS/files":"$FEISTY_MEOW_SCRIPTS/generator"
52 PERL5LIB=$PERLLIB
53 #echo PERLLIB after modification is $PERLLIB
54 # make toast out of generated files right away, but leave any custom scripts.
55 find "$FEISTY_MEOW_LOADING_DOCK" -maxdepth 1 -type f -exec perl "$FEISTY_MEOW_SCRIPTS/files/safedel.pl" "{}" ';'
56 # &>/dev/null
57 if [ ! -d "$FEISTY_MEOW_LOADING_DOCK/custom" ]; then
58   mkdir "$FEISTY_MEOW_LOADING_DOCK/custom"
59 fi
60
61 # just a variable we use in here to refer to the generated variables file.
62 FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
63 # create the alias file as totally blank.
64 echo -n >"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
65 for i in FEISTY_MEOW_APEX FEISTY_MEOW_SCRIPTS FEISTY_MEOW_LOADING_DOCK; do
66   echo "export $i=${!i}" >>"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
67 done
68
69 # load our variables so we can run our perl scripts successfully.
70 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
71
72 # create our common aliases.  we need to refresh the PERLLIB since the shell
73 # seems to keep accumulating the value in a weird way.
74 PERLLIB=$PERLLIB PERL5LIB=$PERLLIB perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
75 #echo after the generate aliases, perllib is $PERLLIB
76
77 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
78   echo this is the variable config file for feisty_meow assets:
79   echo ==============
80   cat "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
81   echo ==============
82 fi
83
84