General TC > Programming & Scripting - Unofficial
alternative to upgrade_tce.sh
(1/1)
SvOlli:
Hello,
I've hacked up an alternative to the upgrade_tce.sh script that takes a slightly different approach.
Instead of booting in a "failsafe" mode, I just upgrade the files in the tce directory, so the updated packages will be loaded only after a reboot.
I hope, it's useful for someone here. It's also attached for easier downloading.
Greetings,
SvOlli
--- Code: (update-tce.sh) ---#!/bin/sh
tmpdir=/tmp/update.tce
tcedir="$(cat /opt/.tce_dir)"
export $(sed 's/: /=/' </opt/.tcrc)
baseurl="${Protocol}://${Mirror}"
. /etc/init.d/tc-functions
check()
{
p=${4%.md5.txt}
wget -q -c ${2}/${3}/${4} 2>/dev/null
if [ ! -f ${4} ]; then
echo ${1}/${p} ${RED}not found${NORMAL}
return
fi
if cmp -s ${1}/${4} ${4}; then
echo ${1}/${p} ${GREEN}current${NORMAL}
else
wget -c ${2}/${3}/${p}
rm ${1}/${p} ${1}/${4}
mv ${p} ${4} ${1}
echo ${1}/${p} ${YELLOW}updated${NORMAL}
fi
}
tceget()
{
for i in $(cd ${1};echo *.md5.txt); do
case ${i} in
*.tce*) check ${1} ${baseurl} tce ${i} ;;
*.tcz*) check ${1} ${baseurl} tcz ${i} ;;
*) echo ${RED}${i} unknown${NORMAL};;
esac
done
}
mkdir -p ${tmpdir}
cd ${tmpdir}
[ -d ${tcedir} ] && tceget ${tcedir}
[ -d ${tcedir}/optional ] && tceget ${tcedir}/optional
cd ..
rm -r ${tmpdir}
--- End code ---
curaga:
This should only be used for TCE type packages. Even though overwriting a mounted file should be safe, it's really bad practise to do.
SvOlli:
It is intended for updating .tce and .tcz. By removing the .tcz (or .tce) first it is made sure, that the new .tcz is a different file. Once the old one's been unmounted, the memory is freed as well. So the main topic here is that the storage consumption using .tcz's is old.tcz + new.tcz instead of just new.tcz. I think it's a better way to go instead of trying to unmount an .tcz that might have open filedescriptors itself. Also a reboot is assumed afterwards, which should do the cleanup anyway.
Navigation
[0] Message Index
Go to full version