File:  [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / default / rc.flash
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Thu Mar 11 13:59:50 2021 UTC (3 years, 7 months ago) by misho
Branches: MAIN
CVS tags: elwix2_8, elwix2_7, HEAD, ELWIX2_7, ELWIX2_6
ver 2.6

    1: #!/bin/sh
    2: #
    3: # Update ELWIX OS flash images
    4: #
    5: # $Id: rc.flash,v 1.2 2021/03/11 13:59:50 misho Exp $
    6: 
    7: die() { echo -n "ERROR:: " >&2; echo "$@" >&2; exit 1; }
    8: 
    9: restoreing()
   10: {
   11: 	case "$1" in
   12: 		primary|first|main|A|1)
   13: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"a") { printf("/dev/%s", $3); }'`
   14: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"a") { printf("%s", $2 * 512); }'`
   15: 
   16: 			sysctl -w kern.geom.debugflags=16
   17: 			imgupd -is $CFG_NAND_SIZE -f $CFG_NAND_MAP || die "Failed update primary image ..."
   18: 			tunefs -L elwix $CFG_NAND_MAP
   19: 			/etc/rc.cfg boot
   20: 			reboot
   21: 			;;
   22: 		secondary|second|backup|B|2)
   23: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"f") { printf("/dev/%s", $3); }'`
   24: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"f") { printf("%s", $2 * 512); }'`
   25: 
   26: 			imgupd -is $CFG_NAND_SIZE -f $CFG_NAND_MAP || die "Failed update secondary image ..."
   27: 			tunefs -L elwix2 $CFG_NAND_MAP
   28: 			/etc/rc.cfg boot2
   29: 			reboot
   30: 			;;
   31: 		configuration|config|cfg|C|0)
   32: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"g") { printf("/dev/%s", $3); }'`
   33: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"g") { printf("%s", $2 * 512); }'`
   34: 
   35: 			imgupd -is $CFG_NAND_SIZE -f $CFG_NAND_MAP || die "Failed update cfg image ..."
   36: 			reboot
   37: 			;;
   38: 		*)
   39: 			die "Unknown $1 image for restore ..."
   40: 			;;
   41: 	esac
   42: }
   43: 
   44: dumping()
   45: {
   46: 	case "$1" in
   47: 		primary|first|main|A|1)
   48: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"a") { printf("/dev/%s", $3); }'`
   49: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"a") { printf("%s", $2 * 512); }'`
   50: 			;;
   51: 		secondary|second|backup|B|2)
   52: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"f") { printf("/dev/%s", $3); }'`
   53: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"f") { printf("%s", $2 * 512); }'`
   54: 			;;
   55: 		configuration|config|cfg|C|0)
   56: 			CFG_NAND_MAP=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"g") { printf("/dev/%s", $3); }'`
   57: 			CFG_NAND_SIZE=`gpart show -p | awk '(NR == 1) { disk = $4; } ($3 == disk"g") { printf("%s", $2 * 512); }'`
   58: 			;;
   59: 		*)
   60: 			die "Unknown $1 image for dump ..."
   61: 			;;
   62: 	esac
   63: 
   64: 	echo imgupd -gs $CFG_NAND_SIZE -f $CFG_NAND_MAP
   65: }
   66: 
   67: #
   68: ## main()
   69: #
   70: 
   71: case "$1" in
   72: 	dump|get|read|fetch)
   73: 		dumping $2
   74: 		;;
   75: 	restore|put|write|update)
   76: 		restoring $2
   77: 		;;
   78: 	*)
   79: 		echo "/etc/rc.flash <dump|restore> <primary|secondary|config>"
   80: 		echo
   81: 		die "Unknown command $1 ..."
   82: 		;;
   83: esac

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>