Menu

[r416]: / trunk / etc / rc.firmware  Maximize  Restore  History

Download this file

65 lines (50 with data), 1.2 kB

#!/bin/sh

# /etc/rc.firmware
# part of FreeNAS (http://www.freenas.org)
# Copyright (C) 2005-2006 Olivier Cochard <olivier@freenas.org>.
# All rights reserved.
#
# Based on m0n0wall (http://m0n0.ch/wall)
# Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
# All rights reserved.

CFDEVICE=`cat /var/etc/cfdevice`

if [ $1 != "upgrade" ]; then
	/sbin/umount -f /ftmp > /dev/null 2>&1
fi

case $1 in
enable)
	/sbin/mdmfs  -s 30m -b 8192 -f 1024 md1 /ftmp \
		> /dev/null 2>&1
	;;
upgrade)
	# wait 5 seconds before beginning
	sleep 5

	exec </dev/console >/dev/console 2>/dev/console
	
	# Check if firmware file exist
	if [ ! -r $2 ]; then
		echo "File does not exist. Exiting."
		exit
	fi

	echo
	echo "Firmware upgrade in progress..."

	# backup config
	mkdir /tmp/configbak
	cp -p /conf/* /tmp/configbak

	# unmount /cf
	/sbin/umount -f /cf

	# dd image onto card
	if [ -r $2 ]; then
		/usr/bin/gunzip -S "" -c $2 | dd of=/dev/$CFDEVICE bs=16k > /dev/null 2>&1
		echo "Image installed."
	fi

	# mount /cf
	/sbin/mount -w -o noatime /cf

	# restore config
	cp -p /tmp/configbak/* /conf

	# remount /cf ro
	/sbin/umount -f /cf
	/sbin/mount -r /cf

	echo "Done - rebooting system..."	
	/sbin/reboot
	;;
esac
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.