remove extention on some scripts and correct services
[debian6500.git] / master / opt / script / flash_fe306
diff --git a/master/opt/script/flash_fe306 b/master/opt/script/flash_fe306
new file mode 100755 (executable)
index 0000000..423b6d4
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# parameters
+#
+# ============================================================================
+#
+# Copyright (C) THALES. All rights reserved
+# Author: Laurent Mazet
+# 
+# 2014-10-06 V1.0 : Creation 
+# 
+# ============================================================================
+
+DRY=
+FIRMWARE=/opt/trc6500/config/code_metier/libHwCtrl/Bitstream
+LIST="application.out production.bin ts12_fp_pano.bin ts22_fp_pano.bin firmware.out"
+HOST=
+TRC6500_SCRIPT_DIR=$(dirname $0)
+
+# help function
+
+function usage () {
+  echo "usage: $PROGNAME [-d] [-f dir] [-h] [-i host] [-l list]"
+  echo " -d: dry mode"
+  echo " -f: firmware directory ($FIRMWARE)"
+  echo " -h: help message"
+  echo " -i: board hostname (or ip)"
+  echo " -l: list of firmware ($LIST)"
+  exit $@
+  }
+
+# formating functions
+
+function title () { echo -e "\033[0;1m$*\033[0;0m"; }
+function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
+function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
+function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
+
+# argument processing
+
+while [ $# -gt 0 ]; do
+    case "$1" in
+    -d) DRY=yes;;
+    -f) shift; FIRMWARE=$1;;
+    -h) usage 0;;
+    -i) shift; HOST=$1;;
+    -l) shift; LIST=$1;;
+    *) usage 1;;
+    esac
+    shift
+done
+
+# check host
+
+[ "$HOST" ] || ping -c 1 $HOST >&/dev/null || \
+    { fail "Can't connect '$HOST'"; exit 1; }
+
+# check firmware
+
+for f in $LIST; do
+    [ -f $FIRMWARE/$f ] || { fail "Can't find '$FIRMWARE/$f'"; exit 1; }
+done
+
+# check mode
+
+protect=""
+[ "$DRY" = yes ] && protect="!echo"
+
+# flash firmware
+
+title "flash fe306 '$HOST'"
+
+ftp -n <<EOF
+open $HOST
+quote USER none
+quote PASS none
+binary
+cd flash
+$(for f in $LIST; do echo "$protect send $FIRMWARE/$f"; done)
+bye
+EOF
+
+# vim:set tabstop=4 shiftwidth=4 softtabstop=4: