00c311bc00
embedded platform in particular. + mkimage will make an autosized image in a file (using vnd) from sets the resulting image can be mounted read-only, with tmpfs used for volatile files on top of read-only bases + mkpkgs will make an autosized image in a file (using vnd) from binary packages + usermode is an easy way to invoke usermode, making sure that bridging is set up properly, and that the host syscallemu module is loaded. This script then runs usermode with two file images (as produced by mkimage and mkpkgs)
66 lines
2.1 KiB
Bash
Executable File
66 lines
2.1 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
# $NetBSD: usermode,v 1.1 2012/01/15 02:01:02 agc Exp $
|
|
|
|
# Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
|
|
image=usermode.img
|
|
pkgs=pkgs.img
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-v) set -x ;;
|
|
*) break ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ $# -gt 0 ]; then
|
|
image=$1
|
|
fi
|
|
|
|
# check bridging is set up
|
|
bridging=$(ifconfig tap0 | awk '$1 == "inet" { print $2 }')
|
|
case "${bridging}" in
|
|
*.*.*.*) echo "bridging is already up on ${bridging}" ;;
|
|
*) interface=$(ifconfig -l | awk '{print $1}')
|
|
sudo ifconfig tap0 create up
|
|
sudo ifconfig bridge0 create
|
|
sudo brconfig bridge0 add tap0 add ${interface} up
|
|
sudo chmod 664 /dev/tap*
|
|
;;
|
|
esac
|
|
|
|
# check syscall emulation module is loaded
|
|
mod=$(modstat syscallemu | awk '$1 == "syscallemu" { print; exit }')
|
|
case "${mod}" in
|
|
syscallemu*) echo "Host syscall emulation module loaded" ;;
|
|
*) sudo modload syscallemu ;;
|
|
esac
|
|
|
|
./netbsd disk=${image} disk=${pkgs} net=tap0,00:00:de:ad:be:ef
|
|
|
|
exit 0
|