Mercurial > ec-dotfiles
annotate setup @ 438:1094159210e0
Added p7zip.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Sun, 06 Jan 2013 13:28:05 +0300 |
parents | 7394b88bf1c6 |
children | e0f9a54b9dce |
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 |
404 | 3 # This script is bourne-shell compatible. |
4 # Or at least it is when I last tested it in Solaris 10. | |
5 | |
6 # Ensure no variable is empty when used. | |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
7 set -u |
404 | 8 # Stop on any error. |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
9 set -e |
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
10 |
404 | 11 # Get directory where this script and dotfiles are located. |
12 # $0 contains either full path when executed from a PATH (godwhy) | |
13 # or with complete path or ./<scriptname> when executed that way. | |
14 # Therefore it's safe to use dirname in this case. | |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
15 basedir="`dirname "${0}"`" |
404 | 16 |
17 # To get actual path, go to the directory and pwd from it. | |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
18 cd "${basedir}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
19 basedir="`pwd`" |
404 | 20 |
21 # FIXME: test existence of the directories. | |
22 # dotfiles | |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
23 rcdir="${basedir}/rc" |
404 | 24 # misc scripts |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
25 bindir="${basedir}/bin" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
26 |
404 | 27 # Make sure $HOME points somewhere. |
28 # FIXME: ensure it is writable (or maybe not). | |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
29 test -n "${HOME}" || exit 1 |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
30 |
404 | 31 # A safe echo. |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
32 _echo() { |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
33 _echon "${*}"; printf "\n" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
34 } |
404 | 35 # A safe and cross platform echo -n. |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
36 _echon() { |
338 | 37 printf '%s' "${*}" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
38 } |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
39 |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
40 _tcsh() { |
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) |
332 | 43 _rc "${1}" "cshrc" ".ecos_tcsh" |
246
4eeccee282b1
Much more portable. Tested on Solaris (bourne shell yay).
Edho Arief <edho@myconan.net>
parents:
143
diff
changeset
|
44 _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
|
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 _bash() { |
338 | 50 case "${1}" in |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
51 uninstall|install) |
332 | 52 _rc "${1}" "bashrc" ".ecos_bash" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
53 _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
|
54 _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
|
55 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
56 esac |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
57 } |
1
ddd721f10cb8
Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
58 |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
59 _zsh() { |
338 | 60 case "${1}" in |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
61 uninstall|install) |
332 | 62 _rc "${1}" "zshrc" ".ecos_zsh" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
63 _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
|
64 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
65 esac |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
66 } |
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 _rc() { |
135
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
69 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
|
70 _echo "Invalid command." |
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
71 return |
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
72 fi |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
73 _srcfile="${rcdir}/${2}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
74 _dstfile="${HOME}/${3}" |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
75 _dstdir="`_echo "${_dstfile}" | sed -e 's,^\(.*\)/[^/]*$,\1,'`" |
315
c6ad8279b076
Support for solarized vim color scheme.
Edho Arief <edho@myconan.net>
parents:
246
diff
changeset
|
76 mkdir -p "${_dstdir}" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
77 if test ! -h "${_dstfile}"; then |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
78 if test -f "${_dstfile}"; then |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
79 cp "${_dstfile}" "${_dstfile}.bak" |
135
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
80 _echo "${_dstfile} backed up to ${_dstfile}.bak" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
81 elif test -d "${_dstfile}"; then |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
82 cp -r "${_dstfile}" "${_dstfile}.bak" |
135
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
83 _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
84 fi |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
85 fi |
135
6a110770a756
A bit more sanity testing.
Edho Prima Arief <edho@myconan.net>
parents:
130
diff
changeset
|
86 rm -rf "${_dstfile}" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
87 case "${1}" in |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
88 install) |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
89 ln -fs "${_srcfile}" "${_dstfile}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
90 _echo "Installed ${_dstfile}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
91 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
92 uninstall) |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
93 _echo "Removed ${_dstfile}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
94 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
95 esac |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
96 } |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
97 |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
98 _init() { |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
99 _script="${HOME}/${3}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
100 _scripttmp="${HOME}/.tmp.${3}" |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
101 rm -f "${_scripttmp}" |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
102 _data="${2}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
103 if [ -f "${_script}" ]; then |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
104 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
|
105 mv -f "${_scripttmp}" "${_script}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
106 fi |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
107 case "${1}" in |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
108 install) |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
109 _echo "${_data}" >> "${_script}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
110 _echo "Added autostart to ${_script}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
111 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
112 uninstall) |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
113 _echo "Removed autostart from ${_script}" |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
114 ;; |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
115 esac |
1
ddd721f10cb8
Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
116 } |
ddd721f10cb8
Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
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 cat <<EOF |
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
120 Usage: ${0} [install|uninstall] |
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
121 EOF |
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
122 } |
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
123 |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
124 case "${1}" in |
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
125 install|uninstall) |
325
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
126 _tcsh "${1}" |
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
127 _bash "${1}" |
795ad57794a6
[setup] Returning solaris compatibility.
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
128 _zsh "${1}" |
417 | 129 _rc "${1}" "../bin" ".ecos_bin" |
130 _rc "${1}" "gemrc" ".gemrc" | |
356 | 131 _rc "${1}" "gitconfig" ".gitconfig" |
332 | 132 _rc "${1}" "hgrc" ".hgrc" |
417 | 133 _rc "${1}" "inputrc" ".inputrc" |
134 _rc "${1}" "tmux.conf" ".tmux.conf" | |
315
c6ad8279b076
Support for solarized vim color scheme.
Edho Arief <edho@myconan.net>
parents:
246
diff
changeset
|
135 _rc "${1}" "vim-solarized" ".vim/colors/solarized.vim" |
410
fd0a889066a6
Added syntax highlight for coffeescript.
Edho Arief <edho@myconan.net>
parents:
404
diff
changeset
|
136 _rc "${1}" "vim-syntax-coffee" ".vim/syntax/coffee.vim" |
417 | 137 _rc "${1}" "vim-syntax-scss" ".vim/syntax/scss.vim" |
425 | 138 _rc "${1}" "vim-autoload-pathogen" ".vim/autoload/pathogen.vim" |
417 | 139 _rc "${1}" "vimrc" ".vimrc" |
26
175848778e77
Added initial upgrade support.
Edho Prima Arief <me@myconan.net>
parents:
23
diff
changeset
|
140 ;; |
23
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
141 *) |
127
a7484f2c9616
Long-overdue massive reorganization.
Edho Prima Arief <edho@myconan.net>
parents:
126
diff
changeset
|
142 _help |
23
738a2da8b79c
Added usage information for setup script.
Edho Prima Arief <me@myconan.net>
parents:
17
diff
changeset
|
143 ;; |
1
ddd721f10cb8
Unified installer/uninstaller.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
144 esac |
246
4eeccee282b1
Much more portable. Tested on Solaris (bourne shell yay).
Edho Arief <edho@myconan.net>
parents:
143
diff
changeset
|
145 |