Annotation of elwix/config/etc/default/rc.cfg, revision 1.2.2.3
1.2 misho 1: #!/bin/sh
2: #
3: # U-boot cfg nand map load/save management script
4: #
1.2.2.3 ! misho 5: # $Id: rc.cfg,v 1.2.2.2 2014/09/17 21:39:17 misho Exp $
1.2 misho 6:
7: CFG_NAND_LIST="/etc/cfg.map"
8: CFG_NAND_MAP="/dev/ada0g"
9: CFG_NAND_SIZE=262144
10:
1.2.2.1 misho 11: UPGRADE_GPIO_PINS="1 2 3"
1.2 misho 12:
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)
1.2.2.3 ! misho 53: ELWIX_REMOTE_HOST="/tmp/elwix_cfg_$(hostname).bin"
1.2 misho 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: ;;
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"
63: for i in ${UPGRADE_GPIO_PINS}; do
1.2.2.2 misho 64: gpioctl $i 1 >/dev/null 2>&1 || pceng "$i=0" >/dev/null 2>&1
1.2 misho 65: done
66: TFTPd -wR
67: ;;
68: *)
69: echo "Missing parameter - available options are (load | save | erase | backup | restore | upgrade)"
70: ;;
71: esac
72:
73: cd -
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>