#! /bin/sh

busybox mount -a

#remount everything, read/write
#echo "Remounting root" &
busybox mount -o remount,rw /

/bin/busybox --install -s

# set hostname
#echo "Setting hostname" &
hostname riscv &

# create some dirs to avoid warning messages
#mkdir -p /var/run && \
mkdir -p /etc/network/if-up.d && \
mkdir -p /etc/network/if-pre-up.d &

# make home directory for root user
mkdir -p /root &

# telnetd requires this
mkdir -p /dev/pts && \
mount -t devpts none /dev/pts &

mkdir -p /dev/shm && \
mount -t tmpfs none /dev/shm &

chmod a+rw /dev/fb0
chmod a+rw /dev/dsp*
chmod -R a+rw /dev/snd

#set rows and columns of terminal
stty rows 24
stty columns 80

#echo "Configuring loopback device"
#ifconfig lo 127.0.0.1

#ifup lo &

# clear ethernet's IP
#echo "Bringing up eth0"
#ifconfig eth0 192.168.1.100 &
#ifconfig eth0 up

#route add default gw 192.168.1.1

/sbin/ifup -a &

#alternative
#setup dhcp
#echo "Launching udhcpc"
#/sbin/udhcpc -n -q -s /usr/share/udhcpc/default.script

# inetd startup
/usr/sbin/inetd &

