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