summaryrefslogtreecommitdiffstats
path: root/loader/linuxrc.s390
blob: 291249060ade2acf976408ea104c5be906a97a46 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#! /bin/sh
#
# Copyright (C) 2000,2001 by
#        Bernhard Rosenkraenzer <bero@redhat.com>
#        Oliver Paukstadt <opaukstadt@millenux.com>
#        Karsten Hopp <karsten@redhat.de>
#        Florian La Roche <laroche@redhat.com>
#        Nils Philippsen <nils@redhat.de>
#        Helge Deller <hdeller@redhat.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

debugshell()
{
	echo "You have defined DEBUG, so here is a shell. You can use 'exit'"
	echo "to go on with the normal installation process."
	/bin/sh
}

startinetd()
{
	echo
	echo "Starting telnetd and sshd to allow login over the network."
	/sbin/inetd
	echo "Generating ssh keys, This can take a while..."
	(cd /etc/ssh
		echo "  Generating host_key"
		ssh-keygen  -q -t rsa1 -f ssh_host_key -C '' -N '' >/dev/null 2>&1
		echo "  Generating rsa_key"
		ssh-keygen  -q -t rsa -f ssh_host_rsa_key -C '' -N '' >/dev/null 2>&1
		echo "  Generating dsa_key"
		ssh-keygen  -q -t dsa -f ssh_host_dsa_key -C '' -N '' >/dev/null 2>&1
		chmod 600 ssh_host_key ssh_host_rsa_key ssh_host_dsa_key
		chmod 644 *.pub
		echo "Done"
	)
	/sbin/sshd
   while : ; do
		echo
		echo "Please connect now to $IPADDR and start 'rhsetup' or start"
		echo "'rhsetup nointeractive' from this shell."
		/bin/sh -l
	done
	#	/sbin/mingetty console --noclear
}


echo "Starting the S390 initrd to configure networking. Version is 0.24."

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH

#mount -n -o remount,rw /
mount -t proc none /proc
mount -t devpts none /dev/pts

ifconfig lo 127.0.0.1 netmask 255.0.0.0
route add -host 127.0.0.1 dev lo

[ -n "$DEBUG" ] && debugshell

# Parse configuration
if [ -n "$HOST" ]; then
	set -- `echo $HOST |sed 's/:/ /g'`
	HNAME=$1
	DEVICE=$2
	NETTYPE=`echo $DEVICE |sed -e 's/[0-9].*//'`
	IPADDR=$3
	if [ ":$NETTYPE" = ":iucv" ]; then
		IUCV="iucv=$4"
		GATEWAY=$5
		MTU=$6
	elif [ ":$NETTYPE" = ":ctc" ]; then
		GATEWAY=$4
		MTU=$5
	else
		MTU=$4
	fi
fi
if [ -n "$MTU" ]; then
	MMTU="mtu $MTU"
fi
if [ -n "$NETWORK" ]; then
	set -- `echo $NETWORK | sed 's/:/ /g'`
	NETWORKIP=$1
	NETMASK=$2
	BROADCAST=$3
	if [ ":$NETTYPE" != ":ctc" ] && [ ":$NETTYPE" != ":iucv" ]; then
		GATEWAY=$4
	fi
fi

# Check for missing parameters, prompt for them if necessary
while [ -z "$HNAME" ]; do
	echo "Please enter the FQDN of your new virtual machine (e.g. s390.redhat.com):"
	read HNAME
done
while [ -z "$DEVICE" ]; do
	echo "Please enter the network device you intend to use (e.g. ctc0, iucv0, eth0, tr0):"
	read DEVICE
	NETTYPE=`echo $DEVICE |sed -e 's/[0-9].*//'`
done
while [ -z "$IPADDR" ]; do
	echo "Please enter the IP address of your new virtual machine:"
	read IPADDR
done
if [ ":$NETTYPE" = ":eth" ] || [ ":$NETTYPE" = ":tr" ]; then
	while [ -z "$NETMASK" ]; do
		echo "Please enter your netmask (e.g. 255.255.255.0):"
		read NETMASK
	done
	while [ -z "$BROADCAST" ]; do
		echo "Please enter your broadcast address:"
		read BROADCAST
	done
	while [ -z "$NETWORKIP" ]; do
		echo "Please enter your network address:"
		read NETWORKIP
	done
	while [ -z "$GATEWAY" ]; do
		echo "Please enter your default gateway:"
		read GATEWAY
	done
	while [ -z "$LCS" ] && [ -z "$QETH" ]; do
		echo "(1) for OSA-2 with LCS or (2) for OSA-Express with QDIO/QETH"
		read INF
		while [ -z "$LCS" ] && [ ":$INF" = ":1" ]; do
			echo "OSA Device address (e.g. fc20,1 - or \"auto\" (may not work)):"
			read LCS
		done
		while [ -z "$QETH" ] && [ ":$INF" = ":2" ]; do
			echo "OSA-Express Device address (e.g. 0xf000,0xf001,0xf002 - or \"auto\" (may not work)):"
			read QETH
		done
	done
