summaryrefslogtreecommitdiff
path: root/addhost
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2013-09-02 16:01:50 +0200
committerLeif Johansson <leifj@sunet.se>2013-09-02 16:01:50 +0200
commit7515782eb503152dfc3e84fee1260fb10d560df9 (patch)
treece0087dc774a156c6a74f11d3af92ef5686b4972 /addhost
import
Diffstat (limited to 'addhost')
-rwxr-xr-xaddhost45
1 files changed, 45 insertions, 0 deletions
diff --git a/addhost b/addhost
new file mode 100755
index 0000000..7099020
--- /dev/null
+++ b/addhost
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+cmd_hostname=""
+cmd_do_bootstrap="no"
+
+set -- $(getopt b?h? "$@")
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ (-h) echo "Usage: $0 [-h] [-b] [--] [<host>]"; exit 0;;
+ (-b) cmd_do_bootstrap="yes" ;;
+ (--) shift; break;;
+ (-*) echo "Unknown option $1\nUsage: $0 [-b] [-h] [--] <host>"; exit 1;;
+ (*) break;;
+ esac
+ shift
+done
+
+if [ ! -z "$1" -a -z "$cmd_hostname" ]; then
+ cmd_hostname="$1"
+fi
+
+if test -z "$cmd_hostname"; then
+ echo "Usage: $0 [-h] [-b] [--] <host>"
+ exit 1
+fi
+
+test -f cosmos.conf && . ./cosmos.conf
+
+defrepo=`git remote -v | grep ${remote:="ro"} | grep fetch | awk '{print $2}'`
+rrepo=${repo:="$defrepo"}
+
+if [ ! -d $cmd_hostname ]; then
+ cp -pr default $cmd_hostname
+ git add $cmd_hostname
+ git commit -m "$cmd_hostname added" $cmd_hostname
+ ./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 cosmos update
+ ssh root@$cmd_hostname cosmos apply
+fi