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 -p "$src" "$dst" || Abort
30 if [ -n "$own" ]; then
31 chown "$own" "$dst" || Abort
33 if [ -n "$perm" ]; then
34 chmod "$perm" "$dst" || Abort
40 if [ "$UID" = "0" -a -z "$I_local" ]; then
41 Msg "Starting system configuration:\n"
42 Msg " - bash shell:\n"
43 if [ -e /etc/bash.bashrc ]; then
44 Copy_File sys/bashrc /etc/bash.bashrc root:0 644
46 Copy_File sys/bashrc /etc/bashrc root:0 644
48 Copy_File sys/profile /etc/profile root:0 644
50 Msg "Not running with root privileges - system configuration SKIPPED.\n"
51 grep "alex@barton.de" /etc/profile >/dev/null 2>&1
52 if [ $? -ne 0 -o -n "$I_local" -o -d $HOME/.etc ]; then
53 Msg "Installing system files to $HOME/.etc/ ...\n"
55 Msg " - bash shell:\n"
56 Copy_File sys/bashrc $HOME/.etc/bashrc "$user" 600
57 Copy_File sys/profile $HOME/.etc/profile "$user" 600
59 Msg "System configuration seems to be modified: not installing locally.\n"
71 Msg "Starting user configuration ($user in $home):\n"
72 touch "$home/.test.$$" >/dev/null 2>&1
74 rm -f "$home/.test.$$"
75 Msg " - bash shell:\n"
76 if [ -e "$home/.profile" ]; then
77 Copy_File user/bash_profile "$home/.profile" "$user" 600
79 Copy_File user/bash_profile "$home/.bash_profile" "$user" 600
81 Copy_File user/bashrc "$home/.bashrc" "$user" 600
82 Copy_File user/bash_logout "$home/.bash_logout" "$user" 600
84 Msg "Can't write to user home directory - user configuration SKIPPED.\n"
89 if [ -w /etc/skel -a -z "$I_local" ]; then
90 Msg "Starting \"/etc/skel\" configuration:\n"
91 Msg " - bash shell:\n"
92 Copy_File user/bash_logout /etc/skel/.bash_logout root:0 644
93 if [ -e /etc/skel/.profile ]; then
94 Copy_File user/bash_profile /etc/skel/.profile root:0 644
96 Copy_File user/bash_profile /etc/skel/.bash_profile root:0 644
98 Copy_File user/bashrc /etc/skel/.bashrc root:0 644
101 && Msg "Can't write to \"/etc/skel\" - configuration SKIPPED.\n" \
102 || Msg "Local install selected, \"/etc/skel\" configuration SKIPPED.\n"
106 while [ $# -gt 0 ]; do
111 echo "Usage: $0 [--local|-l]"
117 [ -n "$UID" ] || UID=`id -u`
120 Msg "Running $NAME (uid=$UID) ...\n"
122 user=`basename "$HOME"`
126 Config_User "$user" "$HOME"