]> git.pld-linux.org Git - packages/binfmt-detector.git/blob - binfmt-detector.init
40661fb2c3dfc389a1683d56bb70d1ccadf49731
[packages/binfmt-detector.git] / binfmt-detector.init
1 #!/bin/sh
2 # $Id$
3 #
4 # binfmt-detector:      Microsoft PE executable type detector.
5 #
6 # chkconfig:    2345 95 05
7 #
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
11 #
12
13 # Source function library
14 . /etc/rc.d/init.d/functions
15
16 # disabled because: seems the mountpoint is namespaced, i.e not visible outside upstart process
17 #upstart_controlled --except status
18
19 BINFMT_DIR=/proc/sys/fs/binfmt_misc
20
21 [ -d $BINFMT_DIR ] || exit 0
22
23 start() {
24         if [ -f /var/lock/subsys/binfmt-detector ]; then
25                 msg_already_running "binfmt detector"
26                 return
27         fi
28
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}
32         fi
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
37                 ok
38                 touch /var/lock/subsys/binfmt-detector
39         else
40                 fail
41         fi
42 }
43
44 stop() {
45         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
46                 msg_not_running "binfmt detector"
47                 return
48         fi
49
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
54         ok
55 }
56
57 condrestart() {
58         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
59                 msg_not_running "binfmt-detector"
60                 RETVAL=$1
61                 return
62         fi
63
64         stop
65         start
66 }
67
68 RETVAL=0
69 case "$1" in
70   start|reload)
71         start
72         ;;
73   stop)
74         stop
75         ;;
76   restart)
77     stop
78     start
79         ;;
80   try-restart)
81         condrestart 0
82         ;;
83   force-reload)
84         condrestart 7
85         ;;
86   status)
87         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
88                 msg_not_running "binfmt detector"
89                 exit 1
90         fi
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)
95         done
96         ;;
97   *)
98         msg_usage "$0 {start|stop|restart|reload|try-restart|force-reload|status}"
99         exit 3
100 esac
101
102 exit $RETVAL
This page took 0.070438 seconds and 2 git commands to generate.