28faa8b
#!/bin/sh
28faa8b
#
28faa8b
# wine	Allow users to run Windows(tm) applications by just clicking on them
28faa8b
#	(or typing ./file.exe)
28faa8b
#
28faa8b
# chkconfig: 35 98 10
28faa8b
# description: Allow users to run Windows(tm) applications by just clicking \
28faa8b
#	       on them (or typing ./file.exe)
d25867b
### BEGIN INIT INFO
d25867b
# Default-Start:  2 3 4 5
d25867b
# Default-Stop: 0 1 6
d25867b
# Short-Description: start and stop wine binary handler
d25867b
# Description: Allow users to run Windows(tm) applications by just clicking
d25867b
#              on them (or typing ./file.exe)
d25867b
### END INIT INFO
d25867b
28faa8b
28faa8b
. /etc/rc.d/init.d/functions
28faa8b
RETVAL=0
28faa8b
28faa8b
start() {
f8764d0
# fix bug on changing runlevels #213230
f8764d0
	if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
f8764d0
	    echo -n $"Binary handler for Windows applications already registered"
f8764d0
	else	
d25867b
	    echo -n $"Registering binary handler for Windows applications: "
f8764d0
	    /sbin/modprobe binfmt_misc &>/dev/null
f8764d0
	    echo ':windows:M::MZ::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
f8764d0
	    echo ':windowsPE:M::PE::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
d25867b
	    RETVAL=$?
d25867b
	    [ $RETVAL -eq 0 ] && success || failure
f8764d0
	fi
d25867b
	echo
28faa8b
}
28faa8b
28faa8b
stop() {
d25867b
	echo -n $"Unregistering binary handler for Windows applications: "
28faa8b
	echo "-1" >/proc/sys/fs/binfmt_misc/windows || :
28faa8b
	echo "-1" >/proc/sys/fs/binfmt_misc/windowsPE || :
d25867b
	RETVAL=$?
d25867b
	[ $RETVAL -eq 0 ] && success || failure
d25867b
	echo
28faa8b
}
28faa8b
28faa8b
wine_status() {
28faa8b
	if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
28faa8b
		echo $"Wine binary format handlers are registered."
28faa8b
		return 0
28faa8b
	else
28faa8b
		echo $"Wine binary format handlers are not registered."
28faa8b
		return 3
28faa8b
	fi
28faa8b
}
28faa8b
28faa8b
case "$1" in
28faa8b
	start)
28faa8b
		start
28faa8b
		;;
28faa8b
	stop)
28faa8b
		stop
28faa8b
		;;
28faa8b
	status)
28faa8b
		wine_status
28faa8b
		RETVAL=$?
28faa8b
		;;
28faa8b
	restart)
28faa8b
		stop
28faa8b
		start
28faa8b
		;;
d25867b
	condrestart|try-restart)
d25867b
	
28faa8b
		if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
28faa8b
			stop
28faa8b
			start
28faa8b
		fi
28faa8b
		;;
28faa8b
	*)
d25867b
		echo $"Usage: $prog {start|stop|status|restart|try-restart}"
28faa8b
		exit 1
28faa8b
esac
28faa8b
exit $RETVAL
28faa8b