Return to rc.cfg CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / default |
1.2 misho 1: #!/bin/sh 2: # 3: # U-boot cfg nand map load/save management script 4: # 1.3 ! misho 5: # $Id: rc.cfg,v 1.2.2.4 2014/09/23 14:25:27 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.3 ! misho 11: UPGRADE_GPIO_PINS="1 2 3" ! 12: ! 13: ELWIX_CFG_BACKUP_NAME="elwix_cfg_$(hostname).bin" 1.2 misho 14: 15: cd ${2:-/etc} 16: 17: case "$1" in 18: load) 19: imgupd -gs ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} | \ 20: gunzip 2>&- | cpio -iud 2>&- || exit 1 21: ;; 22: save) 23: if [ ! -r ${CFG_NAND_LIST} ];then 24: echo "# Auto generated manifest file" >${CFG_NAND_LIST} 25: find . >>${CFG_NAND_LIST} 26: if [ $? -ne 0 -o ! -r ${CFG_NAND_LIST} ]; then 27: echo "Manifest cfg nand map - file '${CFG_NAND_LIST}' not found!" 28: exit 1 29: fi 30: fi 31: 32: sed -nE -e 's/^ *([^ #]+) */\1/p' < ${CFG_NAND_LIST} | xargs find | \ 33: cpio -o | gzip -9 | \ 34: imgupd -is ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} || exit 1 35: ;; 36: erase) 37: imgupd -is ${CFG_NAND_SIZE} -f ${CFG_NAND_MAP} /dev/zero || exit 1 38: echo "Config NAND was erased!" 39: ;; 40: restore) 41: ELWIX_REMOTE_HOST=`cat /etc/myelwix` 42: ping -c1 $(echo ${ELWIX_REMOTE_HOST} | cut -f3 -d '/' | cut -f2 -d '@') >/dev/null 2>&1 43: if [ $? -ne 0 ]; then 44: echo "ELWIX restore from host ${ELWIX_REMOTE_HOST} failed!!!" 45: exit 1 46: fi 47: 48: echo "ELWIX starting restore process from ${ELWIX_REMOTE_HOST}" 49: fetch -q -o- --user-agent=ELWIX_Restore --allow-sslv2 \ 1.3 ! misho 50: --no-verify-peer --no-verify-hostname \ ! 51: ${ELWIX_REMOTE_HOST}/${ELWIX_CFG_BACKUP_NAME} | \ 1.2 misho 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) 1.3 ! misho 56: ELWIX_REMOTE_HOST="/tmp/${ELWIX_CFG_BACKUP_NAME}" 1.2 misho 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: ;; 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" 66: for i in ${UPGRADE_GPIO_PINS}; do 1.3 ! misho 67: gpioctl $i 1 >/dev/null 2>&1 || pceng "$i=0" >/dev/null 2>&1 1.2 misho 68: done 69: TFTPd -wR 70: ;; 71: *) 72: echo "Missing parameter - available options are (load | save | erase | backup | restore | upgrade)" 73: ;; 74: esac 75: 76: cd -