#!/bin/sh
#------------------------------------------------------------------
#
# Marlin startup script
#
# Usage:
#   marlin_sia start :
#       Called at bootup to detect load and start all
#       marlin related drivers and applications.
#   marlin_sia stop  :
#       Called at runtime or before shutdown/reboot to clean up marlin
#       related resource.
#
# Sep 2019 Zhigang Jin
#
# Copyright (c) 2019 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------
#set -x

. modulefunc.sh

case "$1" in
  start)
    if [ -f /lib/modules/at24.ko ]; then
        modload /lib/modules/at24.ko && modrm /lib/modules/at24.ko
    fi
    if [ -f /lib/modules/marlin_driver.ko ]; then
        modload /lib/modules/marlin_driver.ko
    fi
    if [ -f /lib/modules/marlin_device.ko ]; then
        modload /lib/modules/marlin_device.ko
    fi
    ;;
  stop)
    rmmod marlin_device
    rmmod marlin_driver
    rmmod at24
    ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

exit 0
