X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=install.sh;h=7473e97a3836cf97fc3159df5b7b89d9e02efdc2;hb=fb307ee3b9f8ef9d10572862681deb4fd2538559;hp=877058beb19d507b8763729c5063d86afbcb9a23;hpb=adb60776f147e5d77d32909f55aace5b147514e2;p=ConfigScripts.git diff --git a/install.sh b/install.sh index 877058b..7473e97 100755 --- a/install.sh +++ b/install.sh @@ -26,8 +26,8 @@ Copy_File() { fi fi Msg " " - cp "$src" "$dst" || Abort - if [ -n "$own" -a "$own" != "$USER" ]; then + cp -p "$src" "$dst" || Abort + if [ -n "$own" ]; then chown "$own" "$dst" || Abort fi if [ -n "$perm" ]; then @@ -41,17 +41,18 @@ Config_System() { Msg "Starting system configuration:\n" Msg " - bash shell:\n" if [ -e /etc/bash.bashrc ]; then - Copy_File sys/bashrc /etc/bash.bashrc root 644 + Copy_File sys/bashrc /etc/bash.bashrc root:0 644 else - Copy_File sys/bashrc /etc/bashrc root 644 + Copy_File sys/bashrc /etc/bashrc root:0 644 fi - Copy_File sys/profile /etc/profile root 644 + Copy_File sys/profile /etc/profile root:0 644 else Msg "Not running with root privileges - system configuration SKIPPED.\n" grep "alex@barton.de" /etc/profile >/dev/null 2>&1 - if [ $? -ne 0 -o -n "$I_local" ]; then + if [ $? -ne 0 -o -n "$I_local" -o -d $HOME/.etc ]; then Msg "Installing system files to $HOME/.etc/ ...\n" mkdir -p "$HOME/.etc" + Msg " - bash shell:\n" Copy_File sys/bashrc $HOME/.etc/bashrc "$user" 600 Copy_File sys/profile $HOME/.etc/profile "$user" 600 else @@ -85,27 +86,20 @@ Config_User() { } Config_Skel() { - if [ -w /etc/skel ]; then + if [ -w /etc/skel -a -z "$I_local" ]; then Msg "Starting \"/etc/skel\" configuration:\n" - Copy_File user/bash_logout /etc/skel/.bash_logout + Msg " - bash shell:\n" + Copy_File user/bash_logout /etc/skel/.bash_logout root:0 644 if [ -e /etc/skel/.profile ]; then - Copy_File user/bash_profile /etc/skel/.profile root 644 + Copy_File user/bash_profile /etc/skel/.profile root:0 644 else - Copy_File user/bash_profile /etc/skel/.bash_profile root 644 + Copy_File user/bash_profile /etc/skel/.bash_profile root:0 644 fi - Copy_File user/bashrc /etc/skel/.bashrc root 644 + Copy_File user/bashrc /etc/skel/.bashrc root:0 644 else - Msg "Can't write to \"/etc/skel\" - configuration SKIPPED.\n" - fi -} - -Config_RootUser() { - if [ "$UID" = "0" ]; then - user=`grep "^.*:.*:0:" /etc/passwd | head -n 1 | cut -d':' -f1` - home=`grep "^.*:.*:0:" /etc/passwd | cut -d':' -f6` - Config_User "$user" "$home" - else - Msg "Not running with root privileges - root user configuration SKIPPED.\n" + [ -z "$I_local" ] \ + && Msg "Can't write to \"/etc/skel\" - configuration SKIPPED.\n" \ + || Msg "Local install selected, \"/etc/skel\" configuration SKIPPED.\n" fi } @@ -127,10 +121,9 @@ Msg "Running $NAME (uid=$UID) ...\n" user=`basename "$HOME"` -Config_System Config_Skel +Config_System Config_User "$user" "$HOME" -Config_RootUser Msg "$NAME: Done.\n"