#!/bin/sh

PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin

start()
{
    mount -t tmpfs tmpfs /opt/tmp
}

stop()
{
    umount /opt/tmp
}

tmp_status()
{
    mount | grep /opt/tmp >/dev/null
}

case "$1" in
        start)
                if tmp_status
                then
                        echo /opt/tmp is already mounted
                else
                        start
                fi
                ;;
        stop)
                if tmp_status
                then
                        stop
                else
                        echo /opt/tmp is not mounted
                fi
                ;;
        status)
                if tmp_status
                then
                        echo /opt/tmp is mounted
                else
                        echo /opt/tmp is not mounted
                fi
                ;;

        restart)
                stop
                sleep 1
                start
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|status}"
                ;;
esac
