update to Debian 12 (2)
[debian6500.git] / master / opt / script / change_lgcore
CommitLineData
1685c129
LM
1#!/bin/bash
2# ============================================================================
3#
4# Copyright (C) THALES. All rights reserved
5# Author: Laurent Mazet
6#
7# Date : 17/12/2014
8# ============================================================================
9
10# Install new lgcore delivery
11
12# TODO
13# *
14
15MODE=
16PROGNAME=$(basename $0)
17REPOSITORY="/opt/trc6500/debian-rep"
18TMPLOG=/tmp/$PROGNAME-$$.log
19VER=1.0
20
21# help function
22
23function usage () {
24 echo "usage: $PROGNAME [-h] [-r dir] [-v] <mode>"
25 echo " install new version from lgcore delivery from"
26 echo " - usb: usb key slotted on master blade"
27 echo " - file: file stored in a special repository"
28 echo
29 echo " options are:"
30 echo " -h: help message"
31 echo " -r: change repository (default is $REPOSITORY)"
32 echo " -v: version"
33 exit $@
34}
35
36# formating functions
37
38function title () { echo -e "\033[0;1m$*\033[0;0m"; }
39function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
40function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
41function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
42
43# check command
44
45function check () {
46 echo -n "$@: "
47 $@ 2>$TMPLOG && pass OK || { fail KO; cat $TMPLOG; exit 1; }
48 rm -f $TMPLOG
49}
50
51# argument processing
52
53while [ $# -gt 0 ]; do
54 case "$1" in
55 -h) usage 0;;
56 -r) shift; REPOSITORY=$1;;
57 -v) echo "$PROGNAME version $VER"; exit 0;;
58 file|usb) MODE=$1;;
59 *) usage 1;;
60 esac
61 shift
62done
63
64# check mode
65
66[ "$MODE" ] || { fail "need mode (file or usb)"; exit 1; }
67
68# check repository
69
70DIR=
71case "$MODE" in
72file) DIR=$REPOSITORY;;
73usb)
74 DIR=/media/floppy0
75 check mount /dev/sdb1 $DIR
76 trap "umount $DIR;" 0 1 2 15
77esac
78
79# look for file
80
81echo -n "look for delivery file: "
82LIV=$(find $DIR -name liv\*.sfx 2>$TMPLOG | sort | tail -1)
83[ -f "$LIV" ] && pass OK || { fail KO; cat $TMPLOG; exit 1; }
84rm -f $TMPLOG
85
86# install lgcore delivery
87
88check bash $LIV
89
90# vim:set tabstop=4 expandtab shiftwidth=4: