#!/bin/sh
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD: stable/5/tools/tools/nanobsd/Files/root/updatep2 146437 2005-05-20 09:54:23Z phk $
#
# Script to update partition 2 on a NanoBSD system.
#
# usage:
#	ssh somewhere cat image.s1 | sh updatep2
#

set -e

if mount | grep ad0s2 > /dev/null ; then
	echo "You are running partition 2 already"
	echo "you probably want to use 'updatep1' instead"
	exit 1
fi

dd of=/dev/ad0s2 obs=64k
mount /dev/ad0s2a /mnt
sed -i "" 's/ad0s1/ad0s2/' /mnt/conf/base/etc/fstab
sed -i "" 's/ad0s1/ad0s2/' /mnt/etc/fstab
umount /mnt
boot0cfg -s 2 -v ad0
