rename script check_network
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 2 Oct 2015 16:08:02 +0000 (18:08 +0200)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 2 Oct 2015 16:08:02 +0000 (18:08 +0200)
master/etc/sudoers.d/pdmenu
master/etc/sudoers.d/webconfig
master/etc/webconfig/alias.d/50-trc6500-master-file.csv
master/opt/script/check_network [new file with mode: 0755]
master/opt/script/check_network.sh [deleted file]

index b21381d80949f216bbe52fbbff2f423f2ee4f54c..0e63b174586f216ea2b1673d384a8103655aba14 100644 (file)
@@ -1,7 +1,7 @@
 # /etc/sudoers.d/trc6500
 
-trc6500        ALL = (root)NOPASSWD: /opt/script/check_network.sh *
-trc6500        ALL = (root)NOPASSWD: /opt/trc6500/script/check_network.sh *
+trc6500        ALL = (root)NOPASSWD: /opt/script/check_network *
+trc6500        ALL = (root)NOPASSWD: /opt/trc6500/script/check_network *
 trc6500        ALL = (root)NOPASSWD: /sbin/halt
 trc6500        ALL = (root)NOPASSWD: /usr/sbin/service ammwake *
 trc6500        ALL = (root)NOPASSWD: /usr/sbin/service ipmiwake *
index e924016177e0590899856cc480ca1f47c9c0c41b..bafcccd969725d9b450e7b55f0bd6c04185ba2b4 100644 (file)
@@ -1,7 +1,7 @@
 # /etc/sudoers.d/webconfig
 
-webconfig      ALL = (root)NOPASSWD: /opt/script/check_network.sh *
-webconfig      ALL = (root)NOPASSWD: /opt/trc6500/script/check_network.sh *
+webconfig      ALL = (root)NOPASSWD: /opt/script/check_network *
+webconfig      ALL = (root)NOPASSWD: /opt/trc6500/script/check_network *
 webconfig      ALL = (root)NOPASSWD: /sbin/halt
 webconfig      ALL = (root)NOPASSWD: /usr/sbin/service ammwake *
 webconfig      ALL = (root)NOPASSWD: /usr/sbin/service ipmiwake *
index ee5f10c3859a49ce725f898a072a81797b5561f2..1d50e0de237ab5f727f2e1da562981a9a4769294 100644 (file)
@@ -41,10 +41,10 @@ swg1-restart;/usr/share/webconfig;;Restart switch SWG1;/opt/script/connect_switc
 swg2-restart;/usr/share/webconfig;;Restart switch SWG2;/opt/script/connect_switch -c reload swg2
 swm-restart;/usr/share/webconfig;;Restart switch SWM;/opt/script/connect_switch -c reload swm
 ;;;Blade maintenance actions;
-bios;/usr/share/webconfig;;Configure BIOS for all Supermicro blades;sudo /opt/script/check_network.sh -c '/opt/bios/update_bios_cfg.sh -y -Y' -o
-ipmi;/usr/share/webconfig;;Configure IPMI for all Supermicro blades;sudo /opt/script/check_network.sh -c '/opt/ipmi/update_blade_cfg.sh -y -Y' -o
+bios;/usr/share/webconfig;;Configure BIOS for all Supermicro blades;sudo /opt/script/check_network -c '/opt/bios/update_bios_cfg.sh -y -Y' -o
+ipmi;/usr/share/webconfig;;Configure IPMI for all Supermicro blades;sudo /opt/script/check_network -c '/opt/ipmi/update_blade_cfg.sh -y -Y' -o
 /dce;/usr/share/dce;/etc/dhcp/dhcpd.conf;DHCPD Configuration Editor;sudo service isc-dhcp-server restart
-ntp;/usr/share/webconfig;;Synchronize time and date on all blades;sudo /opt/script/check_network.sh -c 'service chrony stop; ntpdate-debian; service chrony start' -o
+ntp;/usr/share/webconfig;;Synchronize time and date on all blades;sudo /opt/script/check_network -c 'service chrony stop; ntpdate-debian; service chrony start' -o
 ;;;Internal equipements;
 http://10.133.26.160:8110;/usr/share/webconfig;;FE306-1;:goto:
 http://10.133.26.160:8120;/usr/share/webconfig;;FE306-2;:goto:
