From 8c26bfec32441830b4a0e5938a6cc7de1a64ff99 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Mon, 5 May 2014 11:08:02 +0200 Subject: Add a hostname override Based on issue #82, we now provide `-B` to override the hostname. In particular: - `mkrc -B foo` will enable `-o` but with the hostname set up `foo`. - `lsrc -B foo` will work like normal `lsrc` except it treats `host-foo` as the host-specific directory. - `rcup -B foo` will run a normal `rcup` except `host-foo` is the host-specific directory. - `rcdn -B foo` is just like normal `rcdn`, but with `host-foo` as the host-specific directory. The `HOSTNAME` can also be set in the rcrc(5), and this is overridden by the aforementioned `-B`. While making this change: The `test/Makefile.am` used a mix of tabs and spaces. Since it's a Makefile, replace it all with tabs. --- share/rcm.sh.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'share/rcm.sh.in') diff --git a/share/rcm.sh.in b/share/rcm.sh.in index 809fca3..2ce68d4 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -12,7 +12,6 @@ DEFAULT_DOTFILES_DIR="$HOME/.dotfiles" MKDIR=mkdir INSTALL=rcup ROOT_DIR="$HOME" -HOSTNAME="$(hostname | sed -e 's/\..*//')" ln_v() { $VERBOSE "'$1' -> '$2'" @@ -96,15 +95,16 @@ handle_common_flags() { fi } -handle_metadata_flags() { - local arg_tags="$1" - local dotfiles_dirs="$2" +determine_hostname() { + local name="$1" - : ${TAGS:=$arg_tags} - : ${DOTFILES_DIRS:=$dotfiles_dirs} - - $DEBUG "TAGS: $TAGS" - $DEBUG "DOTFILES_DIRS: $DOTFILES_DIRS" + if [ -n "$name" ]; then + echo "$name" + elif [ -n "$HOSTNAME" ]; then + echo "$HOSTNAME" + else + echo "$(hostname | sed -e 's/\..*//')" + fi } run_hooks() { -- cgit v1.2.3