1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-09 07:30:57 +02:00

Add updating to beta branch (#1339)

This commit is contained in:
nik0
2020-04-08 13:41:08 +02:00
committed by GitHub
parent be2cb151c0
commit 8947c91864
3 changed files with 68 additions and 13 deletions

View File

@@ -41,9 +41,10 @@ usage()
{
echo "Usage: $1 [OPTIONS]"
echo "$1 will update a local folder with the ${REPO} github repo (first copy all the files in ${DESTOVERRIDE}, stop services and reboot"
echo "Usage this script to update the ${REPO} github repo from ${BRANCH} branch"
echo "Usage this script to update the ${REPO} github repo from ${BRANCH} (default) branch"
echo "Options:"
echo "-b (--backup) backup erased file (add extension ${BACKUPEXT} to the local file before ovewrite it) "
echo "-r (--branch) to set the branch"
echo "-f (--force) force update"
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
echo "-p (--print) print action only, do nothing"
@@ -206,6 +207,11 @@ do
_PROGRESS=1;
shift
;;
-r | --branch)
BRANCH=$2
shift
shift
;;
*|-h |\? | --help)
usage $0
exit 1
@@ -213,7 +219,7 @@ do
esac
done
log "Starting AutoUpdate"
log "Starting AutoUpdate on branch ${BRANCH}"
if [ ${_FORCE} = 1 ]; then
log "Forcing update."
@@ -345,7 +351,8 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
action "rm -Rf ${DESTOVERRIDE}/* 2>/dev/null"
# Everythings was OK, save the date
echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo -n $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo " ## ${BRANCH} branch" >> /system/sdcard/.lastCommitDate
echo "--------------- Reboot ------------"
if [ ${_FORCEREBOOT} = 1 ]; then
countdownreboot
@@ -358,6 +365,7 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
fi
fi
else
echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo -n $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo " ## ${BRANCH} branch" >> /system/sdcard/.lastCommitDate
echo "No files to update."
fi

View File

@@ -571,6 +571,22 @@ if [ -n "$F_cmd" ]; then
echo $processId
return
;;
betaupdate)
processId=$(ps | grep autoupdate.sh | grep -v grep)
if [ "$processId" == "" ]
then
echo "===============" >> /system/sdcard/log/update.log
date >> /var/log/update.log
if [ "$F_login" != "" ]; then
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f -r beta -u $F_login >> "/system/sdcard/log/update.log" &
else
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f -r beta >> "/system/sdcard/log/update.log" &
fi
processId=$(ps | grep autoupdate.sh | grep -v grep)
fi
echo $processId
return
;;
show_updateProgress)
processId=$(ps | grep autoupdate.sh | grep -v grep)

View File

@@ -28,8 +28,10 @@
$('#message').text("Error starting update process");
}
$('#start').removeAttr('disabled');
$('#startBeta').removeAttr('disabled');
} else {
$('#start').attr("disabled", "disabled");
$('#startBeta').attr("disabled", "disabled");
$('#message').text("Update in progress");
$('#progress').val(log);
// This is the end, start the reboot count down
@@ -55,13 +57,37 @@
}).done(function(result) {
if (result.length > 0) {
$('#start').attr("disabled", "disabled");
$('#startBeta').attr("disabled", "disabled");
update(false);
} else {
$('#message').text("Error starting update progress");
$('#start').removeAttr('disabled');
$('#startBeta').removeAttr('disabled');
}
});
}
function startBeta() {
var login = ""
// if ($('#login').val().length > 0) {
// login = "login=" + $('#login').val() + ":" + $('#password').val();
// }
$.ajax({
'url': 'cgi-bin/action.cgi?cmd=betaupdate',
'type': 'POST',
'data': login
}).done(function(result) {
if (result.length > 0) {
$('#start').attr("disabled", "disabled");
$('#startBeta').attr("disabled", "disabled");
update(false);
} else {
$('#message').text("Error starting update progress");
$('#start').removeAttr('disabled');
$('#startBeta').removeAttr('disabled');
}
});
}
</script>
<div class='card status_card'>
@@ -72,15 +98,20 @@
<div class="field is-horizontal">
<p>You can replace the running firmware on this camera by the latest available from its <a target='_blank' href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks">Github repository</a>. Settings will be retained after update.</p>
</div>
<div class="field is-horizontal">
<div class="field-body">
<div class="field">
<div class="control">
<input id="start" class="button is-primary" type="submit" value="Update firmware" onclick="start()" />
</div>
</div>
</div>
</div>
<div class='card-content'>
<div class="columns">
<div class="column">
<div class="control">
<input id="start" class="button is-primary" type="submit" value="Update firmware (stable)" onclick="start()" />
</div>
</div>
<div class="column">
<div class="control">
<input id="startBeta" class="button is-light" type="submit" value="Update firmware (beta)" onclick="startBeta()" />
</div>
</div>
</div>
</div>
<h4 class="title is-4">Please note: at the end of this process the camera will reboot without notice</h4>
<progress id=progress name=progress class="progress is-danger" value=0 max="100"></progress>
<h1 id=message class="title is-1 has-text-centered"></h1>