Skip to content
Snippets Groups Projects
Commit b2f76eda authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add detection if download is an update

parent db6791cc
Branches
No related tags found
No related merge requests found
...@@ -58,6 +58,9 @@ function setprofile(){ ...@@ -58,6 +58,9 @@ function setprofile(){
exit 12 exit 12
fi fi
echo "OK, profile [${profile}] was set." echo "OK, profile [${profile}] was set."
downloadfile="${tmpdir}/${IMLCI_PROJECT}.tgz"
downloadtmp="${tmpdir}/${IMLCI_PROJECT}.tgz.tmp"
} }
# output a colored infoline with date and given message # output a colored infoline with date and given message
...@@ -65,15 +68,15 @@ function setprofile(){ ...@@ -65,15 +68,15 @@ function setprofile(){
function header(){ function header(){
local COLOR="\033[34m" local COLOR="\033[34m"
local NO_COLOR="\033[0m" local NO_COLOR="\033[0m"
echo
echo -en "${COLOR}" echo -en "${COLOR}"
echo ______________________________________________________________________ echo ______________________________________________________________________
echo
echo -n ">>>>>>>>>> $(date) " echo -n ">>>>>>>>>> $(date) "
test ! -z "$profile" && echo -n "${profile} :: " test ! -z "$profile" && echo -n "${profile} :: "
echo -n " - $* " echo -n "$*"
echo -en "${NO_COLOR}" echo -en "${NO_COLOR}"
if [ "$wait" = "1" ]; then if [ "$wait" = "1" ]; then
echo -n "RETURN"; read dummy; echo -n " RETURN"; read dummy;
fi fi
echo echo
} }
...@@ -84,9 +87,11 @@ function header(){ ...@@ -84,9 +87,11 @@ function header(){
function run_task(){ function run_task(){
local taskscript=$1 local taskscript=$1
if [ -x "${taskscript}" ]; then if [ -x "${taskscript}" ]; then
echo "INFO: starting script ${taskscript}..."
. "${taskscript}" || exit 10 . "${taskscript}" || exit 10
else else
echo "SKIP: task script ${taskscript} does not exist." test -f "${taskscript}" && ( echo "SKIP: task script ${taskscript} is not executable." ; ls -l "${taskscript}")
test -f "${taskscript}" || echo "SKIP: task script ${taskscript} does not exist."
fi fi
} }
...@@ -96,11 +101,6 @@ function run_task(){ ...@@ -96,11 +101,6 @@ function run_task(){
cd $( dirname $0 ) cd $( dirname $0 )
echo
echo
echo "<<<<<<<<<<##########| POC :: DEPLOYMENT SCRIPT |##########>>>>>>>>>>"
echo
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
header "looping over all profiles" header "looping over all profiles"
getprofiles getprofiles
...@@ -109,9 +109,17 @@ if [ $# -eq 0 ]; then ...@@ -109,9 +109,17 @@ if [ $# -eq 0 ]; then
do do
$0 $myprofile $0 $myprofile
done done
rc=$?
profile=
header "loop over projects is finished"
exit $? exit $?
fi fi
echo
echo
echo "<<<<<<<<<<##########| POC :: DEPLOYMENT SCRIPT |##########>>>>>>>>>>"
echo
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
header "Set profile [$1]" header "Set profile [$1]"
...@@ -120,15 +128,34 @@ setprofile $1 ...@@ -120,15 +128,34 @@ setprofile $1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
header "Download ${IMLCI_PROJECT}.tgz" header "Download ${IMLCI_PROJECT}.tgz"
cd $tmpdir isupdate=0
${selfdir}/bin/getfile.sh -f ${IMLCI_PROJECT}.tgz || exit 1 ${selfdir}/bin/getfile.sh -f ${IMLCI_PROJECT}.tgz -o ${downloadtmp} || exit 1
# ----------------------------------------------------------------------
header "Detect if download is newer than last download."
if [ -f ${downloadfile} ]; then
# ls -l "${downloadfile}" "${downloadtmp}"
diff "${downloadfile}" "${downloadtmp}"
if [ $? -eq 0 ]; then
echo "INFO: the downloaded file is the same like last download."
rm -f "${downloadtmp}"
else
echo "OK: donwload contains an update."
isupdate=1
mv "${downloadtmp}" "${downloadfile}"
fi
else
echo "INFO: last download not available - first install or a forced update."
isupdate=1
mv "${downloadtmp}" "${downloadfile}"
fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
header "Go into install dir ${installdir}" header "Switch into install dir ${installdir} ..."
test -d "${installdir}" || mkdir -p "${installdir}" test -d "${installdir}" || mkdir -p "${installdir}"
cd ${installdir} || exit 2 cd ${installdir} || exit 2
pwd
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -141,14 +168,14 @@ run_task "${profiledir}/tasks_preinstall.sh" ...@@ -141,14 +168,14 @@ run_task "${profiledir}/tasks_preinstall.sh"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
header "Extract ${IMLCI_PROJECT}.tgz" header "Extract ${IMLCI_PROJECT}.tgz into $( pwd )"
tar -xzf ${tmpdir}/${IMLCI_PROJECT}.tgz . || exit 3 tar -xzf ${tmpdir}/${IMLCI_PROJECT}.tgz . || exit 3
ls -l ls -l
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
header "Remove download archive ${IMLCI_PROJECT}.tgz" # header "Remove download archive ${IMLCI_PROJECT}.tgz"
echo rm -f ${IMLCI_PROJECT}.tgz # echo rm -f ${IMLCI_PROJECT}.tgz
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment