#!/bin/sh
#
# Update the non-active partition, input will stdin if no argument given else a
# listing netcat sesion will be opened at the given port
# Can be used in the following setups:
# 1) Systems with CPU limits (e.g. no encryption and/or  compression):
#   ssh -oBatchMode=yes root@node.example.org /tools/update-wrapper 3333 &
#   cat nanobsd.image | nc node.example.org 3333
# 2) Standard setup:
#   cat nanobsd.image | ssh -oBatchMode=yes root@node.example.org /tools/update-wrapper
#
# Licence: BSD http://wirelessleiden.nl/LICENSE
#
# Rick van der Zwet <info@rickvanderzwet.nl>

. /etc/nanobsd.conf

ROOT=`cd $(dirname $0); pwd -P`

# Find out which partion to use
mount | grep -q ${NANO_DRIVE}s1 && UPDATE=$ROOT/updatep2 || UPDATE=$ROOT/updatep1 

if [ -z $1 ]; then
 $UPDATE
else
 nc -l $1 | $UPDATE
fi
