1#!/bin/sh
2#
3# This script generates a "memstick image" (image that can be copied to a
4# USB memory stick) from a directory tree.  Note that the script does not
5# clean up after itself very well for error conditions on purpose so the
6# problem can be diagnosed (full filesystem most likely but ...).
7#
8# Usage: make-memstick.sh <directory tree> <image filename>
9#
10# $FreeBSD$
11#
12
13PATH=/bin:/usr/bin:/sbin:/usr/sbin
14export PATH
15
16BLOCKSIZE=10240
17
18if [ $# -ne 2 ]; then
19  echo "make-memstick.sh /path/to/directory /path/to/image/file"
20  exit 1
21fi
22
23if [ ! -d ${1} ]; then
24  echo "${1} must be a directory"
25  exit 1
26fi
27
28if [ -e ${2} ]; then
29  echo "won't overwrite ${2}"
30  exit 1
31fi
32
33makefs -B little ${2} ${1}
34if [ $? -ne 0 ]; then
35  echo "makefs failed"
36  exit 1
37fi
38
39