:
: 'Restore a previous system'
:
if [ "$1" = -backup ]; then
        rest -f /usr/src/sys/h/ioconf.h
        rest -f /usr/src/sys/conf/conf.c
        rest -f /usr/src/sys/conf/iotab.c
	rest -f /etc/ttys
	rest -f /etc/rootmtab
	rest -f /etc/ioreconfig.cp
	rest -f /etc/iounconfig.cp
	rest -f /etc/mountlist
	rest -f /etc/spooler/spoollist
	rest -f /etc/devicelist
	cp /outs /nuts
        rm -r /newdev
        cpt /olddev /newdev
        echo System restored.
        echo Use newsys to install it on next IPL.
	sync
        exit 0
:
: 'If not install, make a new system'
:
elif [ "$1" != -install ]; then
	input=${1-/etc/devicelist}
        rm -r /newdev
        echo "Generating new configuration files."
        if /etc/ioconf < $input; then
                cd /usr/src/sys/h
                save -c ioconf.h
                cp newioconf.h ioconf.h
                cd /usr/src/sys/conf
                save -c conf.c
                save -c iotab.c
                cp newconf.c conf.c
                cp newiotab.c iotab.c
                echo "Making new system."
                if make uts; then
                        echo "Make of system successful."
			cp /usr/src/sys/conf/uts /nuts
                else
                        echo "Make of system failed. Correct problem and try again."
                        exit 1
                fi
        else
                echo "Configuration generation failed. Correct problem and try again."
                exit 1
	fi
fi
