4 # binfmt-detector: Microsoft PE executable type detector.
6 # chkconfig: 2345 95 05
8 # description: Microsoft PE executable type detector. User can run \
9 # programs using Wine or Mono simply by clicking on them \
10 # or typing ./file.exe
13 # Source function library
14 . /etc/rc.d/init.d/functions
16 # disabled because: seems the mountpoint is namespaced, i.e not visible outside upstart process
17 #upstart_controlled --except status
19 BINFMT_DIR=/proc/sys/fs/binfmt_misc
21 [ -d $BINFMT_DIR ] || exit 0
24 if [ -f /var/lock/subsys/binfmt-detector ]; then
25 msg_already_running "binfmt detector"
29 # check if binfmt_misc is not already mounted
30 if ! grep -q ${BINFMT_DIR} /proc/mounts; then
31 /bin/mount none -t binfmt_misc ${BINFMT_DIR}
33 msg_starting "binfmt detector"
34 if [ -e "$BINFMT_DIR/register" ]; then
35 echo ':windows:M::MZ::/usr/bin/binfmt-detector:' > ${BINFMT_DIR}/register
36 echo ':windowsPE:M::PE::/usr/bin/binfmt-detector:' > ${BINFMT_DIR}/register
38 touch /var/lock/subsys/binfmt-detector
45 if [ ! -f /var/lock/subsys/binfmt-detector ]; then
46 msg_not_running "binfmt detector"
50 msg_stopping "binfmt detector"
51 echo '-1' > ${BINFMT_DIR}/windows
52 echo '-1' > ${BINFMT_DIR}/windowsPE
53 rm -f /var/lock/subsys/binfmt-detector
58 if [ ! -f /var/lock/subsys/binfmt-detector ]; then
59 msg_not_running "binfmt-detector"
87 if [ ! -f /var/lock/subsys/binfmt-detector ]; then
88 msg_not_running "binfmt detector"
91 for fmt in windows windowsPE; do
92 printf "%s: %s; %s: %s\n" $fmt \
93 $(grep -E '(disabled|enabled)' $BINFMT_DIR/$fmt) \
94 $(grep -E 'interpreter' $BINFMT_DIR/$fmt)
98 msg_usage "$0 {start|stop|restart|reload|try-restart|force-reload|status}"