]> arthur.barton.de Git - ConfigScripts.git/blobdiff - install.sh
Install user/bash_profile as $HOME/.profile, if this file exists
[ConfigScripts.git] / install.sh
index 62e695efa6c56f22ce4dc64395ee34b6ed2edbcc..2453855bd191972b82d305a8fe10e5e177cff493 100755 (executable)
@@ -14,10 +14,12 @@ Abort() {
 Copy_File() {
        src="$1"; dst="$2"; own="$3"; perm="$4"
        echo "     $src -> $dst\c"
-       grep "alex@barton.de" "$dst" >/dev/null 2>&1
-       if [ $? -ne 0 ]; then
-               echo " (B)\c"
-               cp "$dst" "$dst.bak"
+       if [ -e "$dst" ]; then
+               grep "alex@barton.de" "$dst" >/dev/null 2>&1
+               if [ $? -ne 0 ]; then
+                       echo " (B)\c"
+                       cp "$dst" "$dst.bak"
+               fi
        fi
        echo " \c"
        cp "$src" "$dst" || Abort
@@ -26,9 +28,12 @@ Copy_File() {
        echo "- OK."
 }
 
-echo "Running $NAME ..."
+[ -n "$UID" ] || UID=`id -u`
+export UID
 
-if [ "$UID" -eq 0 ]; then
+echo "Running $NAME (uid=$UID) ..."
+
+if [ "$UID" = "0" ]; then
        echo "Starting system configuration:"
        echo " - bash shell:"
        if [ -e /etc/bash.bashrc ]; then
@@ -44,7 +49,11 @@ fi
 user=`basename "$HOME"`
 echo "Starting user configuration ($user in $HOME):"
 echo " - bash shell:"
-Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600
+if [ -e "$HOME/.profile" ]; then
+       Copy_File user/bash_profile "$HOME/.profile" "$user" 600
+else
+       Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600
+fi
 Copy_File user/bashrc "$HOME/.bashrc" "$user" 600
 Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600