diff --git a/master/opt/script/check_network b/master/opt/script/check_network
new file mode 100755 (executable)
index 0000000..5c17bf2
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+# ============================================================================
+#
+# Copyright (C) THALES. All rights reserved
+# Author: Alexandre Cazalis
+# 
+# Gestion attente lames esclaves au boot (ping,ssh)
+#
+# 2013-11-20 : V1.2 LMa 
+#   - Ajout de la personalisation de la commande a executer
+#     par defaut (uptime). Ajout attente montage nfs avant demarrage
+# 2014-05-28 : V1.3 LMa
+#   - Ajout d'un mode foreground pour ne tenter qu'une fois chaque commande
+#   - Ajout d'une commande pour exclude la lame maitre
+#
+# 2014-10-28 : Change owner
+# ============================================================================
+
+# TODO
+# *
+
+CMD="uptime"
+MODE="iter"
+PROGNAME=$(basename $0)
+VER=1.3
+EXCLUDE="___"
+
+function usage () {
+    echo "usage: $PROGNAME [-c command] [-h] [-i] [-o] [-t seconds] [-v] [-w] [-x] host1 host2..."
+    echo "   -c: set command (default '$CMD')"
+    echo "   -h: help message"
+    echo "   -i: infinity loop mode [default]"
+    echo "   -o: only try ones"
+    echo "   -t: timeout"
+    echo "   -v: version message"
+    echo "   -w: wait mode"
+    echo "   -x: avoid master blade"
+    exit $@
+}
+
+while [ $# -gt 0 ]; do
+    case "$1" in
+    -c) shift; CMD=$1;;
+    -h) usage 0;;
+    -i) MODE="iter";;
+    -o) MODE="ones";;
+    -t) shift; [[ "$1" =~ [^0-9] ]] && { echo "incorrect timeout ($1)"; exit 1;}; TIMEOUT=$1;;
+    -v) echo "$PROGNAME: version $VER"; exit;;
+    -w) MODE="wait";;
+    -x) EXCLUDE="trc00";;
+    *) list+=" "$1;;
+    esac
+    shift
+done
+
+# list
+[ "$list" ] || list=$(awk '{sub(/#.*/, "")} /trc[0-9][0-9]/ && ! /-rf/ {print $2}' /etc/hosts)
+list=$(echo $list" "|sed s/$EXCLUDE//)
+
+# timeout
+if [ "$TIMEOUT" ]; then
+    trap "echo 'timeout expired (${TIMEOUT}s)'; exit 0;" SIGVTALRM
+    ( sleep $TIMEOUT; kill -SIGVTALRM $$ 2>/dev/null; [ $? -eq 0 ] && rc=1 || rc=0; exit $rc) &
+fi
+trap "exit 0;" SIGINT
+
+# main loop
+while true; do
+    for host in $list; do
+       stat=0
+       echo -n ${host}:" "
+       ping -c 1 $host >&/dev/null && { ssh -t -o ConnectTimeout=1 root@$host "$CMD" 2>/dev/null && stat=1 || echo "soon..."; } || echo
+       [ "$MODE" = "wait" -a $stat -eq 1 ] && list=${list/$host }
+    done
+    [ "$MODE" = "ones" ] && break;
+    [[ "$list" =~ [a-zA-Z0-9_-] ]] && sleep 1 || break;
+done
diff --git a/master/opt/script/check_network.sh b/master/opt/script/check_network.sh
deleted file mode 100755 (executable)
index 5c17bf2..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/bash
-#
-# ============================================================================
-#
-# Copyright (C) THALES. All rights reserved
-# Author: Alexandre Cazalis
-# 
-# Gestion attente lames esclaves au boot (ping,ssh)
-#
-# 2013-11-20 : V1.2 LMa 
-#   - Ajout de la personalisation de la commande a executer
-#     par defaut (uptime). Ajout attente montage nfs avant demarrage
-# 2014-05-28 : V1.3 LMa
-#   - Ajout d'un mode foreground pour ne tenter qu'une fois chaque commande
-#   - Ajout d'une commande pour exclude la lame maitre
-#
-# 2014-10-28 : Change owner
-# ============================================================================
-
-# TODO
-# *
-
-CMD="uptime"
-MODE="iter"
-PROGNAME=$(basename $0)
-VER=1.3
-EXCLUDE="___"
-
-function usage () {
-    echo "usage: $PROGNAME [-c command] [-h] [-i] [-o] [-t seconds] [-v] [-w] [-x] host1 host2..."
-    echo "   -c: set command (default '$CMD')"
-    echo "   -h: help message"
-    echo "   -i: infinity loop mode [default]"
-    echo "   -o: only try ones"
-    echo "   -t: timeout"
-    echo "   -v: version message"
-    echo "   -w: wait mode"
-    echo "   -x: avoid master blade"
-    exit $@
-}
-
-while [ $# -gt 0 ]; do
-    case "$1" in
-    -c) shift; CMD=$1;;
-    -h) usage 0;;
-    -i) MODE="iter";;
-    -o) MODE="ones";;
-    -t) shift; [[ "$1" =~ [^0-9] ]] && { echo "incorrect timeout ($1)"; exit 1;}; TIMEOUT=$1;;
-    -v) echo "$PROGNAME: version $VER"; exit;;
-    -w) MODE="wait";;
-    -x) EXCLUDE="trc00";;
-    *) list+=" "$1;;
-    esac
-    shift
-done
-
-# list
-[ "$list" ] || list=$(awk '{sub(/#.*/, "")} /trc[0-9][0-9]/ && ! /-rf/ {print $2}' /etc/hosts)
-list=$(echo $list" "|sed s/$EXCLUDE//)
-
-# timeout
-if [ "$TIMEOUT" ]; then
-    trap "echo 'timeout expired (${TIMEOUT}s)'; exit 0;" SIGVTALRM
-    ( sleep $TIMEOUT; kill -SIGVTALRM $$ 2>/dev/null; [ $? -eq 0 ] && rc=1 || rc=0; exit $rc) &
-fi
-trap "exit 0;" SIGINT
-
-# main loop
-while true; do
-    for host in $list; do
-       stat=0
-       echo -n ${host}:" "
-       ping -c 1 $host >&/dev/null && { ssh -t -o ConnectTimeout=1 root@$host "$CMD" 2>/dev/null && stat=1 || echo "soon..."; } || echo
-       [ "$MODE" = "wait" -a $stat -eq 1 ] && list=${list/$host }
-    done
-    [ "$MODE" = "ones" ] && break;
-    [[ "$list" =~ [a-zA-Z0-9_-] ]] && sleep 1 || break;
-done