#!/bin/sh

################################################################################
#
# Copyright (C) 2015 Cumulus Networks Inc. All rights reserved
#
################################################################################

# install/remove/query ONIE firmware updates

# This operation requires root privileges
if [ $(id -u) -ne 0 ] ; then
    echo "ERROR: This command requires root privileges"
    exit 1
fi

. /usr/lib/cumulus/onie/onie-tools-common

cl_mount_onie_tools || {
    echo "ERROR: Mounting ONIE tools failed" >&2
    exit 1
}

if [ -x "$onie_tool_dir/onie-fwpkg" ] ; then
    # Use the onie-fwpkg command that comes with the ONIE tools
    # package from the ONIE distribution.
    $onie_tool_dir/onie-fwpkg "$@"
else
    echo "Warning: The current ONIE installation does not support this operation." >&2
fi

cl_umount_onie_tools
