setup_user.sh 895 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Add environment settings to user's
  3. # .bashrc
  4. # .bash_profile
  5. # Add a .pvmrc
  6. . `dirname $0`/user.bash_profile
  7. echo "Configuring user account $USER for sbsv2 in: $SBS_HOME"
  8. if [ ! -d "$SBS_HOME" ]; then
  9. echo "SBS_HOME appears to not be set correctly: $SBS_HOME" 1>&2
  10. exit 1
  11. fi
  12. patchfile()
  13. {
  14. echo "Adding '$2' to $1"
  15. grep -q '# SBS_SETTINGS' "$1"
  16. if [ $? -eq 0 ]; then
  17. sed "s%.* # SBS_SETTINGS (do not edit this line).*%$2 # SBS_SETTINGS (do not edit this line)%" "$1" > "$1.sbsv2" &&
  18. mv "$1" "$1.orig" &&
  19. mv "$1.sbsv2" "$1"
  20. else
  21. cp "$1" "$1.orig" &&
  22. echo "$2 # SBS_SETTINGS (do not edit this line)" >> "$1"
  23. fi
  24. }
  25. # Patch the bash profile
  26. patchfile ~/.bash_profile ". $SBS_HOME/bin/user.bash_profile"
  27. patchfile ~/.bashrc ". $SBS_HOME/bin/user.bashrc"
  28. if [ -f ~/.pvmrc ]; then
  29. cp ~/.pvmrc ~/.pvmrc.orig
  30. fi
  31. cp $SBS_HOME/util/install-linux/linux_pvmrc ~/.pvmrc