summaryrefslogtreecommitdiff
blob: f339dabb666e6c8a269a7790a9983e24da994066 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh -
#RCUPDATE:2 3 4:95:This line is required for script management

# description: MOSIX is am extension of the operating system,
#	       supporting scalable and transparent cluster computing.
#
# mosix		Script to stop/start MOSIX
#
# Author:       Amnon Shiloh

. /etc/rc.d/config/functions

SERVICE="mosix"
opts="start stop status restart"

mosix_stop() {
	echo 0 > /proc/mosix/admin/mospe
	rm -f /var/lock/subsys/mosix
}

mosix_start() {
	if [ -s /etc/overheads -a -f /proc/mosix/admin/overheads ]
	then
		 /bin/grep -v '^#' /etc/overheads > /proc/mosix/admin/overheads
	fi
	if [ -s /etc/mfscosts -a -f /proc/mosix/admin/mfscosts ]
	then
		 /bin/grep -v '^#' /etc/mfscosts > /proc/mosix/admin/mfscosts
	fi
	a1=
	[ -s /etc/mospe ] && a1="-p `cat /etc/mospe`"
	a2=
	[ -s /etc/mosgates ] && a2="-g `cat /etc/mosgates`"
	/sbin/setpe -W $a1 $a2 -f /etc/mosix.map
	touch /var/lock/subsys/mosix
}

alarm() {
	t=$2
	while :
	do
		case "$t" in 0) break ;; esac
		sleep 1
		t=$(($t-1))
	done
	kill -1 $1
	exit 0
}

# See how we were called.
start() {
	eecho "Initializing MOSIX"
	if [ ! -f /etc/mosix.map ]
	then
		echo You have no MOSIX configuration - please edit yours now:
		echo -n "Editor to use [q to quit] - [vi] :- "
		trap 'echo Timed-Out ; exit 1' 1
		alarm $$ 120 &
		killer=$!
		read editor
		kill $killer
		trap ''
		case "$editor" in [qQ]) exit ;;
			"") editor=/usr/bin/vi
			    [ -f $editor ] || editor=/bin/vi
				;;
		esac
		echo "# MOSIX CONFIGURATION" > /etc/mosix.map
		echo "# ===================" >> /etc/mosix.map
		echo "#" >> /etc/mosix.map
		echo "# Each line should contain 3 fields, mapping IP addresses to MOSIX node-numbers:" >> /etc/mosix.map
		echo "# 1) first MOSIX node-number in range." >> /etc/mosix.map
		echo "# 2) IP address of the above node (or node-name from /etc/hosts)." >> /etc/mosix.map
		echo "# 3) number of nodes in this range." >> /etc/mosix.map
		echo "#" >> /etc/mosix.map
		echo "# MOSIX-#  IP  number-of-nodes" >> /etc/mosix.map
		echo "# ============================" >> /etc/mosix.map
		$editor /etc/mosix.map
		echo
		while :
		do
			echo "If this node's standard IP address is not part of the table that"
			echo "you just edited, because MOSIX uses a different or separate network,"
			echo "you need to type this node's MOSIX-number now."
			echo
			/bin/echo -n "Otherwise please press only <Enter> :- "
			read me
			case "$me" in "") /bin/rm -f /etc/mospe ; break ;;
				[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | \
				[1-9][0-9][0-9][0-9] | \
				[1-6][0-9][0-9][0-9][0-9])
					echo $me > /etc/mospe ; break ;;
				*) echo Improper MOSIX number - please try again: ;;
			esac
		done
	fi
	start_mosix 
	eend
}

stop() {
	eecho "Stopping MOSIX"
	stop_mosix 
	eend
}

status() {
	/sbin/setpe -r
}

restart() {
	eecho "Restarting MOSIX"
	stop_mosix
	start_mosix 
	eend
}

doservice ${@}