simplified sudo function
[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
55 # make toast out of generated files right away, but leave any custom scripts.
56 \rm -f "$FEISTY_MEOW_LOADING_DOCK"/fmc_*
57
58 ## #no, old:
59 ## if [ ! -d "$FEISTY_MEOW_LOADING_DOCK/custom" ]; then
60 ##   mkdir "$FEISTY_MEOW_LOADING_DOCK/custom"
61 ## fi
62
63 # just a variable we use in here to refer to the generated variables file.
64 FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
65 # create the alias file as totally blank.
66 echo -n >"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
67 for i in FEISTY_MEOW_APEX FEISTY_MEOW_SCRIPTS FEISTY_MEOW_LOADING_DOCK; do
68   echo "export $i=${!i}" >>"$FEISTY_MEOW_VARIABLES_LOADING_FILE"
69 done
70
71 # load our variables so we can run our perl scripts successfully.
72 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
73
74 # create our common aliases.  we need to refresh the PERLLIB since the shell
75 # seems to keep accumulating the value in a weird way.
76 PERLLIB=$PERLLIB PERL5LIB=$PERLLIB perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
77 #echo after the generate aliases, perllib is $PERLLIB
78
79 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
80   echo this is the variable config file for feisty_meow assets:
81   echo ==============
82   cat "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
83   echo ==============
84 fi
85
86