OSDN Git Service

For LINUX: .bashrc and .bash_profile v2.3.31p0232
authorEos <eos@localhost.localdomain>
Sun, 29 Nov 2015 19:37:17 +0000 (04:37 +0900)
committerEos <eos@localhost.localdomain>
Sun, 29 Nov 2015 19:37:17 +0000 (04:37 +0900)
modified:   env/install-eos.sh
new file:   env/template.bashrc
modified:   env/update-eos.sh

env/install-eos.sh
env/template.bashrc [new file with mode: 0644]
env/update-eos.sh

index 1d78afa..75ade64 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#RCRC!/bin/bash
 #### 
 WD=`pwd`
 
@@ -113,6 +113,8 @@ esac
 
 unset FLAG_BASHPROFILE 
 echo -n "Do you want to rewrite $HOME/.bash_prfile ? [Y|y or N|n] " ; read FLAG_BASHPROFILE 
+unset FLAG_BASHRC
+echo -n "Do you want to rewrite $HOME/.bashrc ? [Y|y or N|n] " ; read FLAG_BASHRC
 
 
 #### No Change
@@ -215,7 +217,10 @@ case $FLAG_BASHPROFILE in
                awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bash_profile > $HOME/.bash_profile.org
 
                cat $HOME/.bash_profile.org > $HOME/.bash_profile
-               cat >> $HOME/.bash_profile << EOF
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat $EOS_HOME/env/template.bashrc >>  $HOME/.bash_profile
+               else 
+                       cat >> $HOME/.bash_profile << EOF
 ## Eos_env Start
 ##
 
@@ -233,6 +238,49 @@ test -r $HOME/.Eos_env  && . $HOME/.Eos_env
 ##
 ## Eos_env End
 EOF
+               fi
+               echo "Please check $HOME/.bash_profile."
+               ;;
+
+       *)
+               echo "Before you use Eos, "
+               echo 'source $EOS_HOME0/env/Eos_env'
+               echo "  or " 
+               echo "You should rewrite $HOME/.bash_profile by yourself to execute $EOS_HOME0/env/Eos_env."
+               ;;
+esac
+
+#
+# .bashrc
+#
+
+case $FLAG_BASHRC in 
+       Y|y)
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bashrc > $HOME/.bashrc.org
+
+               cat $HOME/.bashrc.org > $HOME/.bashrc
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat  $EOS_HOME/env/template.bashrc >> $HOME/.bashrc
+               else 
+                       cat >> $HOME/.bashrc << EOF
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+       fi
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End
+EOF
+               fi
                echo "Please check $HOME/.bash_profile."
                ;;
 
diff --git a/env/template.bashrc b/env/template.bashrc
new file mode 100644 (file)
index 0000000..f5c1934
--- /dev/null
@@ -0,0 +1,16 @@
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+    if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+        ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+    fi  
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End 
index d902533..ac371d6 100755 (executable)
@@ -32,6 +32,9 @@ if [ -z $EOS_HOME0 ] ; then
        echo "      or   "
        echo -n "Set EOS_HOME0 [$EOS_HOME] :" 
        read EOS_HOME0
+       if [ -z $EOS_HOME0 ] ; then
+               export EOS_HOME0=$EOS_HOME
+       fi 
 fi
 
 if [ -z $EOS_GITUSER0 ] ; then
@@ -63,8 +66,9 @@ case $ANS in
 esac
 
 unset FLAG_BASHPROFILE 
-echo -n "Do you want to modify .bash_profile automatically ? [ Y|y or N|n ] : "
-read FLAG_BASHPROFILE 
+echo -n "Do you want to modify .bash_profile automatically ? [ Y|y or N|n ] : "; read FLAG_BASHPROFILE 
+unset FLAG_BASHRC
+echo -n "Do you want to modify .bashrc automatically ? [ Y|y or N|n ] : "; read FLAG_BASHRC
 
 #
 # Start updating
@@ -143,7 +147,49 @@ case $FLAG_BASHPROFILE in
        Y|y) 
                awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bash_profile > $HOME/.bash_profile.org
                cat $HOME/.bash_profile.org > $HOME/.bash_profile
-               cat >> $HOME/.bash_profile << EOF 
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat $EOS_HOME/env/template.bashrc >> $HOME/.bash_profile
+               else
+                       cat >> $HOME/.bash_profile << EOF 
+
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+    if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+        ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+    fi  
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End 
+EOF
+               fi
+               ;;
+       *)
+               echo "Please set your preferable environment as you like."
+               echo "Or"
+               echo "$ source $EOS_HOME/env/Eos_env"
+               ;;
+esac
+
+
+#
+#
+
+case $FLAG_BASHRC in 
+       Y|y) 
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bashrc > $HOME/.bashrc.org
+               cat $HOME/.bashrc.org > $HOME/.bashrc
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat $EOS_HOME/env/template.bashrc >> $HOME/.bashrc
+               else
+                       cat >> $HOME/.bashrc << EOF 
 ## Eos_env Start
 ##
 
@@ -161,6 +207,7 @@ test -r $HOME/.Eos_env  && . $HOME/.Eos_env
 ##
 ## Eos_env End 
 EOF
+               fi      
                ;;
        *)
                echo "Please set your preferable environment as you like."