From 1685c1292e82c761828bea8c14174215d2b4d3c7 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Tue, 23 Dec 2014 09:52:03 +0100 Subject: [PATCH] add a script to update lgcore --- master/etc/sudoers.d/pdmenu | 4 ++ master/etc/sudoers.d/webconfig | 3 ++ master/etc/webconfig/alias.csv | 21 ++++++-- master/root/bin/change_lgcore.sh | 90 ++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100755 master/root/bin/change_lgcore.sh diff --git a/master/etc/sudoers.d/pdmenu b/master/etc/sudoers.d/pdmenu index 53c247d..789fdd9 100644 --- a/master/etc/sudoers.d/pdmenu +++ b/master/etc/sudoers.d/pdmenu @@ -5,3 +5,7 @@ trc6500 ALL = (root)NOPASSWD: /sbin/halt trc6500 ALL = (root)NOPASSWD: /usr/sbin/service ammwake * trc6500 ALL = (root)NOPASSWD: /usr/sbin/service ipmiwake * trc6500 ALL = (root)NOPASSWD: /usr/sbin/service trc6500 * +trc6500 ALL = (root)NOPASSWD: /usr/bin/make * +trc6500 ALL = (root)NOPASSWD: /opt/trc6500/script/change_configuration.sh * +trc6500 ALL = (root)NOPASSWD: /root/bin/change_lgcore.sh * + diff --git a/master/etc/sudoers.d/webconfig b/master/etc/sudoers.d/webconfig index b021651..4f15b4d 100644 --- a/master/etc/sudoers.d/webconfig +++ b/master/etc/sudoers.d/webconfig @@ -5,3 +5,6 @@ webconfig ALL = (root)NOPASSWD: /sbin/halt webconfig ALL = (root)NOPASSWD: /usr/sbin/service ammwake * webconfig ALL = (root)NOPASSWD: /usr/sbin/service ipmiwake * webconfig ALL = (root)NOPASSWD: /usr/sbin/service trc6500 * +webconfig ALL = (root)NOPASSWD: /usr/bin/make * +webconfig ALL = (root)NOPASSWD: /opt/trc6500/script/change_configuration.sh * +webconfig ALL = (root)NOPASSWD: /root/bin/change_lgcore.sh * diff --git a/master/etc/webconfig/alias.csv b/master/etc/webconfig/alias.csv index 05a7fdc..47561f6 100644 --- a/master/etc/webconfig/alias.csv +++ b/master/etc/webconfig/alias.csv @@ -10,19 +10,19 @@ /gonext_ce/cfg;/usr/share/xcfe/cfg;/etc/webconfig/gonext.csv;; /trc6500_ce;/usr/share/xcfe;/opt/trc6500/etc/trc6500_config.xml;TRC6500 Configuration Editor;sudo service trc6500 restart /trc6500_ce/cfg;/usr/share/xcfe/cfg;/etc/webconfig/trc6500.csv;; -;;;TRC6500 maintenance action; +;;;TRC6500 maintenance actions; trc6500;/usr/share/webconfig;;Restart TRC6500;sudo service trc6500 restart start_active_phase;/usr/share/webconfig;;Start active phase;/opt/trc6500/bin/start_active_phase stop;/usr/share/webconfig;;Stop active phase;/opt/trc6500/bin/stop_active_phase halt;/usr/share/webconfig;;Shutdown TRC6500;sudo halt -;;;FE306 maintenance action; +;;;FE306 maintenance actions; fe306;/usr/share/webconfig;;Configure all FE306;/opt/trc6500/script/configure_fe306 -a FE306-1-flash;/usr/share/webconfig;;Flash FE306-1;/opt/trc6500/script/flash_fe306 -i fe306-1 FE306-2-flash;/usr/share/webconfig;;Flash FE306-2;/opt/trc6500/script/flash_fe306 -i fe306-2 FE306-3-flash;/usr/share/webconfig;;Flash FE306-3;/opt/trc6500/script/flash_fe306 -i fe306-3 FE306-4-flash;/usr/share/webconfig;;Flash FE306-4;/opt/trc6500/script/flash_fe306 -i fe306-4 FE306-5-flash;/usr/share/webconfig;;Flash FE306-5;/opt/trc6500/script/flash_fe306 -i fe306-5 -;;;Matrix maintenance action; +;;;Matrix maintenance actions; maxtrix;/usr/share/webconfig;;Configure matrix;/opt/trc6500/script/configure_matrix ;;;Switch maintenance actions; swg1-boot;/usr/share/webconfig;;Bootstrap switch SWG1;/opt/trc6500/script/configure_switch_bootstrap swg1 @@ -56,4 +56,19 @@ ammwake;/usr/share/webconfig;;Power on all HS22 IBM slaves;sudo service ammwake ipmiwake;/usr/share/webconfig;;Power on all SuperMicro slaves;sudo service ipmiwake start ammwake;/usr/share/webconfig;;Power off all HS22 IBM slaves;sudo service ammwake stop ipmiwake;/usr/share/webconfig;;Power off all SuperMicro slaves;sudo service ipmiwake stop +mediatray;/usr/share/webconfig;;Set media-tray to HS22 master blade;/opt/trc6500/script/set_mediatray amm00 -b 1 mediatray;/usr/share/webconfig;;Remove media-tray on HS22 chassis;/opt/trc6500/script/set_mediatray amm00 -b -1 && /opt/trc6500/script/set_mediatray amm01 -b -1 +;;;Setup hardware actions; +8mhzmhf;/usr/share/webconfig;;Setup 8MHzMHF mode;sudo /opt/trc6500/script/change_configuration.sh 8MHzMHF +12mhzdf;/usr/share/webconfig;;Setup 12MHzDF mode;sudo /opt/trc6500/script/change_configuration.sh 12MHzDF +12mhzmdf;/usr/share/webconfig;;Setup 12MHzMDF mode;sudo /opt/trc6500/script/change_configuration.sh 12MHzMDF +30mhzmdf;/usr/share/webconfig;;Setup 30MHzMDF mode;sudo /opt/trc6500/script/change_configuration.sh 30MHzMDF +30mhzmhf;/usr/share/webconfig;;Setup 30MHzMHF mode;sudo /opt/trc6500/script/change_configuration.sh 30MHzMHF +hw_ibm;/usr/share/webconfig;;Setup IBM HS22 chassis mode;sudo /opt/trc6500/script/change_configuration.sh hw_ibm +hw_supermicro;/usr/share/webconfig;;Setup IBM HS22 chassis mode;sudo /opt/trc6500/script/change_configuration.sh hw_supermicro +tz_zulu;/usr/share/webconfig;;Setup Zulu timezone;sudo /opt/trc6500/script/change_configuration.sh tz_zulu +tz_paris;/usr/share/webconfig;;Setup Europe/Paris timezone;sudo /opt/trc6500/script/change_configuration.sh tz_paris +tarballs;/usr/share/webconfig;;Build tarballs;sudo make -f /opt/cluster/Makefile all +;;;Install LgCore actions; +install-usb;/usr/share/webconfig;;Install LgCore from USB key;sudo /root/bin/change_lgcore.sh usb +install-file;/usr/share/webconfig;;Install LgCore from local file;sudo /root/bin/change_lgcore.sh file -r /var/cache/webconfig 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: -- 2.30.2