annotate setup @ 142:6a43fa890c93

Rename autodetection.
author Edho Arief <edho@myconan.net>
date Wed, 02 Nov 2011 23:07:37 +0700
parents 6a110770a756
children 719b0687d974
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() {
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
47 if test -z "${3}" || test -z "${2}" || test -z "${1}"; then
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
48 _echo "Invalid command."
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
49 return
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
50 fi
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
51 _srcfile="${rcdir}/${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
52 _dstfile="${HOME}/${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
53 if test ! -h "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
54 if test -f "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
55 cp "${_dstfile}" "${_dstfile}.bak"
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
56 _echo "${_dstfile} backed up to ${_dstfile}.bak"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
57 elif test -d "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
58 cp -r "${_dstfile}" "${_dstfile}.bak"
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
59 _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
60 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
61 fi
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
62 rm -rf "${_dstfile}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
63 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
64 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
65 ln -fs "${_srcfile}" "${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
66 _echo "Installed ${_dstfile}"
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 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
69 _echo "Removed ${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
70 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
71 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
72 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
73
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
74 _init() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
75 _script="${HOME}/${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
76 _scripttmp="${HOME}/.tmp.${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
77 _data="${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
78 if [ -f "${_script}" ]; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
79 grep -v "${_data}" "${_script}" > "${_scripttmp}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
80 mv -f "${_scripttmp}" "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
81 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
82 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
83 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
84 _echo "${_data}" >> "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
85 _echo "Added autostart to ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
86 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
87 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
88 _echo "Removed autostart from ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
89 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
90 esac
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
91 }
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
92
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
93 _help() {
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
94 cat <<EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
95 Usage: ${0} [install|uninstall]
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
96 EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
97 }
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
98
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
99 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
100 install|uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
101 for i in tcsh bash zsh; do
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
102 _"${i}" "${1}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
103 done
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
104 _rc "${1}" "tmux" ".tmux.conf"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
105 _rc "${1}" "hg" ".hgrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
106 _rc "${1}" "vim" ".vimrc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
107 _rc "${1}" "inputrc" ".inputrc"
130
70928bbbd6cb Whoops, forgot that bin is outside rc directory.
Edho Prima Arief <edho@myconan.net>
parents: 128
diff changeset
108 _rc "${1}" "../bin" ".ecos_bin"
26
175848778e77 Added initial upgrade support.
Edho Prima Arief <me@myconan.net>
parents: 23
diff changeset
109 ;;
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
110 *)
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
111 _help
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
112 ;;
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
113 esac