wine.init 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. #
  3. # wine Allow users to run Windows(tm) applications by just clicking on them
  4. # (or typing ./file.exe)
  5. #
  6. # chkconfig: 35 98 10
  7. # description: Allow users to run Windows(tm) applications by just clicking \
  8. # on them (or typing ./file.exe)
  9. ### BEGIN INIT INFO
  10. # Provides: wine-binfmt
  11. # Required-Start:
  12. # Required-Stop:
  13. # Default-Start: 2 3 4 5
  14. # Default-Stop: 0 1 6
  15. # Short-Description: Add and remove wine binary handler
  16. # Description: Allow users to run Windows(tm) applications by just clicking
  17. # on them (or typing ./file.exe)
  18. ### END INIT INFO
  19. . /etc/rc.d/init.d/functions
  20. RETVAL=0
  21. start() {
  22. # fix bug on changing runlevels #213230
  23. if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
  24. echo -n $"Binary handler for Windows applications already registered"
  25. else
  26. echo -n $"Registering binary handler for Windows applications: "
  27. /sbin/modprobe binfmt_misc &>/dev/null
  28. echo ':windows:M::MZ::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
  29. echo ':windowsPE:M::PE::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || :
  30. RETVAL=$?
  31. [ $RETVAL -eq 0 ] && success || failure
  32. fi
  33. echo
  34. }
  35. stop() {
  36. echo -n $"Unregistering binary handler for Windows applications: "
  37. echo "-1" >/proc/sys/fs/binfmt_misc/windows || :
  38. echo "-1" >/proc/sys/fs/binfmt_misc/windowsPE || :
  39. RETVAL=$?
  40. [ $RETVAL -eq 0 ] && success || failure
  41. echo
  42. }
  43. wine_status() {
  44. if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
  45. echo $"Wine binary format handlers are registered."
  46. return 0
  47. else
  48. echo $"Wine binary format handlers are not registered."
  49. return 3
  50. fi
  51. }
  52. case "$1" in
  53. start)
  54. start
  55. ;;
  56. stop)
  57. stop
  58. ;;
  59. status)
  60. wine_status
  61. RETVAL=$?
  62. ;;
  63. restart)
  64. stop
  65. start
  66. ;;
  67. reload)
  68. stop
  69. start
  70. ;;
  71. condrestart|try-restart)
  72. if [ -e /proc/sys/fs/binfmt_misc/windows ]; then
  73. stop
  74. start
  75. fi
  76. ;;
  77. *)
  78. echo $"Usage: $prog {start|stop|status|restart|reload|try-restart}"
  79. exit 1
  80. esac
  81. exit $RETVAL