Skip to content

Commit

Permalink
Update autoupdate.sh (EliasKotlyar#482)
Browse files Browse the repository at this point in the history
When the script is not started in /system/sdcard folder, the files are created whatever the status of the local file
  • Loading branch information
nik0 authored and jmtatsch committed Jun 17, 2018
1 parent b76ed0a commit caf1cb3
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions firmware_mod/autoupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ logerror ()
# Log string on std error
progress()
{
if [ ${_PROGRESS} -eq 1 ]; then
_NBFILES=$((${_NBFILES} + 1))
echo -n $((${_NBFILES} *100 / ${_NBTOTALFILES} )) > /tmp/progress
if [ ${_PROGRESS} -eq 1 ]; then
_NBFILES=$((${_NBFILES} + 1))
echo -n $((${_NBFILES} *100 / ${_NBTOTALFILES} )) > /tmp/progress
# echo "file = ${_NBFILES}, total=${_NBTOTALFILES} = $((${_NBFILES} *100 / ${_NBTOTALFILES} ))"
fi
fi
}

##########################################################################
Expand Down Expand Up @@ -161,11 +161,9 @@ countdownreboot()
while [ ${i} -gt 0 ];
do
echo "$i seconds remaining before reboot (Press control-c to abort)";
i=$((${i} - 1))
i=$((${i} - 1))
sleep 1;
done
action sync
action sync
action reboot
}
##########################################################################
Expand Down Expand Up @@ -262,12 +260,11 @@ do
echo "Can not get remote file $i, exiting."
exit 1
fi

# Check the file exists in local
if [ -f "${LOCALFILE}" ]; then
if [ -f "${DESTFOLDER}/${LOCALFILE}" ]; then
REMOTESHA=$(${SHA} ${TMPFILE} 2>/dev/null | cut -d "=" -f 2)
# Calculate the remote and local SHA
LOCALSHA=$(${SHA} ${LOCALFILE} 2>/dev/null | cut -d "=" -f 2)
LOCALSHA=$(${SHA} ${DESTFOLDER}${LOCALFILE} 2>/dev/null | cut -d "=" -f 2)

# log "SHA of $LOCALFILE is ${LOCALSHA} ** remote is ${REMOTESHA}"
if [ "${REMOTESHA}" = "${LOCALSHA}" ] ; then
Expand All @@ -277,20 +274,20 @@ do
echo "${LOCALFILE} updated."
action "mkdir -p $(dirname ${DESTOVERRIDE}/${LOCALFILE}) 2>/dev/null"
if [ ${_BACKUP} = 1 ]; then
action cp ${LOCALFILE} ${DESTOVERRIDE}/${LOCALFILE}${BACKUPEXT}
action cp ${DESTFOLDER}${LOCALFILE} ${DESTOVERRIDE}/${LOCALFILE}${BACKUPEXT}
fi
action mv ${TMPFILE} ${DESTOVERRIDE}/${LOCALFILE}
else
echo "${LOCALFILE} needs to be updated. Overwrite?"
echo "[Y]es or [N]o or [A]ll?"
echo "[Y]es or [N]o or [A]ll?"
rep=$(ask_yes_or_no )
if [ "${rep}" = "no" ]; then
echo "${LOCALFILE} not updated"
rm -f ${TMPFILE} 2>/dev/null
else
action "mkdir -p $(dirname ${DESTOVERRIDE}/${LOCALFILE}) 2>/dev/null"
if [ ${_BACKUP} = 1 ]; then
action cp ${LOCALFILE} ${DESTOVERRIDE}/${LOCALFILE}${BACKUPEXT}
action cp ${DESTFOLDER}${LOCALFILE} ${DESTOVERRIDE}/${LOCALFILE}${BACKUPEXT}
fi
action mv ${TMPFILE} ${DESTOVERRIDE}/${LOCALFILE}

Expand All @@ -307,7 +304,7 @@ do
action mv ${TMPFILE} ${DESTOVERRIDE}/${LOCALFILE}
else
echo "${LOCALFILE} doesn't exist, create it?"
echo "[Y]es or [N]o or [A]ll ?"
echo "[Y]es or [N]o or [A]ll ?"
rep=$(ask_yes_or_no )
if [ "${rep}" = "no" ]; then
echo "${LOCALFILE} not created."
Expand All @@ -331,8 +328,8 @@ fi
if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) > 1 ]; then
echo "--------------- Stopping services ---------"
for i in /system/sdcard/controlscripts/*; do
echo stopping $i
$i stop &> /dev/null
echo stopping $i
$i stop &> /dev/null
done
pkill lighttpd.bin 2> /dev/null
pkill bftpd 2> /dev/null
Expand All @@ -348,7 +345,7 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
countdownreboot
else
echo "A reboot is needed, do you want to reboot now?"
echo "[Y]es or [N]o"
echo "[Y]es or [N]o"
rep=$(ask_yes_or_no )
if [ "${rep}" = "yes" ]; then
countdownreboot
Expand Down

0 comments on commit caf1cb3

Please sign in to comment.