Annotation of elwix/config/etc/default/rc.cfg, revision 1.1.2.6
1.1.2.1 misho 1: #!/bin/sh
2: #
3: # U-boot cfg nand map load/save management script
4: #
1.1.2.6 ! misho 5: # $Id: rc.cfg,v 1.1.2.5 2014/07/29 19:12:14 misho Exp $
1.1.2.1 misho 6:
7: CFG_NAND_LIST="/etc/cfg.map"
1.1.2.6 ! misho 8: CFG_NAND_MAP="/dev/ada0g"
1.1.2.5 misho 9: CFG_NAND_SIZE=262144
1.1.2.1 misho 10:
1.1.2.3 misho 11: UPGRADE_GPIO_PINS=""
12:
1.1.2.1 misho 13: cd ${2:-/etc}
14:
15: case "$1" in
16: load)
17: imgupd -gs ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} | \
18: gunzip 2>&- | cpio -iud 2>&- || exit 1
19: ;;
20: save)
21: if [ ! -r ${CFG_NAND_LIST} ];then
22: echo "# Auto generated manifest file" >${CFG_NAND_LIST}
23: find . >>${CFG_NAND_LIST}
24: if [ $? -ne 0 -o ! -r ${CFG_NAND_LIST} ]; then
25: echo "Manifest cfg nand map - file '${CFG_NAND_LIST}' not found!"
26: exit 1
27: fi
28: fi
29:
30: sed -nE -e 's/^ *([^ #]+) */\1/p' < ${CFG_NAND_LIST} | xargs find | \
31: cpio -o | gzip -9 | \
32: imgupd -is ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} || exit 1
33: ;;
34: erase)
35: imgupd -is ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} /dev/zero || exit 1
36: echo "Config NAND was erased!"
37: ;;
38: restore)
39: ELWIX_REMOTE_HOST=`cat /etc/myelwix`
40: ping -c1 $(echo ${ELWIX_REMOTE_HOST} | cut -f3 -d '/' | cut -f2 -d '@') >/dev/null 2>&1
41: if [ $? -ne 0 ]; then
42: echo "ELWIX restore from host ${ELWIX_REMOTE_HOST} failed!!!"
43: exit 1
44: fi
45:
46: echo "ELWIX starting restore process from ${ELWIX_REMOTE_HOST}"
47: fetch -q -o- --user-agent=ELWIX_Restore --allow-sslv2 \
48: --no-verify-peer --no-verify-hostname ${ELWIX_REMOTE_HOST} | \
49: imgupd -R -is ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} || exit 1
50: echo "ELWIX restore process complete. Now rebooting system ..."
51: ;;
52: backup)
53: ELWIX_REMOTE_HOST="/tmp/elwix_cfg.bin"
54:
55: echo "ELWIX starting backup process to ${ELWIX_REMOTE_HOST}"
56: imgupd -gs ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} ${ELWIX_REMOTE_HOST} || exit 1
57: echo "ELWIX backup process complete."
58: ;;
1.1.2.2 misho 59: upgrade)
60: echo "ELWIX switch to upgrade mode. Starting TFTPd ..."
61: echo " You can upload now elwix_firmware.bin image to device with \"firmware\" name!!!"
62: echo " Example: put elwix_firmware.bin firmware"
1.1.2.3 misho 63: for i in ${UPGRADE_GPIO_PINS}; do
64: gpioctl $i 1 >/dev/null 2>&1
65: done
1.1.2.2 misho 66: TFTPd -wR
67: ;;
1.1.2.1 misho 68: *)
1.1.2.4 misho 69: echo "Missing parameter - available options are (load | save | erase | backup | restore | upgrade)"
1.1.2.1 misho 70: ;;
71: esac
72:
73: cd -
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>