#!/bin/sh
# Rsync minimal changes directly to live image

. $(dirname $0)/package-build.inc.sh

HOST=$1
SLICE=${2:-''}

if [ -z "$1" ]; then
  echo "Usage $0: <host> [<p1|p2>]"
  echo ""
  echo "By default update the next available slice"
  exit 128
fi
  
# Find object directory 
IMG=${OBJDIR}/_.disk.image

if [ ! -r "${IMG}" ]; then
  p_err Source ${IMG} does not exists
  exit 1
fi

echo "# Going to deploy $IMG to $HOST (slice:$SLICE)"
ssh $HOST mount || exit 1
cat $IMG | ssh $HOST /tools/update$SLICE || exit 1

exit 0
