From 54000987a08f43e33d6c41ef18f0510f6ce7c540 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Thu, 31 Oct 2013 23:26:16 +0100 Subject: new addhost --- addhost | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'addhost') diff --git a/addhost b/addhost index 7099020..033c16b 100755 --- a/addhost +++ b/addhost @@ -2,15 +2,17 @@ cmd_hostname="" cmd_do_bootstrap="no" +cmd_fqdn="" -set -- $(getopt b?h? "$@") +set -- $(getopt b?h?n: "$@") while [ $# -gt 0 ]; do case "$1" in (-h) echo "Usage: $0 [-h] [-b] [--] []"; exit 0;; (-b) cmd_do_bootstrap="yes" ;; + (-n) cmd_fqdn="$2" ; shift ;; (--) shift; break;; - (-*) echo "Unknown option $1\nUsage: $0 [-b] [-h] [--] "; exit 1;; + (-*) echo "Unknown option $1\nUsage: $0 [-b] [-h] [-n fqdn] [--] "; exit 1;; (*) break;; esac shift @@ -20,8 +22,12 @@ if [ ! -z "$1" -a -z "$cmd_hostname" ]; then cmd_hostname="$1" fi +if [ ! -z "$cmd_hostname" -a -z "$cmd_fqdn" ]; then + cmd_fqdn="$cmd_hostname" +fi + if test -z "$cmd_hostname"; then - echo "Usage: $0 [-h] [-b] [--] " + echo "Usage: $0 [-h] [-b] [-n fqdn] [--] " exit 1 fi @@ -29,17 +35,18 @@ test -f cosmos.conf && . ./cosmos.conf defrepo=`git remote -v | grep ${remote:="ro"} | grep fetch | awk '{print $2}'` rrepo=${repo:="$defrepo"} +rtag=${tag:="changeme"} if [ ! -d $cmd_hostname ]; then - cp -pr default $cmd_hostname - git add $cmd_hostname - git commit -m "$cmd_hostname added" $cmd_hostname + cp -pr default $cmd_fqdn + git add $cmd_fqdn + git commit -m "$cmd_fqdn added" $cmd_fqdn ./bump-tag fi if [ "$cmd_do_bootstrap" = "yes" ]; then scp apt/cosmos_1.2-2_all.deb apt/bootstrap-cosmos.sh root@$cmd_hostname: - ssh root@$cmd_hostname ./bootstrap-cosmos.sh $cmd_hostname $rrepo + ssh root@$cmd_hostname ./bootstrap-cosmos.sh $cmd_fqdn $rrepo $rtag ssh root@$cmd_hostname cosmos update ssh root@$cmd_hostname cosmos apply fi -- cgit v1.1