]> git.pld-linux.org Git - packages/binfmt-detector.git/blob - binfmt-detector.init
- drop upstart support
[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 BINFMT_DIR=/proc/sys/fs/binfmt_misc
17
18 [ -d $BINFMT_DIR ] || exit 0
19
20 start() {
21         if [ -f /var/lock/subsys/binfmt-detector ]; then
22                 msg_already_running "binfmt detector"
23                 return
24         fi
25
26         # check if binfmt_misc is not already mounted
27         if ! grep -q ${BINFMT_DIR} /proc/mounts; then
28                 /bin/mount none -t binfmt_misc ${BINFMT_DIR}
29         fi
30         msg_starting "binfmt detector"
31         if [ -e "$BINFMT_DIR/register" ]; then
32                 echo ':windows:M::MZ::/usr/bin/binfmt-detector:' > ${BINFMT_DIR}/register
33                 echo ':windowsPE:M::PE::/usr/bin/binfmt-detector:' > ${BINFMT_DIR}/register
34                 ok
35                 touch /var/lock/subsys/binfmt-detector
36         else
37                 fail
38         fi
39 }
40
41 stop() {
42         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
43                 msg_not_running "binfmt detector"
44                 return
45         fi
46
47         msg_stopping "binfmt detector"
48         echo '-1' > ${BINFMT_DIR}/windows
49         echo '-1' > ${BINFMT_DIR}/windowsPE
50         rm -f /var/lock/subsys/binfmt-detector
51         ok
52 }
53
54 condrestart() {
55         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
56                 msg_not_running "binfmt-detector"
57                 RETVAL=$1
58                 return
59         fi
60
61         stop
62         start
63 }
64
65 RETVAL=0
66 case "$1" in
67   start|reload)
68         start
69         ;;
70   stop)
71         stop
72         ;;
73   restart)
74     stop
75     start
76         ;;
77   try-restart)
78         condrestart 0
79         ;;
80   force-reload)
81         condrestart 7
82         ;;
83   status)
84         if [ ! -f /var/lock/subsys/binfmt-detector ]; then
85                 msg_not_running "binfmt detector"
86                 exit 1
87         fi
88         for fmt in windows windowsPE; do
89                 printf "%s: %s; %s: %s\n" $fmt \
90                         $(grep -E '(disabled|enabled)' $BINFMT_DIR/$fmt) \
91                         $(grep -E 'interpreter' $BINFMT_DIR/$fmt)
92         done
93         ;;
94   *)
95         msg_usage "$0 {start|stop|restart|reload|try-restart|force-reload|status}"
96         exit 3
97 esac
98
99 exit $RETVAL
This page took 0.093934 seconds and 3 git commands to generate.