summaryrefslogtreecommitdiff
blob: 494744ad05e1095d3db3fc25d461ab735f5c15e3 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/sbin/runscript
#
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/openmosix-user/files/openmosix.init,v 1.8 2004/07/15 00:55:46 agriffis Exp $

depend() {
	need net
}

stop() {
	ebegin "Stopping openMosix"
        # Expel all processes and disable openMosix configuration
        einfo "openMosix: "
        mosctl expel
	setpe -off
        killall -TERM omdiscd &> /dev/null
	rm -f /var/lock/subsys/mosix
	eend
}

start() {

# If we're not running an openMosix enabeled kernel: exit
if [ ! -d /proc/hpc ]; then
    einfo "This is not an openMosix kernel, configuration aborted"
    exit
fi

# Find the openMosix map-file
AUTODISC=0
if [ -f /etc/openmosix.map ]; then
    OMOSIX_MAP=/etc/openmosix.map
elif [ -f /etc/mosix.map ]; then
    OMOSIX_MAP=/etc/mosix.map
    einfo "openMosix map-file /etc/mosix.map depreciated: Rename to /etc/openmosix.map"
elif [ -f /etc/hpc.map ]; then
    OMOSIX_MAP=/etc/hpc.map
    einfo "openMosix map-file /etc/hpc.map depreciated: Rename to /etc/openmosix.map"
else
    AUTODISC=1
fi

OMnode=""
if [ -f /etc/openmosix/om-node-num ]
then
  OMnode="-p $(< /etc/openmosix/om-node-num)"
fi

# Check the map-file for sanity
if [ $AUTODISC -eq 0 ]; then
    setpe $OMnode -c -f $OMOSIX_MAP &> /dev/null
    if [ ! $? -eq 0 ]; then
        einfo "openMosix: Invalid configuration in map-file $OMOSIX_MAP, using autodiscovery"
        AUTODISC=1
    fi
fi

# Source the configuration from /etc/openmosix/openmosix.config
# This file would be a good place to force autodiscovery by setting AUTODISC=1
[ -f /etc/openmosix/openmosix.config ] && . /etc/openmosix/openmosix.config

# Make sure we have omdiscd installed
if [ $AUTODISC -eq 1  ]; then
    if [ ! -x `which omdiscd` ]; then
        eerror "openMosix: omdiscd not installed, exiting"
        eend
    fi
fi



	ebegin "Initializing openMosix"
        # The variables $OVERHEADS, $MFSCOSTS, $MYOMID, $MOSGATES and $AUTODISCIF
        # can be set to desired values in /etc/openmosix/openmosix.config
        [ $OVERHEADS ] && echo $OVERHEADS > /proc/hpc/admin/overheads
        [ $MFSCOSTS  ] && echo $MFSCOSTS  > /proc/hpc/admin/mfscosts
    
        if [ $AUTODISC -eq 0  ]; then
            # Static configuration via $OMOSIX_MAP
            SETPE_OPTIONS=""
	    [ $MYOMID ] && SETPE_OPTIONS="$SETPE_OPTIONS -p $MYOMID"
	    [ $MOSGATES ] && SETPE_OPTIONS="$SETPE_OPTIONS -g $MOSGATES"
	    setpe $OMnode -W $SETPE_OPTIONS -f $OMOSIX_MAP
       else
            # Configurate openMosix with the omdiscd
	    OMDISCD_OPTIONS=""
	    [ $AUTODISCIF ] && OMDISCD_OPTIONS="$OMDISCD_OPTIONS -i $AUTODISCIF"
	    omdiscd $OMDISCD_OPTIONS
       fi

       [ $? -eq 0 ] && touch /var/lock/subsys/openmosix
       mosctl noblock 1>/dev/null 2>&1
       eend
}