summaryrefslogtreecommitdiff
blob: 74735a40926a783e2f0fa2e97ae32e3c3b8383c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-dotnet/pe-format/files/pe-format.init,v 1.1 2006/12/21 00:53:52 compnerd Exp $

start() {
   ebegin "Registering PE binaries with ${CLR}"

   if [[ ! -d /proc/sys/fs/binfmt_misc ]] ; then
      eerror "You need support for \"misc binaries\" in your kernel!"
      exit 1
   fi

   if [[ $(mount | grep -c binfmt_misc) -eq 0 ]] ; then
      mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc &> /dev/null
      local result=$?

      if [[ $result -ne 0 ]] ; then
         eend $result
         exit $result
      fi
   fi

   case "${CLR}" in
      mono)
         echo ':PE:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
         eend 0
         ;;
      ilrun)
         echo ':PE:M::MZ::/usr/bin/ilrun:' > /proc/sys/fs/binfmt_misc/register
         eend 0
         ;;
      *)
         eerror 'Please enter a valid option in /etc/conf.d/dotnet'
         eend 1
         ;;
   esac
}

stop() {
   ebegin "Unregistering PE binaries"

   if [[ -f /proc/sys/fs/binfmt_misc/PE ]] ; then
      echo '-1' > /proc/sys/fs/binfmt_misc/PE
   fi

   eend $?
}

# vim: ts=4 :