Explorar o código

update by krrish

krrish %!s(int64=6) %!d(string=hai) anos
pai
achega
26c797bab0
Modificáronse 1 ficheiros con 48 adicións e 0 borrados
  1. 48 0
      build/pushToRemote_batch.sh

+ 48 - 0
build/pushToRemote_batch.sh

@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# check input
+if [ -z "$1" ]; then
+    echo "*************************************************************************************"
+    echo 
+    echo " Usage: ./pushToRemote_batch.sh /PATH/TO/FILE"
+    echo
+    echo "*************************************************************************************"
+    echo 
+    exit 1
+fi
+
+FBS_ESC=`echo -en "\033"`
+COLOR_RED="${FBS_ESC}[1;31m"
+COLOR_GREEN="${FBS_ESC}[1;32m"
+COLOR_CLOSE="${FBS_ESC}[0m"
+
+cd $(dirname $0)
+
+# check scirpt exists
+[ -x ./pushToRemote.sh ] || { echo "need pushToRemote.sh with \"x\" privilege, exit"; exit 1; }
+
+# check file exists
+[ -f "$1" ] || { echo "$1 dose't exists"; exit 1; }
+
+# check the file content
+# file content should start with "registry.svicloud.com/*" only
+FILTERED_ROWS=`sed -n '/^$/!p' $1 | sed -n '/^ *#/!p'`
+if echo "$FILTERED_ROWS" | grep -vq "^ *registry.svicloud.com/"; then
+    echo "content in $i error, only \"registry.svicloud.com/*\" support"
+    exit 1
+fi
+
+BASEFILE=`basename $0`
+LOG_FILE=/var/log/${BASEFILE%.*}.log
+echo "" >>$LOG_FILE; echo "[`date "+%Y-%m-%d %H:%M:%S"`]" >>$LOG_FILE
+
+# loop
+LOOP_ROWS=`sed -n '/^$/!p' $1 | sed -n '/^ *#/!p' | \
+  grep "^ *registry.svicloud.com/" | sort | uniq`
+
+for i in $LOOP_ROWS; do
+  echo; echo "################ $i"
+  ./pushToRemote.sh $i && \
+    { echo "################ ${COLOR_GREEN}success${COLOR_CLOSE}"; echo ; echo -e "success\t$i" >>$LOG_FILE; } || \
+    { echo "################ ${COLOR_RED}error${COLOR_CLOSE}"; echo ; echo -e "error\t$i" >>$LOG_FILE; }
+done