]> arthur.barton.de Git - ConfigScripts.git/blob - install.sh
Initial import into GIT repository.
[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         grep "alex@barton.de" "$dst" >/dev/null 2>&1
18         if [ $? -ne 0 ]; then
19                 echo " (B)\c"
20                 cp "$dst" "$dst.bak"
21         fi
22         echo " \c"
23         cp "$src" "$dst" || Abort
24         [ -n "$own" ] && chown "$own" "$dst" || Abort
25         [ -n "$perm" ] && chmod "$perm" "$dst" || Abort
26         echo "- OK."
27 }
28
29 echo "Running $NAME ..."
30
31 if [ "$UID" -eq 0 ]; then
32         echo "Starting system configuration:"
33         echo " - bash shell:"
34         if [ -e /etc/bash.bashrc ]; then
35                 Copy_File sys/bashrc /etc/bash.bashrc root 644
36         else
37                 Copy_File sys/bashrc /etc/bashrc root 644
38         fi
39         Copy_File sys/profile /etc/profile root 644
40 else
41         echo "Not running with root privileges - system configuration SKIPPED."
42 fi
43
44 user=`basename "$HOME"`
45 echo "Starting user configuration ($user in $HOME):"
46 echo " - bash shell:"
47 Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600
48 Copy_File user/bashrc "$HOME/.bashrc" "$user" 600
49 Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600
50
51 echo "$NAME: Done."
52
53 # -eof-