File update.sh of Package rke
#!/bin/bash
rc=0
prj=rke
prjdir=$(dirname $0)
# go to projekt dir
cd $prjdir
# download latest software
mkdir ${prj}-x.x.x && curl -s -o ${prj}-x.x.x/${prj} -L https://github.com/rancher/rke/releases/latest/download/rke_linux-amd64 && chmod 755 ${prj}-x.x.x/${prj}
if [ $? -eq 0 ] ; then
# retrieve current version info and cut off any leading "v" (or other letters)
versionstr=$(${prj}-x.x.x/${prj} --version |awk '{ print $3}') && \
version="${versionstr#[^0-9]*}"
if [ -n "$version" ] ; then
currentver="$(grep -Ee "^Version:[[:space:]]+${version}\$" ${prj}.spec)"
if [ $? -ne 0 ] ; then
mv ${prj}-x.x.x ${prj}-$version && \
tar -cjf ${prj}-${version}.tar.bz2 ${prj}-${version} && \
rm -rf ${prj}-${version} && \
sed -i "s/^Version:.*$/Version: $version/" ${prj}.spec
if [ $? -eq 0 ] ; then
echo "$0: updated project to version ${version}. Done." >&2
osc add ${prj}-${version}.tar.bz2
osc commit -m "updated to version ${version}"
rc=0
else
echo "$0: could not update project to version ${version}. Aborting." >&2
rc=3
fi
else
echo "$0: project already is at version ${version}. Done."
rm -rf ${prj}-x.x.x
rc=0
fi
else
echo "$0: could not retrieve current version info. Aborting." >&2
rc=2
fi
else
echo "$0: could not download latest binary. Aborting." >&2
rc=1
fi
exit $rc