#!/bin/sh
#
# This script patches files coming from OS-SDK.
# This service will be used till OS-SDK clean up is done
#
# Copyright (c) 2018-2020 by Cisco Systems, Inc.


function PatchFile()
{
    if [ -f $1 ]; then
           echo "First boot: Bkup & create softlink"
           mv $1 $1"_orig"
           ln -s $2 $1
    else
           echo "First boot: create softlink"
           ln -s $2 $1
    fi
}


case "$1" in
start)
        echo "Patching files...."
        PatchFile "/usr/local/etc/functions.platform" "/usr/local/etc/ncs5700/functions.platform"
        PatchFile "/usr/local/etc/functions.pci" "/usr/local/etc/ncs5700/functions.pci"
        PatchFile "/usr/local/etc/setup-fpga.sh" "/usr/local/etc/ncs5700/setup-fpga.sh"
        ;;


stop|force-reload|restart)
        echo "Not supported"
        ;;

*)
        echo "Usage: /usr/local/etc/patch-ossdk-ncs5700 {start|stop}"
        exit 1
        ;;
esac

exit 0
