diff options
| author | Anton Bobov <abobov@gmail.com> | 2013-11-14 11:09:47 +0600 |
|---|---|---|
| committer | Anton Bobov <abobov@gmail.com> | 2013-11-14 18:29:23 +0600 |
| commit | c10e0e31a4233e82ba83504c145d746b206435cd (patch) | |
| tree | 7058d1bb45a045275c81caf4ea9539e7e9dae784 /install.sh | |
| parent | afca4ae1cf0d071fcce2068223a5becef9be6a28 (diff) | |
Rewrite install file.
Added check before link creating (can be forced with -f option). After
creating links script build all path and resources.
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..affdf12 --- /dev/null +++ b/install.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set -e +dir="$(cd "$(dirname "$0")" && pwd)" +os=$(uname --operating-system) +CMD=$SYSTEMROOT/System32/cmd.exe + +filter() { + fname="files/$(basename "$@")" + if [[ "$fname" == "files/." || "$fname" == "files/.." ]] ; then + return 0 + fi + return 1 +} + +create_windows_link() { + fp=$1 + tp=$2 + opt="" + if [ -d "$fp" ] ; then + opt="/D" + fi + if [[ 1 = $OVERRIDE ]] ; then + rm --recursive --force "$tp" + else + rm --force "$tp" + fi + $CMD /c mklink $opt $(cygpath --windows "$tp") $(cygpath --windows "$fp") >/dev/null +} + +create_link() { + while read fp tp ; do + case "$os" in + "Cygwin") create_windows_link "$fp" "$tp" ;; + *) ln --symbolic --force --no-target-directory "$fp" "$tp" ;; + esac + done +} + +after_install() { + mkdir -p $HOME/tmp/vim-undo $HOME/tmp/vim-backup + mkdir -p $HOME/.mutt/cache + touch $HOME/.mutt/aliases + if ! which ctags >/dev/null 2>&1; then + echo 'No ctags.' >&2 + fi + cd $HOME/.vim/bundle/Command-T/ruby/command-t && make >/dev/null +} + +check_override() { + while read filename ; do + fp=$dir/files/$filename + tp=$HOME/$filename + if [[ 1 != $OVERRIDE ]] ; then + rp=$(readlink -f "$tp") + if [[ -e "$rp" && "$rp" != "$fp" ]] ; then + echo "Skip: $filename" >&2 + continue + fi + fi + echo "$fp" "$tp" + done +} + +if [[ "-f" = "$1" ]] ; then + OVERRIDE=1 +fi + +cd && \ + ( ls --format=single-column --almost-all "$dir/files" | check_override | create_link ) && \ + after_install |
