From 3f63cedd709cb6266eb3c345101a78ac09a55f82 Mon Sep 17 00:00:00 2001
From: Yoann Guilhem <yoann.guilhem@esrf.fr>
Date: Fri, 8 Jun 2012 09:37:13 +0000
Subject: [PATCH] Fix DCTuser_setup.sh: - create ~/.subversion directory in
 case of first use of SVN - add the line in .bashrc to source bashrc_private
 (for new ESRF users, this line is not present)

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@479 4c865b51-4357-4376-afb4-474e03ccb993
---
 DCTuser_setup.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/DCTuser_setup.sh b/DCTuser_setup.sh
index 870f2e53..7b59c84a 100755
--- a/DCTuser_setup.sh
+++ b/DCTuser_setup.sh
@@ -5,6 +5,7 @@ DCT_DIR="${HOME}/matlabDCT"
 CURRENT_DIR=`pwd`
 
 # get a good version of .subversion/servers
+mkdir -p ${HOME}/.subversion
 echo "Setup SVN servers..."
 echo "http-proxy-host = proxy.esrf.fr
 http-proxy-port = 3128
@@ -14,6 +15,18 @@ store-plaintext-passwords = no" >> ${HOME}/.subversion/servers
 echo "Checkout code from Sourceforge, in directory \"${DCT_DIR}\"..."
 svn co https://dct.svn.sourceforge.net/svnroot/dct/trunk ${DCT_DIR}
 
+# check if .bashrc_private is sourced by .bashrc, if not, add it
+if ! grep -qE '^\s*[^#].+\. ~/.bashrc_private' ~/.bashrc ; then
+  echo "Adding line in in .bashrc file to source .bashrc_private file"
+  if [ -w ~/.bashrc ] ; then
+    echo -e '\n[ -f ~/.bashrc_private ] && . ~/.bashrc_private' >> ~/.bashrc
+  else
+    echo "The .bashrc file is not writable, so adding writable bit before!"
+    chmod +w ~/.bashrc
+    echo -e '\n[ -f ~/.bashrc_private ] && . ~/.bashrc_private' >> ~/.bashrc
+    chmod -w ~/.bashrc
+  fi
+fi
 # append to .bashrc_private
 echo "Appending to your .bashrc_private file..."
 echo "
-- 
GitLab