blob: 8b8b61d4a3bc9355e3f77c8a2e33ab4057c1362f [file] [log] [blame]
#!/bin/bash
# Define all BAL apps to be upgraded here
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')
#JENKINSSERVER='jenkins-tlva-06.il.broadcom.com'
JENKINSSERVER='10.187.130.172'
ING_SDK_VER='6.5.6'
mkdir -p old
JENKINSPATH1="http://${JENKINSSERVER}/job/Bal.Synced.bcm-sdk-${ING_SDK_VER}/lastSuccessfulBuild/artifact/bal/cur/"
JENKINSFILE1=(
'3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/bcm.user'
'3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/linux-kernel-bde.ko'
'3rdparty/bcm-sdk/build/sdk-all-'${ING_SDK_VER}'/build/linux/user/wrx-3_7/linux-user-bde.ko'
'3rdparty/bcm-sdk/rc/qax/bcm88470_board.soc'
'3rdparty/bcm-sdk/rc/qax/combo28_dram.soc'
'3rdparty/bcm-sdk/rc/qax/config.bcm'
'3rdparty/bcm-sdk/rc/qax/init.sh'
'3rdparty/bcm-sdk/rc/qax/qax.soc'
'3rdparty/bcm-sdk/rc/qax/rc.soc'
)
function coloredEcho(){
local exp=$1;
local color=$2;
if ! [[ $color =~ '^[0-9]$' ]] ; then
case $(echo $color | tr '[:upper:]' '[:lower:]') in
black) color=0 ;;
red) color=1 ;;
green) color=2 ;;
yellow) color=3 ;;
blue) color=4 ;;
magenta) color=5 ;;
cyan) color=6 ;;
white|*) color=7 ;; # white or invalid color
esac
fi
tput setaf $color;
echo $exp;
tput sgr0;
}
function check_return(){
echo -n "$1... "
$($2)
if [ $? -eq 0 ]; then
coloredEcho '[ OK ]' green
else
coloredEcho '[ ERROR ]' red
fi
}
# Checking connectivity to Jenkins Server
echo -n "Verifing Connectivity to Jenkins... "
ping -c 1 ${JENKINSSERVER} &> /dev/null
if [ $? -eq 0 ]; then
coloredEcho '[ OK ]' green
else
coloredEcho '[ ERROR ]' red
echo 'Aborting Upgrade!'
exit 0
fi
# delete any old versions
echo 'Deleting older versions...'
for FILE in ${FILELIST[@]}
do
check_return "Deleting ${FILE}.old" "rm -f old/${FILE}.old"
done
# rename the existing versions
echo 'Renaming last version x.old ...'
for FILE in ${FILELIST[@]}
do
check_return "Moving ${FILE} to ${FILE}.old" "mv ${FILE} old/${FILE}.old"
done
# Get the new versions
echo 'Downloading ING version '${ING_SDK_VER}'...'
for FILE in ${JENKINSFILE1[@]}
do
COMMAND="wget -q ${JENKINSPATH1}${FILE}"
SHORTFILE=$(echo ${FILE} | sed 's:.*/::')
check_return "Getting Latest ${SHORTFILE}" "${COMMAND}"
done
# Changing permissions to executable
echo 'Changing permissions to executable...'
for FILE in ${FILELIST[@]}
do
check_return "Makiing ${FILE} executable" "chmod 755 ${FILE}"
done
echo 'Upgrade Complete'