1199536Smr#!/bin/sh
2199536Smr#
3199536Smr# Copyright (c) 2004-2005 Poul-Henning Kamp.
4199536Smr# All rights reserved.
5199536Smr#
6199536Smr# Redistribution and use in source and binary forms, with or without
7199536Smr# modification, are permitted provided that the following conditions
8199536Smr# are met:
9199536Smr# 1. Redistributions of source code must retain the above copyright
10199536Smr#    notice, this list of conditions and the following disclaimer.
11199536Smr# 2. Redistributions in binary form must reproduce the above copyright
12199536Smr#    notice, this list of conditions and the following disclaimer in the
13199536Smr#    documentation and/or other materials provided with the distribution.
14199536Smr#
15199536Smr# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16199536Smr# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17199536Smr# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18199536Smr# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19199536Smr# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20199536Smr# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21199536Smr# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22199536Smr# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23199536Smr# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24199536Smr# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25199536Smr# SUCH DAMAGE.
26199536Smr#
27199536Smr# $FreeBSD$
28199536Smr#
29199536Smr# Script to update partition 1 on a NanoBSD system.
30199536Smr#
31199536Smr# usage:
32199536Smr#	ssh somewhere cat image.s1 | sh updatep1
33199536Smr#
34199536Smr
35199536Smrset -e
36199536Smr
37199536Smr. /etc/nanobsd.conf
38199536Smr
39199536Smrif mount | grep ${NANO_DRIVE}s1 > /dev/null ; then
40199536Smr	echo "You are running partition 1 already"
41199536Smr	echo "you probably want to use 'updatep2' instead"
42199536Smr	exit 1
43199536Smrfi
44199536Smr
45199536Smr# Blow away old system.
46199536Smrdd if=/dev/zero of=/dev/${NANO_DRIVE}s1 bs=1m count=1 > /dev/null 2>&1
47199536Smr
48199536Smr# Copy in new system
49199536Smrdd of=/dev/${NANO_DRIVE}s1 obs=64k
50199536Smr
51199536Smr# Check that it worked
52199536Smrfsck_ffs -n /dev/${NANO_DRIVE}s1a
53199536Smr
54199536Smrgpart set -a active -i 1 ${NANO_DRIVE}
55