Annotation of elwix/config/etc/default/rc.flash, revision 1.1.2.2
1.1.2.1 misho 1: #!/bin/sh
2: #
3: # Update ELWIX OS flash images
4: #
1.1.2.2 ! misho 5: # $Id: rc.flash,v 1.1.2.1 2017/10/13 00:01:12 misho Exp $
1.1.2.1 misho 6:
7: die() { echo -n "ERROR:: " >&2; echo "$@" >&2; exit 1; }
8:
1.1.2.2 ! misho 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:
1.1.2.1 misho 71: case "$1" in
1.1.2.2 ! misho 72: dump|get|read|fetch)
! 73: dumping $2
1.1.2.1 misho 74: ;;
1.1.2.2 ! misho 75: restore|put|write|update)
! 76: restoring $2
1.1.2.1 misho 77: ;;
78: *)
1.1.2.2 ! misho 79: echo "/etc/rc.flash <dump|restore> <primary|secondary|config>"
! 80: echo
! 81: die "Unknown command $1 ..."
1.1.2.1 misho 82: ;;
83: esac
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>