dad26d1477cbdd79d404d90ca38673bd1de55e68
[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 examples/feisty_meow_startup/bashrc_user file 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 # repetitive bit stolen from variables.  should make a file out of this somehow.
25 IS_DOS=$(uname | grep -i ming)
26 if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
27 # now if we're stuck in DOS, then fix the feisty meow variable name.
28 if [ ! -z "$IS_DOS" ]; then
29   FEISTY_MEOW_APEX="$(cmd /c chdir | tr A-Z a-z | sed -e 's/\\/\//g')"
30 echo feisty meow dos is: $FEISTY_MEOW_APEX
31   FEISTY_MEOW_APEX="$(dos_to_unix_path "$FEISTY_MEOW_APEX")"
32 echo new feisty meow fixed dir is: $FEISTY_MEOW_APEX
33 fi
34
35 popd &>/dev/null
36
37 export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_APEX/scripts"
38
39 # FEISTY_MEOW_LOADING_DOCK is where the generated files feisty_meow uses are located.
40 export FEISTY_MEOW_LOADING_DOCK="$HOME/.zz_feisty_loading"
41 if [ ! -d "$FEISTY_MEOW_LOADING_DOCK" ]; then
42   mkdir -p "$FEISTY_MEOW_LOADING_DOCK"
43 fi
44 # need to add some paths explicitly until we've bootstrapped ourselves.
45 export PERLLIB=$PERLLIB:"$FEISTY_MEOW_SCRIPTS/files":"$FEISTY_MEOW_SCRIPTS/generator"
46 # make toast out of generated files right away, but leave any custom scripts.
47 find "$FEISTY_MEOW_LOADING_DOCK" -maxdepth 1 -type f -exec perl "$FEISTY_MEOW_SCRIPTS/files/safedel.pl" "{}" ';'
48 # &>/dev/null
49 if [ ! -d "$FEISTY_MEOW_LOADING_DOCK/custom" ]; then
50   mkdir "$FEISTY_MEOW_LOADING_DOCK/custom"
51 fi
52
53 # just a variable we use in here to refer to the generated variables file.
54 FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
55 # create the alias file as totally blank.
56 echo -n >"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
57 for i in FEISTY_MEOW_APEX FEISTY_MEOW_SCRIPTS FEISTY_MEOW_LOADING_DOCK; do
58   echo "export $i=${!i}" >>"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
59 done
60
61 # load our variables so we can run our perl scripts successfully.
62 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
63
64 # create our common aliases.
65 perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
66
67 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
68   echo established these variables for feisty_meow assets:
69   echo ==============
70   cat "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
71   echo ==============
72 fi
73