18870: Fix diagnostic
[arvados.git] / tools / salt-install / installer.sh
index 37f1baf20ea5e48e1a21125848bd55620c77abd0..fde261611cfe553375658291779a7a29f4a22b26 100755 (executable)
@@ -6,6 +6,44 @@
 
 set -e
 
+sync() {
+    if test "$NODE" != localhost ; then
+       if ! ssh $NODE test -d arvados-setup ; then
+           ssh $NODE git init --bare arvados-setup.git
+           if ! git remote add $NODE $DEPLOY_USER@$NODE:arvados-setup.git ; then
+               git remote set-url $NODE $DEPLOY_USER@$NODE:arvados-setup.git
+           fi
+           git push $NODE $BRANCH
+           ssh $NODE git clone arvados-setup.git arvados-setup
+       fi
+
+       git push $NODE $BRANCH
+       ssh $NODE git -C arvados-setup checkout $BRANCH
+       ssh $NODE git -C arvados-setup pull
+    fi
+}
+
+deploynode() {
+    if test -z "${NODES[$NODE]}" ; then
+       echo "No roles declared for '$NODE' in local.params"
+       exit 1
+    fi
+
+    if test $NODE = localhost ; then
+       sudo ./provision.sh --config local.params --roles ${NODES[$NODE]}
+    else
+       ssh $DEPLOY_USER@$NODE "cd arvados-setup && sudo ./provision.sh --config local.params --roles ${NODES[$NODE]}"
+    fi
+}
+
+loadconfig() {
+    CONFIG_FILE=local.params
+    if ! test -s $CONFIG_FILE ; then
+       echo "Must be run from arvados-setup, maybe you need to 'initialize' first?"
+    fi
+    source ${CONFIG_FILE}
+}
+
 subcmd="$1"
 if test -n "$subcmd" ; then
     shift
@@ -55,46 +93,50 @@ case "$subcmd" in
        git commit -m"initial commit"
 
        echo "setup directory initialized, now go to $SETUPDIR, edit 'local.params' and 'local_config_dir' as needed, then run 'installer.sh deploy'"
-    ;;
+       ;;
     deploy)
-       CONFIG_FILE=local.params
-       if ! test -s $CONFIG_FILE ; then
-           echo "Must be run from arvados-setup, maybe you need to 'initialize' first?"
-       fi
+       NODE=$1
 
-       source ${CONFIG_FILE}
+       loadconfig
 
        set -x
 
+       BRANCH=$(git branch --show-current)
+
        git add -A
        if ! git diff --cached --exit-code ; then
            git commit -m"prepare for deploy"
        fi
-       for NODE in "${!NODES[@]}"
-       do
-           if test $NODE = localhost ; then
-               sudo ./provision.sh --config local.params --roles ${NODES[$NODE]}
-           else
-               if ! ssh $NODE test -d arvados-setup ; then
-                   ssh $NODE git init --bare arvados-setup.git
-                   if ! git remote add $NODE $DEPLOY_USER@$NODE:arvados-setup.git ; then
-                       git remote set-url $NODE $DEPLOY_USER@$NODE:arvados-setup.git
-                   fi
-                   git push $NODE master
-                   ssh $NODE git clone arvados-setup.git arvados-setup
-               fi
-
-               git push $NODE master
-               ssh $NODE git -C arvados-setup pull
-
-               ssh $DEPLOY_USER@$NODE "cd arvados-setup && sudo ./provision.sh --config local.params --roles ${NODES[$NODE]}"
-           fi
-       done
+
+       if test -z "$NODE"; then
+           for NODE in "${!NODES[@]}"
+           do
+               sync
+               deploynode
+           done
+       else
+           sync
+           deploynode
+       fi
+
+       ;;
+    diagnostics)
+       loadconfig
+
+       if ! which arvados-client ; then
+           apt-get install arvados-client
+       fi
+
+       export ARVADOS_API_HOST="${CLUSTER}.${DOMAIN}"
+       export ARVADOS_API_TOKEN="$SYSTEM_ROOT_TOKEN"
+
+       arvados-client diagnostics -internal-client
        ;;
     *)
        echo "Arvados installer"
        echo ""
        echo "initialize   initialize the setup directory for configuration"
        echo "deploy       deploy the configuration from the setup directory"
+       echo "diagnostics  check your install using diagnostics"
        ;;
 esac