else
	while [ -z "$GATEWAY" ]; do
		echo "Enter the IP of your ctc/iucv point-to-point partner:"
		read GATEWAY
	done
	if [ ":$NETTYPE" = ":iucv" ]; then
		while [ -z "$IUCV" ]; do
			echo "Enter iucv kernel module options (usually iucv=HOST):"
			read IUCV
		done
	fi
fi

# configure network-interface
if [ ":$NETTYPE" = ":ctc" ]; then
	insmod ctc $CTC
	ifconfig $DEVICE $IPADDR $MMTU pointopoint $GATEWAY
	route add -host $IPADDR dev $DEVICE
elif [ ":$NETTYPE" = ":iucv" ]; then
	insmod netiucv $IUCV
	ifconfig $DEVICE $IPADDR $MMTU pointopoint $GATEWAY
	route add -host $IPADDR dev $DEVICE
else
	if [ -z "$QETH" ]; then
		if [ ":$LCS" = ":auto" ]; then
			LCS=""
		else
			LCS=`echo $LCS | sed -e '/^0x\|^0X/ b; s/^/0x/'`
			LCS="noauto=1 devno_portno_pairs=$LCS"
		fi
		insmod -f /lib/lcs.o $LCS
	else
		if [ ":$QETH" = ":auto" ]; then
			QETH="qeth_options="
		else
			QETH="qeth_options=noauto,$QETH"
		fi
		insmod -f /lib/qdio.o
		insmod -f /lib/qeth.o $QETH
	fi
	ifconfig $DEVICE $IPADDR $MMTU netmask $NETMASK broadcast $BROADCAST
	route add -net $NETWORKIP netmask $NETMASK dev $DEVICE
fi
route add default gw $GATEWAY dev $DEVICE

[ -n "$HNAME" ] && hostname $HNAME

# show interfaces and routing table
ifconfig -a
route -n

[ -n "$DEBUG" ] && debugshell

echo "Starting portmap."
portmap

# convert to space-separated lists
DNS=`echo $DNS |sed -e 's/:/ /g'`
SEARCHDNS=`echo $SEARCHDNS |sed -e 's/:/ /g'`
 
# transfer options into install environment
cat > /tmp/install.cfg <<EOF
HNAME="$HNAME"
DEVICE="$DEVICE"
NETTYPE="$NETTYPE"
IPADDR="$IPADDR"
GATEWAY="$GATEWAY"
MTU="$MTU"
NETWORKIP="$NETWORKIP"
NETMASK="$NETMASK"
BROADCAST="$BROADCAST"
INSTALL="$INSTALL"
INTERACTIVE="$INTERACTIVE"
DNS="$DNS"
SEARCHDNS="$SEARCHDNS"
RPMSERVER="$RPMSERVER"
MOUNTS="$MOUNTS"
FORCEDASDFORMAT="$FORCEDASDFORMAT"
SWAP="$SWAP"
DASD="$DASD"
LCS="$LCS"
QETH="$QETH"
IUCV="$IUCV"
CTC="$CTC"
DTZ="$DTZ"
ROOTPW="$ROOTPW"
CROOTPW="$CROOTPW"
export HNAME DEVICE NETTYPE IPADDR GATEWAY MTU INTERACTIVE
export NETWORKIP NETMASK BROADCAST INSTALL DNS SEARCHDNS FORCEDASDFORMAT
export RPMSERVER MOUNTS SWAP DASD LCS QETH IUCV DTZ ROOTPW CROOTPW
EOF
# immediately read it in again to export these into the shell below
. /tmp/install.cfg

[ -n "$DEBUG" ] && debugshell

if [ ":$INTERACTIVE" = ":0" ]; then
	rhsetup nointeractive || startinetd
else
	startinetd
fi

umount -a
umount /proc
#umount /

exit 0
# vim:ts=3:sw=3
# ;;; Local Variables: ***
# ;;; mode: sh ***
# ;;; tab-width:3 ***
# ;;; end: ***