Merge branch 'master' of feistymeow.org:feisty_meow
[feisty_meow.git] / scripts / core / connect_feisty_meow.sh
1 #!/bin/bash
2
3 # Author: Chris Koeritz
4
5 # this script adds the feisty inits code to .bashrc, if we think it has not yet been added.
6
7 # auto-locate the feisty meow scripts, since they supposedly are not enabled yet.
8 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
9 # normalize the path we want to cobble together.
10 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
11
12 echo calculated apex as $FEISTY_MEOW_APEX
13
14 do_root="$1"; shift
15
16 if [ -f "$HOME/.bashrc" ] && grep -q "launch_feisty_meow.sh" "$HOME/.bashrc"; then
17   # the stanza for loading feisty meow already seems to be present.
18   echo "Feisty Meow already seems to be configured in '~/.bashrc'."
19 else
20   # check for the --root flag to see if they're trying to get the root version of inits.
21   if [ "$do_root" != "--root" ]; then
22     # stuff the "normal user" init file into .bashrc.  not appropriate for root.
23     # this is the easy and quick start script for most folks.
24     cat $FEISTY_MEOW_APEX/infobase/feisty_inits/dot.bashrc-normal-user |
25       sed -e \
26         "s?FEISTY_MEOW_APEX=\".*\"?FEISTY_MEOW_APEX=\"$FEISTY_MEOW_APEX\"?" \
27         >> "$HOME/.bashrc"
28     echo "Feisty Meow is now configured in '~/.bashrc' for standard users."
29   else
30     # stuff the root user init file into .bashrc.  this one doesn't automatically load
31     # feisty meow.  instead, it provides a fredme macro to load the feisty meow scripts.
32     # fredme comes from the main author being fred t. hamster.  we have since added a
33     # feistyme macro too, to be less personalized...
34     cat $FEISTY_MEOW_APEX/infobase/feisty_inits/dot.bashrc-root |
35       sed -e \
36         "s?FEISTY_MEOW_APEX=\".*\"?FEISTY_MEOW_APEX=\"$FEISTY_MEOW_APEX\"?" \
37         >> "$HOME/.bashrc"
38     echo "Feisty Meow is now configured in '~/.bashrc' for the root user."
39   fi
40 fi
41