Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Define all BAL apps to be upgraded here |
| 4 | FILELIST=('bcm.user' 'linux-kernel-bde.ko' 'linux-user-bde.ko' 'bcm88470_board.soc' 'combo28_dram.soc' 'config.bcm' 'init.sh' 'qax.soc' 'rc.soc') |
| 5 | #JENKINSSERVER='jenkins-tlva-06.il.broadcom.com' |
| 6 | JENKINSSERVER='10.187.130.172' |
| 7 | ING_SDK_VER='6.5.6' |
| 8 | |
| 9 | mkdir -p old |
| 10 | |
| 11 | JENKINSPATH1="http://${JENKINSSERVER}/job/Bal.Synced.bcm-sdk-${ING_SDK_VER}/lastSuccessfulBuild/artifact/bal/cur/" |
| 12 | JENKINSFILE1=( |
| 13 | '3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/bcm.user' |
| 14 | '3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/linux-kernel-bde.ko' |
| 15 | '3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/linux-user-bde.ko' |
| 16 | '3rdparty/bcm-sdk/rc/qax/bcm88470_board.soc' |
| 17 | '3rdparty/bcm-sdk/rc/qax/combo28_dram.soc' |
| 18 | '3rdparty/bcm-sdk/rc/qax/config.bcm' |
| 19 | '3rdparty/bcm-sdk/rc/qax/init.sh' |
| 20 | '3rdparty/bcm-sdk/rc/qax/qax.soc' |
| 21 | '3rdparty/bcm-sdk/rc/qax/rc.soc' |
| 22 | ) |
| 23 | |
| 24 | |
| 25 | function coloredEcho(){ |
| 26 | local exp=$1; |
| 27 | local color=$2; |
| 28 | if ! [[ $color =~ '^[0-9]$' ]] ; then |
| 29 | case $(echo $color | tr '[:upper:]' '[:lower:]') in |
| 30 | black) color=0 ;; |
| 31 | red) color=1 ;; |
| 32 | green) color=2 ;; |
| 33 | yellow) color=3 ;; |
| 34 | blue) color=4 ;; |
| 35 | magenta) color=5 ;; |
| 36 | cyan) color=6 ;; |
| 37 | white|*) color=7 ;; # white or invalid color |
| 38 | esac |
| 39 | fi |
| 40 | tput setaf $color; |
| 41 | echo $exp; |
| 42 | tput sgr0; |
| 43 | } |
| 44 | |
| 45 | function check_return(){ |
| 46 | echo -n "$1... " |
| 47 | $($2) |
| 48 | if [ $? -eq 0 ]; then |
| 49 | coloredEcho '[ OK ]' green |
| 50 | else |
| 51 | coloredEcho '[ ERROR ]' red |
| 52 | fi |
| 53 | } |
| 54 | |
| 55 | # Checking connectivity to Jenkins Server |
| 56 | echo -n "Verifing Connectivity to Jenkins... " |
| 57 | ping -c 1 ${JENKINSSERVER} &> /dev/null |
| 58 | if [ $? -eq 0 ]; then |
| 59 | coloredEcho '[ OK ]' green |
| 60 | else |
| 61 | coloredEcho '[ ERROR ]' red |
| 62 | echo 'Aborting Upgrade!' |
| 63 | exit 0 |
| 64 | fi |
| 65 | |
| 66 | # delete any old versions |
| 67 | echo 'Deleting older versions...' |
| 68 | for FILE in ${FILELIST[@]} |
| 69 | do |
| 70 | check_return "Deleting ${FILE}.old" "rm -f old/${FILE}.old" |
| 71 | done |
| 72 | |
| 73 | # rename the existing versions |
| 74 | echo 'Renaming last version x.old ...' |
| 75 | for FILE in ${FILELIST[@]} |
| 76 | do |
| 77 | check_return "Moving ${FILE} to ${FILE}.old" "mv ${FILE} old/${FILE}.old" |
| 78 | done |
| 79 | |
| 80 | # Get the new versions |
| 81 | echo 'Downloading ING version '${ING_SDK_VER}'...' |
| 82 | for FILE in ${JENKINSFILE1[@]} |
| 83 | do |
| 84 | COMMAND="wget -q ${JENKINSPATH1}${FILE}" |
| 85 | SHORTFILE=$(echo ${FILE} | sed 's:.*/::') |
| 86 | check_return "Getting Latest ${SHORTFILE}" "${COMMAND}" |
| 87 | done |
| 88 | |
| 89 | # Changing permissions to executable |
| 90 | echo 'Changing permissions to executable...' |
| 91 | for FILE in ${FILELIST[@]} |
| 92 | do |
| 93 | check_return "Makiing ${FILE} executable" "chmod 755 ${FILE}" |
| 94 | done |
| 95 | |
| 96 | echo 'Upgrade Complete' |