X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=install.sh;h=f42c52e666b71b4f28578d94b84dbb45e7409a2f;hb=3446359c55772523b509586655ee2d178048d3aa;hp=86849bb582b9ce59c4910ffab28177601f787e14;hpb=79e5dc0b431c162f1a44ac8c8d8a5feaea879f24;p=ConfigScripts.git diff --git a/install.sh b/install.sh index 86849bb..f42c52e 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 --preserve=timestamps "$src" "$dst" || Abort + if [ -n "$own" ]; then chown "$own" "$dst" || Abort fi if [ -n "$perm" ]; then @@ -37,7 +37,7 @@ Copy_File() { } Config_System() { - if [ "$UID" = "0" ]; then + if [ "$UID" = "0" -a -z "$I_local" ]; then Msg "Starting system configuration:\n" Msg " - bash shell:\n" if [ -e /etc/bash.bashrc ]; then @@ -49,7 +49,7 @@ Config_System() { else Msg "Not running with root privileges - system configuration SKIPPED.\n" grep "alex@barton.de" /etc/profile >/dev/null 2>&1 - if [ $? -ne 0 ]; 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" Copy_File sys/bashrc $HOME/.etc/bashrc "$user" 600 @@ -84,6 +84,23 @@ Config_User() { fi } +Config_Skel() { + if [ -w /etc/skel -a -z "$I_local" ]; then + Msg "Starting \"/etc/skel\" configuration:\n" + Copy_File user/bash_logout /etc/skel/.bash_logout root 644 + if [ -e /etc/skel/.profile ]; then + Copy_File user/bash_profile /etc/skel/.profile root 644 + else + Copy_File user/bash_profile /etc/skel/.bash_profile root 644 + fi + Copy_File user/bashrc /etc/skel/.bashrc root 644 + else + [ -z "$I_local" ] \ + && Msg "Can't write to \"/etc/skel\" - configuration SKIPPED.\n" \ + || Msg "Local install selected, \"/etc/skel\" configuration SKIPPED.\n" + fi +} + Config_RootUser() { if [ "$UID" = "0" ]; then user=`grep "^.*:.*:0:" /etc/passwd | head -n 1 | cut -d':' -f1` @@ -94,6 +111,17 @@ Config_RootUser() { fi } +while [ $# -gt 0 ]; do + case "$1" in + "--local"|"-l") + export I_local=1; ;; + *) + echo "Usage: $0 [--local|-l]" + exit 1 + esac + shift +done + [ -n "$UID" ] || UID=`id -u` export UID @@ -101,6 +129,7 @@ Msg "Running $NAME (uid=$UID) ...\n" user=`basename "$HOME"` +Config_Skel Config_System Config_User "$user" "$HOME" Config_RootUser