X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=master%2Froot%2Fbin%2Fchange_lgcore.sh;fp=master%2Froot%2Fbin%2Fchange_lgcore.sh;h=24c2da89a8d46c67b1d67a1ab5e5772ac9bb469f;hb=1685c1292e82c761828bea8c14174215d2b4d3c7;hp=0000000000000000000000000000000000000000;hpb=91b93b1f854bdf054acebb3e11ea552401c5bf59;p=debian6500.git diff --git a/master/root/bin/change_lgcore.sh b/master/root/bin/change_lgcore.sh new file mode 100755 index 0000000..24c2da8 --- /dev/null +++ b/master/root/bin/change_lgcore.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# ============================================================================ +# +# Copyright (C) THALES. All rights reserved +# Author: Laurent Mazet +# +# Date : 17/12/2014 +# ============================================================================ + +# Install new lgcore delivery + +# TODO +# * + +MODE= +PROGNAME=$(basename $0) +REPOSITORY="/opt/trc6500/debian-rep" +TMPLOG=/tmp/$PROGNAME-$$.log +VER=1.0 + +# help function + +function usage () { + echo "usage: $PROGNAME [-h] [-r dir] [-v] " + echo " install new version from lgcore delivery from" + echo " - usb: usb key slotted on master blade" + echo " - file: file stored in a special repository" + echo + echo " options are:" + echo " -h: help message" + echo " -r: change repository (default is $REPOSITORY)" + echo " -v: version" + 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"; } + +# check command + +function check () { + echo -n "$@: " + $@ 2>$TMPLOG && pass OK || { fail KO; cat $TMPLOG; exit 1; } + rm -f $TMPLOG +} + +# argument processing + +while [ $# -gt 0 ]; do + case "$1" in + -h) usage 0;; + -r) shift; REPOSITORY=$1;; + -v) echo "$PROGNAME version $VER"; exit 0;; + file|usb) MODE=$1;; + *) usage 1;; + esac + shift +done + +# check mode + +[ "$MODE" ] || { fail "need mode (file or usb)"; exit 1; } + +# check repository + +DIR= +case "$MODE" in +file) DIR=$REPOSITORY;; +usb) + DIR=/media/floppy0 + check mount /dev/sdb1 $DIR + trap "umount $DIR;" 0 1 2 15 +esac + +# look for file + +echo -n "look for delivery file: " +LIV=$(find $DIR -name liv\*.sfx 2>$TMPLOG | sort | tail -1) +[ -f "$LIV" ] && pass OK || { fail KO; cat $TMPLOG; exit 1; } +rm -f $TMPLOG + +# install lgcore delivery + +check bash $LIV + +# vim:set tabstop=4 expandtab shiftwidth=4: