changeset 1:ddd721f10cb8

Unified installer/uninstaller.
author Edho Prima Arief <me@myconan.net>
date Sat, 10 Jul 2010 12:11:03 +0000
parents cd87be0968d9
children 1c563df145fa
files install setup uninstall
diffstat 3 files changed, 39 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/install	Sat Jul 10 11:57:25 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-scripts="tcsh vim tmux"
-
-case "$1" in
-  tcsh)
-    SCRIPT_SOURCE="tcsh"
-    SCRIPT_DEST=".tcsh_init"
-    grep -v '#ECCORE_TCSH' "${HOME}/.cshrc" > .cleancshrc
-    echo '[ -r "${HOME}/.tcsh_init" ] && source "${HOME}/.tcsh_init" #ECCORE_TCSH' >> .cleancshrc
-    mv .cleancshrc "${HOME}/.cshrc"
-  ;;
-  tmux)
-    SCRIPT_SOURCE="tmux"
-    SCRIPT_DEST=".tmux.conf"
-  ;;
-  hg)
-    SCRIPT_SOURCE="hg"
-    SCRIPT_DEST=".hgrc"
-esac
-
-ln -s "${PWD}/${SCRIPT_SOURCE}" "${HOME}/${SCRIPT_DEST}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup	Sat Jul 10 12:11:03 2010 +0000
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+install() {
+  #create symlinks
+  linker "tcsh" ".tcsh_init"
+  linker "tmux" ".tmux.conf"
+  linker "hg" ".hgrc"
+
+  #modify cshrc
+  uninstall_tcsh
+  echo '[ -r "${HOME}/.tcsh_init" ] && source "${HOME}/.tcsh_init" #ECCORE_TCSH' >> "${HOME}/.cshrc"
+}
+
+linker() {
+  ln -fs "${PWD}/${1}" "${HOME}/${2}"
+}
+
+uninstall_tcsh() {
+  if [ -e "${HOME}/.cshrc" ]; then
+    grep -v '#ECCORE_TCSH' "${HOME}/.cshrc" > .cleancshrc
+    mv .cleancshrc "${HOME}/.cshrc"
+  fi
+}
+
+uninstall() {
+  for i in .tcsh_init .tmux_conf .hgrc; do
+    [ -e "${HOME}/${i}" ] && rm -f "${HOME}/${i}"
+  done
+  uninstall_tcsh
+}
+
+case "$1" in
+  install)
+    install
+  ;;
+  uninstall)
+    uninstall
+  ;;
+esac
--- a/uninstall	Sat Jul 10 11:57:25 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-echo "Removing: ${1}"
-echo "Press any key to continue"
-read _
-
-case "$1" in
-  tcsh)
-    for i in init exec.before exec.after; do
-      [ -e "${HOME}/.tcsh_${i}" ] && rm "${HOME}/.tcsh_${i}"
-    done
-    grep -v "#ECCORE_TCSH" "${HOME}/.cshrc" > .newcshrc
-    mv .newcshrc "${HOME}/.cshrc"
-  ;;
-  tmux)
-    SCRIPT_NAME=".tmux.conf"
-  ;;
-  hg)
-    SCRIPT_NAME=".hgrc"
-  ;;
-esac
-[ -n "${SCRIPT_NAME}" ] && rm -f "${HOME}/${SCRIPT_NAME}"