SHARE
TWEET

Untitled

a guest Jun 26th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export ID=$(echo $(who am i| awk '{print $1}'|xargs))
  2. export now=$(date '+%d%b%H%M%S')
  3. read -p "hosts' file location " location
  4.  
  5. function2
  6.  
  7. function_in_background(){
  8.     echo "proceding in background.." >> $LOG
  9.     while IFS= read -r i
  10.     do
  11.         (echo $i;sudo -i -u username ssh -q -o "StrictHostKeyChecking no" -o "NumberOfPasswordPrompts 0" -o ConnectTimeout=2 $i "cd /$i"_"${now}/ &&
  12. ./script update --start /$i"_"${now}/logs/update.xml --output /$i"_"${now}/logs" )  >> "${file_save}-${i}.txt" 2>&1 &
  13. done < "$file_name"
  14. wait
  15.         while IFS= read -r i
  16.         do
  17.             cat "${file_save}-${i}.txt"
  18.             rm "${file_save}-${i}.txt"
  19.             done < "$file_name" > "$LOG"
  20.         ( cat $LOG ;  echo -e "nn" ; ) | mailx -s "update completed" -a $LOGS -c "xyz@exchange.corp"    
  21.         break;
  22. }
  23.  
  24.  
  25. function2(){
  26. LOG="/tmp/logs_${ID}_${now}"
  27. UPDATE="/tmp/update${ID}_${now}"
  28. cat $LOG| grep '[[*]]' > $UPDATE
  29.         if [ $COUNT -gt 0 ];then
  30.                 echo "`tput setaf 3`Below are the updates recommended`tput sgr0`"
  31.                 cat $UPDATE|grep [*]
  32.                 export now
  33.                 export ID
  34.                 export LOG
  35.                 export location
  36.                 export -f function_in_background
  37.                 nohup bash -c flash &>>$log &
  38.  
  39.         else
  40.                 echo "There are no update..exiting"
  41.                 echo "                               "
  42.                 exit 0;
  43.  
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top