forked from simos/bashrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc_config
executable file
·81 lines (73 loc) · 2.2 KB
/
bashrc_config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
#
# bashrc_config configuration script by Simos Xenitellis <[email protected]>.
#
SOURCE="/usr/share/bashrc"
ETCSKEL="/etc/skel"
USER=n
SYSTEM=n
VERBOSE=
usage()
{
echo "usage: $0 [-v|--verbose] [[-u|--user] | [-s|--system]] [-h|--help]" >&2
echo " -v --verbose be verbose" >&2
echo " -u --user installation for the current user" >&2
echo " -s --system system-wide installation (in /etc/skel)" >&2
echo "" >&2
echo "The system-wide installation populates $ETCSKEL" >&2
echo "and new accounts created will have the bash" >&2
echo "configuration files by default." >&2
echo "" >&2
exit 0
}
while [ $# -gt 0 ] ; do
case $1 in
-u|--user)
USER=y
;;
-s|--system)
SYSTEM=y
;;
-v|--verbose)
VERBOSE=--verbose
;;
-*)
usage
exit 0
;;
*)
break
;;
esac
shift
done
if [ "$USER" = "y" -a "$SYSTEM" = "y" ] ; then
echo "Please choose either a user or system-wide installation." >&2
exit 1
fi
if [ "$USER" = "y" ] ; then
echo -n "Copying files from ${SOURCE} to ${HOME}..." >&2
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc ${HOME}/.bashrc
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.bindkey ${HOME}/.bashrc.bindkey
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.complete ${HOME}/.bashrc.complete
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.set ${HOME}/.bashrc.set
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.alias ${HOME}/.bashrc.alias
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.hosts ${HOME}/.bashrc.hosts
/bin/cp -u ${VERBOSE} ${SOURCE}/bashrc.local ${HOME}/.bashrc.local
echo " done." >&2
exit 0
fi
if [ "$SYSTEM" = "y" ] ; then
echo -n "Copying files from ${SOURCE} to ${ETCSKEL}..." >&2
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc ${ETCSKEL}/.bashrc
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.bindkey ${ETCSKEL}/.bashrc.bindkey
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.complete ${ETCSKEL}/.bashrc.complete
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.set ${ETCSKEL}/.bashrc.set
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.alias ${ETCSKEL}/.bashrc.alias
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.hosts ${ETCSKEL}/.bashrc.hosts
/bin/cp -f ${VERBOSE} ${SOURCE}/bashrc.local ${ETCSKEL}/.bashrc.local
echo " done." >&2
exit 0
fi
usage
exit 0