annotate setup @ 128:66a1d79c4161

Cleaned up unused functions.
author Edho Prima Arief <edho@myconan.net>
date Thu, 27 Oct 2011 16:29:39 +0700
parents a7484f2c9616
children 70928bbbd6cb fcef92b3f37f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
1 #!/bin/sh
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
2
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
3 basedir="`dirname "${0}"`"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
4 cd "${basedir}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
5 basedir="`pwd`"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
6 rcdir="${basedir}/rc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
7 bindir="${basedir}/bin"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
8
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
9 test -n "${HOME}" || exit 1
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
10
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
11 _echo() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
12 _echon "${*}"; printf "\n"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
13 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
14 _echon() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
15 printf "%s" "${*}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
16 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
17
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
18 _tcsh() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
19 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
20 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
21 _rc "${1}" "tcsh" ".ecos_tcsh"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
22 _init "${1}" '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
23 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
24 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
25 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
26
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
27 _bash() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
28 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
29 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
30 _rc "${1}" "bash" ".ecos_bash"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
31 _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bash_profile"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
32 _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bashrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
33 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
34 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
35 }
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
36
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
37 _zsh() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
38 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
39 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
40 _rc "${1}" "zsh" ".ecos_zsh"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
41 _init "${1}" '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' ".zshrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
42 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
43 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
44 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
45
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
46 _rc() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
47 _srcfile="${rcdir}/${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
48 _dstfile="${HOME}/${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
49 if test ! -h "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
50 if test -f "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
51 cp "${_dstfile}" "${_dstfile}.bak"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
52 elif test -d "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
53 cp -r "${_dstfile}" "${_dstfile}.bak"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
54 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
55 _echo "${_dstfile} backed up to ${_dstfile}.bak"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
56 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
57 rm -f "${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
58 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
59 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
60 ln -fs "${_srcfile}" "${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
61 _echo "Installed ${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
62 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
63 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
64 _echo "Removed ${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
65 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
66 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
67 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
68
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
69 _init() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
70 _script="${HOME}/${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
71 _scripttmp="${HOME}/.tmp.${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
72 _data="${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
73 if [ -f "${_script}" ]; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
74 grep -v "${_data}" "${_script}" > "${_scripttmp}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
75 mv -f "${_scripttmp}" "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
76 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
77 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
78 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
79 _echo "${_data}" >> "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
80 _echo "Added autostart to ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
81 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
82 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
83 _echo "Removed autostart from ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
84 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
85 esac
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
86 }
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
87
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
88 _help() {
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
89 cat <<EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
90 Usage: ${0} [install|uninstall]
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
91 EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
92 }
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
93
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
94 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
95 install|uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
96 for i in tcsh bash zsh; do
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
97 _"${i}" "${1}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
98 done
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
99 _rc "${1}" "tmux" ".tmux.conf"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
100 _rc "${1}" "hg" ".hgrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
101 _rc "${1}" "vim" ".vimrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
102 _rc "${1}" "inputrc" ".inputrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
103 _rc "${1}" "bin" ".ecos_bin"
26
175848778e77 Added initial upgrade support.
Edho Prima Arief <me@myconan.net>
parents: 23
diff changeset
104 ;;
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
105 *)
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
106 _help
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
107 ;;
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
108 esac