mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-09 23:50:47 +02:00
Add updating to beta branch (#1339)
This commit is contained in:
@@ -41,9 +41,10 @@ usage()
|
|||||||
{
|
{
|
||||||
echo "Usage: $1 [OPTIONS]"
|
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 "$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 "Options:"
|
||||||
echo "-b (--backup) backup erased file (add extension ${BACKUPEXT} to the local file before ovewrite it) "
|
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 "-f (--force) force update"
|
||||||
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
|
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
|
||||||
echo "-p (--print) print action only, do nothing"
|
echo "-p (--print) print action only, do nothing"
|
||||||
@@ -206,6 +207,11 @@ do
|
|||||||
_PROGRESS=1;
|
_PROGRESS=1;
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-r | --branch)
|
||||||
|
BRANCH=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*|-h |\? | --help)
|
*|-h |\? | --help)
|
||||||
usage $0
|
usage $0
|
||||||
exit 1
|
exit 1
|
||||||
@@ -213,7 +219,7 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Starting AutoUpdate"
|
log "Starting AutoUpdate on branch ${BRANCH}"
|
||||||
|
|
||||||
if [ ${_FORCE} = 1 ]; then
|
if [ ${_FORCE} = 1 ]; then
|
||||||
log "Forcing update."
|
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"
|
action "rm -Rf ${DESTOVERRIDE}/* 2>/dev/null"
|
||||||
|
|
||||||
# Everythings was OK, save the date
|
# 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 ------------"
|
echo "--------------- Reboot ------------"
|
||||||
if [ ${_FORCEREBOOT} = 1 ]; then
|
if [ ${_FORCEREBOOT} = 1 ]; then
|
||||||
countdownreboot
|
countdownreboot
|
||||||
@@ -358,6 +365,7 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
|
echo -n $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
|
||||||
|
echo " ## ${BRANCH} branch" >> /system/sdcard/.lastCommitDate
|
||||||
echo "No files to update."
|
echo "No files to update."
|
||||||
fi
|
fi
|
||||||
|
@@ -571,6 +571,22 @@ if [ -n "$F_cmd" ]; then
|
|||||||
echo $processId
|
echo $processId
|
||||||
return
|
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)
|
show_updateProgress)
|
||||||
processId=$(ps | grep autoupdate.sh | grep -v grep)
|
processId=$(ps | grep autoupdate.sh | grep -v grep)
|
||||||
|
@@ -28,8 +28,10 @@
|
|||||||
$('#message').text("Error starting update process");
|
$('#message').text("Error starting update process");
|
||||||
}
|
}
|
||||||
$('#start').removeAttr('disabled');
|
$('#start').removeAttr('disabled');
|
||||||
|
$('#startBeta').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
$('#start').attr("disabled", "disabled");
|
$('#start').attr("disabled", "disabled");
|
||||||
|
$('#startBeta').attr("disabled", "disabled");
|
||||||
$('#message').text("Update in progress");
|
$('#message').text("Update in progress");
|
||||||
$('#progress').val(log);
|
$('#progress').val(log);
|
||||||
// This is the end, start the reboot count down
|
// This is the end, start the reboot count down
|
||||||
@@ -55,13 +57,37 @@
|
|||||||
}).done(function(result) {
|
}).done(function(result) {
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
$('#start').attr("disabled", "disabled");
|
$('#start').attr("disabled", "disabled");
|
||||||
|
$('#startBeta').attr("disabled", "disabled");
|
||||||
update(false);
|
update(false);
|
||||||
} else {
|
} else {
|
||||||
$('#message').text("Error starting update progress");
|
$('#message').text("Error starting update progress");
|
||||||
$('#start').removeAttr('disabled');
|
$('#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>
|
</script>
|
||||||
|
|
||||||
<div class='card status_card'>
|
<div class='card status_card'>
|
||||||
@@ -72,15 +98,20 @@
|
|||||||
<div class="field is-horizontal">
|
<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>
|
<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>
|
||||||
<div class="field is-horizontal">
|
<div class='card-content'>
|
||||||
<div class="field-body">
|
<div class="columns">
|
||||||
<div class="field">
|
<div class="column">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input id="start" class="button is-primary" type="submit" value="Update firmware" onclick="start()" />
|
<input id="start" class="button is-primary" type="submit" value="Update firmware (stable)" onclick="start()" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="column">
|
||||||
</div>
|
<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>
|
<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>
|
<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>
|
<h1 id=message class="title is-1 has-text-centered"></h1>
|
||||||
|
Reference in New Issue
Block a user