#!/bin/sh
#### INFO
# Provides:             Application drive
# Description:          Mounts the mtd5 ubifs volume
####

#
# Author:               David Dumke
# DateCreated:          March 1, 2010
# LastModified:         December 17, 2010
# Version:              1.1
#

do_start() {
        echo "Attach and mount /nautel."
        ubiattach /dev/ubi_ctrl -m 5 -d 1
        mount -t ubifs ubi1:application /nautel
}

do_stop() {
        echo "Unmount and detach /nautel"
        killall NextGenServer-run
	# Store the baud rates from server.conf for use by the reboot script
	# before we shut down.
        slowBaud=$(cat /nautel/server/server.conf | sed -n "s/^PollingDeviceBaud\s*=\s*\([0-9]*\)/\1/p")
        turboBaud=$(cat /nautel/server/server.conf | sed -n "s/^PollingTurboBaud\s*=\s*\([0-9]*\)/\1/p")
        umount /nautel
        ubidetach /dev/ubi_ctrl -m 5
}

case "$1" in
        start)
                do_start
                ;;
        stop)
                do_stop
                ;;
        restart)
                echo "Remount /nautel"
                do_stop
                do_start
                echo "  done."
                ;;
        *)
                echo "Usage: $SCRIPTNAME {start|stop}" >&2
                exit 3
                ;;
esac

