annotate setup @ 325:795ad57794a6

[setup] Returning solaris compatibility.
author Edho Arief <edho@myconan.net>
date Sun, 18 Mar 2012 16:02:08 +0700
parents c6ad8279b076
children db66d53e10ea
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
325
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
3 set -u
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
4 set -e
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
5
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
6 basedir="`dirname "${0}"`"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
7 cd "${basedir}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
8 basedir="`pwd`"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
9 rcdir="${basedir}/rc"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
10 bindir="${basedir}/bin"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
11
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
12 test -n "${HOME}" || exit 1
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 _echo() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
15 _echon "${*}"; printf "\n"
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 _echon() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
18 printf "%s" "${*}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
19 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
20
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
21 _tcsh() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
22 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
23 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
24 _rc "${1}" "tcsh" ".ecos_tcsh"
246
4eeccee282b1 Much more portable. Tested on Solaris (bourne shell yay).
Edho Arief <edho@myconan.net>
parents: 143
diff changeset
25 _init "${1}" 'test -r "${HOME}/.ecos_tcsh" && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
127
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 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
28 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
29
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
30 _bash() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
31 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
32 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
33 _rc "${1}" "bash" ".ecos_bash"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
34 _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
35 _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
36 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
37 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
38 }
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
39
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
40 _zsh() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
41 case "$1" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
42 uninstall|install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
43 _rc "${1}" "zsh" ".ecos_zsh"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
44 _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
45 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
46 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
47 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
48
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
49 _rc() {
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
50 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
51 _echo "Invalid command."
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
52 return
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
53 fi
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
54 _srcfile="${rcdir}/${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
55 _dstfile="${HOME}/${3}"
325
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
56 _dstdir="`_echo "${_dstfile}" | sed -e 's,^\(.*\)/[^/]*$,\1,'`"
315
c6ad8279b076 Support for solarized vim color scheme.
Edho Arief <edho@myconan.net>
parents: 246
diff changeset
57 mkdir -p "${_dstdir}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
58 if test ! -h "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
59 if test -f "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
60 cp "${_dstfile}" "${_dstfile}.bak"
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
61 _echo "${_dstfile} backed up to ${_dstfile}.bak"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
62 elif test -d "${_dstfile}"; then
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
63 cp -r "${_dstfile}" "${_dstfile}.bak"
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
64 _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
65 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
66 fi
135
6a110770a756 A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents: 130
diff changeset
67 rm -rf "${_dstfile}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
68 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
69 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
70 ln -fs "${_srcfile}" "${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
71 _echo "Installed ${_dstfile}"
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 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
74 _echo "Removed ${_dstfile}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
75 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
76 esac
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
77 }
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
78
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
79 _init() {
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
80 _script="${HOME}/${3}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
81 _scripttmp="${HOME}/.tmp.${3}"
325
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
82 rm -f "${_scripttmp}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
83 _data="${2}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
84 if [ -f "${_script}" ]; then
325
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
85 sed -e "/`_echo "${_data}" | sed -e 's/.*#//'`/d" "${_script}" > "${_scripttmp}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
86 mv -f "${_scripttmp}" "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
87 fi
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
88 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
89 install)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
90 _echo "${_data}" >> "${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
91 _echo "Added autostart to ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
92 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
93 uninstall)
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
94 _echo "Removed autostart from ${_script}"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
95 ;;
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
96 esac
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
97 }
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
98
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
99 _help() {
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
100 cat <<EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
101 Usage: ${0} [install|uninstall]
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
102 EOF
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
103 }
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
104
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
105 case "${1}" in
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
106 install|uninstall)
325
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
107 _tcsh "${1}"
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
108 _bash "${1}"
795ad57794a6 [setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents: 315
diff changeset
109 _zsh "${1}"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
110 _rc "${1}" "tmux" ".tmux.conf"
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
111 _rc "${1}" "hg" ".hgrc"
315
c6ad8279b076 Support for solarized vim color scheme.
Edho Arief <edho@myconan.net>
parents: 246
diff changeset
112 _rc "${1}" "vimrc" ".vimrc"
c6ad8279b076 Support for solarized vim color scheme.
Edho Arief <edho@myconan.net>
parents: 246
diff changeset
113 _rc "${1}" "vim-solarized" ".vim/colors/solarized.vim"
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
114 _rc "${1}" "inputrc" ".inputrc"
130
70928bbbd6cb Whoops, forgot that bin is outside rc directory.
Edho Prima Arief <edho@myconan.net>
parents: 128
diff changeset
115 _rc "${1}" "../bin" ".ecos_bin"
26
175848778e77 Added initial upgrade support.
Edho Prima Arief <me@myconan.net>
parents: 23
diff changeset
116 ;;
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
117 *)
127
a7484f2c9616 Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents: 126
diff changeset
118 _help
23
738a2da8b79c Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents: 17
diff changeset
119 ;;
1
ddd721f10cb8 Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
120 esac
246
4eeccee282b1 Much more portable. Tested on Solaris (bourne shell yay).
Edho Arief <edho@myconan.net>
parents: 143
diff changeset
121