1139823Simp#!/bin/sh
2206361Sjoel#
351852Sbp# Copyright (c) 2004-2005 Poul-Henning Kamp.
451852Sbp# All rights reserved.
551852Sbp#
651852Sbp# Redistribution and use in source and binary forms, with or without
751852Sbp# modification, are permitted provided that the following conditions
851852Sbp# are met:
951852Sbp# 1. Redistributions of source code must retain the above copyright
1051852Sbp#    notice, this list of conditions and the following disclaimer.
1151852Sbp# 2. Redistributions in binary form must reproduce the above copyright
1251852Sbp#    notice, this list of conditions and the following disclaimer in the
1351852Sbp#    documentation and/or other materials provided with the distribution.
1451852Sbp#
1551852Sbp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1651852Sbp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1751852Sbp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1851852Sbp# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1951852Sbp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2051852Sbp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2151852Sbp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2251852Sbp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2351852Sbp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2451852Sbp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2551852Sbp# SUCH DAMAGE.
2651852Sbp#
2751852Sbp# $FreeBSD$
2854477Sbp#
2954477Sbp# Script to update partition 1 on a NanoBSD system.
3051852Sbp#
3151852Sbp# usage:
3251852Sbp#	ssh somewhere cat image.s1 | sh updatep1
3351852Sbp#
3451852Sbp
3551852Sbpset -e
3651852Sbp
3751852Sbp. /etc/nanobsd.conf
3887599Sobrien
3951852Sbpif mount | grep ${NANO_DRIVE}s1 > /dev/null ; then
4051852Sbp	echo "You are running partition 1 already"
4151852Sbp	echo "you probably want to use 'updatep2' instead"
4274060Sbp	exit 1
4351852Sbpfi
4451852Sbp
4551852Sbp# Blow away old system.
4687599Sobriendd if=/dev/zero of=/dev/${NANO_DRIVE}s1 bs=1m count=1 > /dev/null 2>&1
4751852Sbp
4851852Sbp# Copy in new system
4951852Sbpdd of=/dev/${NANO_DRIVE}s1 obs=64k
5051852Sbp
5151852Sbp# Check that it worked
5251852Sbpfsck_ffs -n /dev/${NANO_DRIVE}s1
5387599Sobrien
5451852Sbpgpart set -a active -i 1 ${NANO_DRIVE}
5551852Sbp