]>
Commit | Line | Data |
---|---|---|
aab3d22f | 1 | #!/bin/sh |
2 | # $Id$ | |
3 | # | |
5b18dbd8 | 4 | # binfmt-detector: Microsoft PE executable type detector. |
aab3d22f | 5 | # |
5b18dbd8 | 6 | # chkconfig: 2345 95 05 |
aab3d22f | 7 | # |
5b18dbd8 ER |
8 | # description: Microsoft PE executable type detector. User can run \ |
9 | # programs using Wine or Mono simply by clicking on them \ | |
802a6ec3 | 10 | # or typing ./file.exe |
aab3d22f | 11 | # |
12 | ||
13 | # Source function library | |
14 | . /etc/rc.d/init.d/functions | |
15 | ||
5b18dbd8 | 16 | BINFMT_DIR=/proc/sys/fs/binfmt_misc |
aab3d22f | 17 | |
5b18dbd8 | 18 | [ -d $BINFMT_DIR ] || exit 0 |
4d915dda | 19 | |
a62c069c | 20 | start() { |
5b18dbd8 ER |
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 | |
aab3d22f | 36 | else |
5b18dbd8 | 37 | fail |
aab3d22f | 38 | fi |
a62c069c ER |
39 | } |
40 | ||
41 | stop() { | |
5b18dbd8 ER |
42 | if [ ! -f /var/lock/subsys/binfmt-detector ]; then |
43 | msg_not_running "binfmt detector" | |
44 | return | |
aab3d22f | 45 | fi |
5b18dbd8 ER |
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 | |
a62c069c ER |
63 | } |
64 | ||
65 | RETVAL=0 | |
66 | case "$1" in | |
5b18dbd8 | 67 | start|reload) |
a62c069c ER |
68 | start |
69 | ;; | |
70 | stop) | |
71 | stop | |
aab3d22f | 72 | ;; |
73 | restart) | |
a62c069c ER |
74 | stop |
75 | start | |
aab3d22f | 76 | ;; |
5b18dbd8 ER |
77 | try-restart) |
78 | condrestart 0 | |
79 | ;; | |
80 | force-reload) | |
81 | condrestart 7 | |
82 | ;; | |
aab3d22f | 83 | status) |
acaec71f ER |
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 | |
aab3d22f | 93 | ;; |
94 | *) | |
5b18dbd8 | 95 | msg_usage "$0 {start|stop|restart|reload|try-restart|force-reload|status}" |
aab3d22f | 96 | exit 3 |
97 | esac | |
98 | ||
a62c069c | 99 | exit $RETVAL |