David van Moolenbroek c58da9fbc3 Rename MINIX service(8) to minix-service(8)
IMPORTANT: this change has a docs/UPDATING entry!

This rename is unfortunately necessary because NetBSD has decided to
create its own service(8) utility, and we will want to import theirs
as well.  The two can obviously not coexist.

Also move ours from /bin to /sbin, as it is a superuser-only utility.

Change-Id: Ic6e46ffb3a84b4747d2fdcb0d74e62dbea065039
2017-02-22 17:16:21 +00:00

113 lines
2.8 KiB
Bash

#!/bin/sh
set -e
exec >/dev/log
exec 2>/dev/log
exec </dev/null
PATH=/sbin:/usr/sbin:/bin:/usr/bin
FSCK=/bin/fsck_mfs
ACPI=/service/acpi
if [ X`/bin/sysenv arch` = Xi386 ]
then if [ -e $ACPI -a -n "`sysenv acpi`" ]
then
minix-service -c up $ACPI
fi
minix-service -c up /service/pci -dev /dev/pci
minix-service -c up /service/input -dev /dev/kbdmux
minix-service -c up /service/pckbd || :
# Start procfs so we can access /proc/pci
mount -t procfs none /proc >/dev/null
# Do we want to use the virtio block device?
# If not specified, default to yes if the device is found.
if /bin/sysenv virtio_blk >/dev/null
then virtio_blk="`/bin/sysenv virtio_blk`"
elif grep '^[^ ]* [^ ]* 1AF4:1001[^ ]* ' /proc/pci >/dev/null
then echo "virtio_blk not set, defaulting to using found virtio device."
virtio_blk=yes
fi
minix-service -cn up /service/floppy -dev /dev/fd0
if [ X`/bin/sysenv ahci` = Xyes ]
then
# this is here temporarily, for testing purposes
minix-service -c up /service/ahci -dev /dev/c0d0 -label ahci_0 -args instance=0
elif [ X"$virtio_blk" = Xyes ]
then
minix-service -c up /service/virtio_blk -dev /dev/c0d0 -label virtio_blk_0 -args instance=0
else
minix-service -c up /service/at_wini -dev /dev/c0d0 -label at_wini_0
minix-service -cr up /service/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1 2>/dev/null || :
fi
/bin/umount /proc >/dev/null
fi
if [ X`/bin/sysenv arch` = Xearm ]
then echo Starting the mmc driver
minix-service -c up /service/mmc -dev /dev/c0d0
fi
minix-service up /service/procfs || echo "WARNING: couldn't start procfs"
if /bin/sysenv rootdevname >/dev/null
then rootdevname=/dev/`/bin/sysenv rootdevname`
else
if (! sysenv cdproberoot) && (! sysenv bootramdisk) >/dev/null
then echo "rootdevname not set"
exit 1
fi
fi
if [ "`sysenv bin_img`" = 1 ]
then
bin_img="-i "
fi
if sysenv cdproberoot >/dev/null
then
echo
echo 'Looking for boot CD. This may take a minute.'
echo 'Please ignore any error messages.'
echo
rootdevname=$(cdprobe) || { echo 'No CD found'; exit 1; }
export rootdevname
elif [ "$rootdevname" = "/dev/ram" ]
then
ramimagename=/dev/`/bin/sysenv ramimagename`
echo "Loading ramdisk from $ramimagename"
loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed"
fi
if sysenv bootramdisk >/dev/null
then
rootdevname=imgrd
fi
echo "Root device name is $rootdevname"
if ! sysenv cdproberoot >/dev/null
then
if [ -e $FSCK ]
then $FSCK -p $rootdevname
fi
fi
# Change root from temporary boot ramdisk to the configure
# root device
if ! sysenv bootramdisk >/dev/null
then
/bin/mount -n $bin_img"$rootdevname" /
fi
/bin/mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs"
if ! sysenv bootramdisk >/dev/null
then
exec /bin/sh /etc/rc `sysenv bootopts` "$@"
fi