Commit ed038bdd authored by sokai's avatar sokai

better upgrade routine (install new version only if wget was successfully at first)

parent ca98bdd2
......@@ -134,34 +134,27 @@ update() {
upgrade() {
## self-upgrade of this script
NEWSCRIPT="/tmp/${SCRIPTNAME}"
# get and install new version
wget -q -O ${NEWSCRIPT} ${UPGRADEURL} 2>/dev/null
if [ -f ${NEWSCRIPT} ]; then
# remove current script
stop
disable
# install new script
chmod +x ${NEWSCRIPT}
mv ${NEWSCRIPT} ${SCRIPT}
enable
start
# 1. stop
stop
# 2. diable
disable
# 3. backup the orig. script
mv ${SCRIPT} /tmp/${SCRIPTNAME}
# 4. get and install new version
wget -q -O ${SCRIPT} $UPGRADEURL && chmod +x ${SCRIPT}
if [ -f ${SCRIPT} ]; then
VERSION=$(grep 'SCRIPTVERSION=' ${SCRIPT} -m 1 | cut -f2 -d'='|sed 's/ /%20/g'|sed "s/'//g")
SUCCESS="new version (${VERSION}) installed at ${SCRIPT} (${SCRIPT} upgrade)"
echo ${SUCCESS}
logger -t ${SCRIPTNAME} ${SUCCESS}
else
ERROR="couldn't download new version - old version at ${SCRIPT} re-enabled (${SCRIPT} upgrade)"
ERROR="couldn't download new version - current version remains at ${SCRIPT} (${SCRIPT} upgrade)"
echo ${ERROR}
logger -t ${SCRIPTNAME} ${ERROR}
mv /tmp/${SCRIPTNAME} ${SCRIPT}
fi
# 5. enable
enable
# 6. start
start
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment