Created
August 31, 2014 17:17
-
-
Save drscream/b5f509dcbd66d75e7871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Simple bash script to update all mibe images (folders) to the new base mibe | |
## image. | |
## Thomas Merkel <[email protected]> | |
## | |
## PARAM | |
## | |
UUID=${1} | |
MI=${2} | |
## | |
## GLOBAL VAR | |
## | |
_color_red=$(tput setaf 160) | |
_color_green=$(tput setaf 64) | |
_color_orange=$(tput setaf 166) | |
_color_reset=$(tput sgr0) | |
## | |
## FUNCTION | |
## | |
function update() { | |
local uuid=${1} | |
local mi=${2} | |
if [[ $(grep -c 'base=' ${mi}/manifest) -eq 0 ]]; then | |
echo "${_color_orange}[${mi}]${_color_reset} skip because of no base image used" | |
else | |
echo "${_color_green}[${mi}]${_color_reset} update to base image version: ${uuid}" | |
sed -i 's:base=.*:base="'${uuid}'":g' ${mi}/manifest | |
( | |
cd ${mi} | |
git add manifest | |
git commit -m "update to new core-base image: ${uuid}" | |
git push mibed | |
if [ ${?} -eq 0 ]; then | |
git push | |
fi | |
) | |
fi | |
} | |
## | |
## MAIN | |
## | |
if [ $# -lt 1 ]; then | |
echo "${0} <UUID> [MI FOLDER]" | |
exit | |
fi | |
if [ -z ${MI} ]; then | |
for mi in mi-core*; do | |
[[ ! -d ${mi} ]] && continue | |
[[ ${mi} == "mi-core-base" ]] && continue | |
update ${UUID} ${mi} | |
done | |
else | |
update ${UUID} ${MI} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment