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)
28faa8b
28faa8b
. /etc/rc.d/init.d/functions
28faa8b
RETVAL=0
28faa8b
28faa8b
start() {
28faa8b
	echo -n $"Registering binary handler for Windows applications"
28faa8b
	/sbin/modprobe binfmt_misc &>/dev/null
28faa8b
	echo ':windows:M::MZ::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
28faa8b
	echo ':windowsPE:M::PE::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
28faa8b
}
28faa8b
28faa8b
stop() {
28faa8b
	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 || :
28faa8b
}
28faa8b
28faa8b
reload() {
28faa8b
	stop
28faa8b
	start
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
		;;
28faa8b
	condrestart)
28faa8b
		if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
28faa8b
			stop
28faa8b
			start
28faa8b
		fi
28faa8b
		;;
28faa8b
	*)
28faa8b
		echo $"Usage: $prog {start|stop|status|restart|condrestart}"
28faa8b
		exit 1
28faa8b
esac
28faa8b
exit $RETVAL
28faa8b