shithub: riscv

ref: 651b2a32be9a0d0daebe9f6ff4ddee675908a8fc
dir: /rc/bin/inst/confignet/

View raw version
#!/bin/rc

# desc: configure the network

switch($1){
case checkready checkdone
	if(~ $netisfrom none){
		confignet=done
		export confignet
		exit
	}
	if(~ $netisfrom ppp ether){
		x=config$netisfrom
		$x=done
		./config$netisfrom checkdone
		confignet=$$x
		export confignet
		exit
	}
	confignet=ready
	export confignet
	exit

case go
	devs=''
	if(test -d /net/ether0 >[2]/dev/null)
		devs=$devs^ether
	if(test -f /dev/eia? >[2]/dev/null)
		devs=$devs^ppp
	
	switch($devs){
	case ''
		echo
		echo 'Could not find ethernet card nor serial port nor modem.'
		echo
		netisfrom=none
	
	case ppp
		echo
		echo 'No ethernet card was detected, but there is a serial port or modem.'
		echo 'We will configure PPP.'
		echo
		netisfrom=ppp
	
	case ether
		echo
		echo 'No serial port or modem detected, but there is an ethernet card.'
		echo 'We will configure the ethernet.'
		echo
		netisfrom=ether
	
	case etherppp
		echo
		echo 'You can connect to the internet via'
		echo 'a local ethernet or a dial-up PPP connection.'
		echo
		prompt -d ether 'Interface to use' ether ppp
		netisfrom=$rd
	}
	
	export netisfrom
	if(~ $netisfrom ether ppp)
		exec ./config$netisfrom go

	if(! test -f /srv/cs && ! test -f /net/cs)
		ndb/cs
	if(! test -f /srv/dns && ! test -f /net/dns)
		ndb/dns -r
}