]> arthur.barton.de Git - ConfigScripts.git/blob - install.sh
6804f0bfae4f0740d0684cb6ce61f2eb911cc394
[ConfigScripts.git] / install.sh
1 #!/bin/sh
2 #
3 # ConfigScripts - install.sh
4 # Written by Alexander Barton <alex@barton.de>. Public Domain.
5 #
6
7 NAME=`basename "$0"`
8
9 Abort() {
10         echo "- ERROR!"
11         exit 1
12 }
13
14 Copy_File() {
15         src="$1"; dst="$2"; own="$3"; perm="$4"
16         echo "     $src -> $dst\c"
17         if [ -e "$dst" ]; then
18                 grep "alex@barton.de" "$dst" >/dev/null 2>&1
19                 if [ $? -ne 0 ]; then
20                         echo " (B)\c"
21                         cp "$dst" "$dst.bak"
22                 fi
23         fi
24         echo " \c"
25         cp "$src" "$dst" || Abort
26         [ -n "$own" ] && chown "$own" "$dst" || Abort
27         [ -n "$perm" ] && chmod "$perm" "$dst" || Abort
28         echo "- OK."
29 }
30
31 echo "Running $NAME ..."
32
33 if [ "$UID" -eq 0 ]; then
34         echo "Starting system configuration:"
35         echo " - bash shell:"
36         if [ -e /etc/bash.bashrc ]; then
37                 Copy_File sys/bashrc /etc/bash.bashrc root 644
38         else
39                 Copy_File sys/bashrc /etc/bashrc root 644
40         fi
41         Copy_File sys/profile /etc/profile root 644
42 else
43         echo "Not running with root privileges - system configuration SKIPPED."
44 fi
45
46 user=`basename "$HOME"`
47 echo "Starting user configuration ($user in $HOME):"
48 echo " - bash shell:"
49 Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600
50 Copy_File user/bashrc "$HOME/.bashrc" "$user" 600
51 Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600
52
53 echo "$NAME: Done."
54
55 # -eof-