From aeb367f5cbeb755a0c6ebd87c3598eac2e13c75b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 28 Jun 2015 14:53:39 +0200 Subject: Add hostname in tagname --- nix-script-switch.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'nix-script-switch.sh') diff --git a/nix-script-switch.sh b/nix-script-switch.sh index 6cf585d..ad540bc 100755 --- a/nix-script-switch.sh +++ b/nix-script-switch.sh @@ -14,6 +14,7 @@ usage() { -c Command for nixos-rebuild. See 'man nixos-rebuild' -g Alternative git commit, defaults to 'tag -a' -w Path to your configuration git directory + -n Include hostname in tag name -h Show this help and exit Everything after a double dash (--) will be passed to nixos-rebuild as @@ -30,8 +31,9 @@ ARGS= WD= TAG_NAME= GIT_COMMAND= +HOSTNAME="" -while getopts "c:w:t:h" OPTION +while getopts "c:w:t:nh" OPTION do case $OPTION in c) @@ -52,6 +54,11 @@ do stdout "GIT_COMMAND = $GIT_COMMAND" ;; + n) + HOSTNAME=$(hostname) + stdout "HOSTNAME = $HOSTNAME" + ;; + h) usage exit 1 @@ -96,7 +103,12 @@ then if [[ -z "$TAG_NAME" ]] then - TAG_NAME="nixos-$LASTGEN-$COMMAND" + if [[ -z "$HOSTNAME" ]] + then + TAG_NAME="nixos-$LASTGEN-$COMMAND" + else + TAG_NAME="nixos-$HOSTNAME-$LASTGEN-$COMMAND" + fi fi explain git --git-dir="$WD/.git" --work-tree="$WD" $GIT_COMMAND "$TAG_NAME" -- cgit v1.2.3