#!/bin/sh
#
# execsys-binfmt: test1
#
# chkconfig: 2345 2 98
# description: test2
#
### BEGIN INIT INFO
# Provides:          execsys-binfmt
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Should-Start:      $local_fs
# Should-Stop:       $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start scripts.mit.edu execsys system
# Description:       Decides what interpreter to use to execute files
### END INIT INFO

stop ()
{
    echo "-1" > /proc/sys/fs/binfmt_misc/status
    umount /proc/sys/fs/binfmt_misc
}

start ()
{
    mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
    cat > /proc/sys/fs/binfmt_misc/register <<REGISTER
:pl:E::pl::/usr/bin/perl:
:php:E::php::/usr/bin/php-cgi:
:py:E::py::/usr/bin/python:
:exe:E::exe::/usr/bin/mono:
REGISTER
}

case "$1" in
start)
    stop 2>/dev/null || :
    start
    ;;
stop)
    stop
    ;;
force-reload)
    stop
    start
    ;;
restart)
    stop
    start
    ;;
*)
    echo "Usage: $0 [start|stop|restart|force-reload]" >&2
    exit 2
    ;;
esac

exit $?
