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