3 # ConfigScripts - install.sh
4 # Written by Alexander Barton <alex@barton.de>. Public Domain.
19 src="$1"; dst="$2"; own="$3"; perm="$4"
21 if [ -e "$dst" ]; then
22 grep "alex@barton.de" "$dst" >/dev/null 2>&1
29 cp "$src" "$dst" || Abort
30 [ -n "$own" ] && chown "$own" "$dst" || Abort
31 [ -n "$perm" ] && chmod "$perm" "$dst" || Abort
35 [ -n "$UID" ] || UID=`id -u`
38 Msg "Running $NAME (uid=$UID) ..."
40 user=`basename "$HOME"`
42 if [ "$UID" = "0" ]; then
43 Msg "Starting system configuration:"
45 if [ -e /etc/bash.bashrc ]; then
46 Copy_File sys/bashrc /etc/bash.bashrc root 644
48 Copy_File sys/bashrc /etc/bashrc root 644
50 Copy_File sys/profile /etc/profile root 644
52 Msg "Not running with root privileges - system configuration SKIPPED."
53 grep "alex@barton.de" /etc/profile >/dev/null 2>&1
55 Msg "Installing system files to $HOME/.etc/ ..."
57 Copy_File sys/bashrc $HOME/.etc/bashrc "$user" 600
58 Copy_File sys/profile $HOME/.etc/profile "$user" 600
60 Msg "System configuration seems to be modified: not installing locally."
64 touch "$HOME/.test.$$" >/dev/null 2>&1
66 rm -f "$HOME/.test.$$"
67 Msg "Starting user configuration ($user in $HOME):"
69 if [ -e "$HOME/.profile" ]; then
70 Copy_File user/bash_profile "$HOME/.profile" "$user" 600
72 Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600
74 Copy_File user/bashrc "$HOME/.bashrc" "$user" 600
75 Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600
77 Msg "Can't write to user home directory - user configuration SKIPPED."