#!/bin/sh
##########VRP Syncer .1 Beta#########################
# Copyright Shane R. Nay (shane@agendacomputing.com)
# License terms under the GPL
# This program basically checks the sync folder for
# new .vrp packages, and installs them locally or
# remotely via vrpinstall.  It will sync the remote PDA
# via rsync if it's running remotely.  Also the consist
# files are made so the package can be uninstalled, or
# rebuilt in the future.  (ala hotsync to other PDA's)

VRP_CONF=${VRP_CONF:=/etc/vrp.conf}
VRP_SYNC_INTERNAL="true"

if [ ! -f ${VRP_CONF} ]; then
    echo Your VRP Configuration file could not be found. $VRP_CONF
    exit 1
fi
source $VRP_CONF

if [ ${VRP_INSTALLTYPE} = "remote" ]; then
    rsync -r $VRP_DEV::$VRP_MOUNT/ $VRP_OUTPUT
fi

for i in $VRP_INPUT/*vrp ; do
    VRP_PACKAGE=$i
    echo doing install for package: $VRP_PACKAGE
    if [ -f $VRP_PACKAGE ]; then
	source ${VRP_LOC}/vrpinst
    fi
done

if [ ${VRP_INSTALLTYPE} = "remote" ]; then
    rsync -r $VRP_OUTPUT $VRP_DEV::$VRP_MOUNT
fi

exit 0
