Skip to content

Commit 2a16624

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0aac42b + 8947c91 commit 2a16624

3 files changed

Lines changed: 68 additions & 13 deletions

File tree

firmware_mod/autoupdate.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ usage()
4141
{
4242
echo "Usage: $1 [OPTIONS]"
4343
echo "$1 will update a local folder with the ${REPO} github repo (first copy all the files in ${DESTOVERRIDE}, stop services and reboot"
44-
echo "Usage this script to update the ${REPO} github repo from ${BRANCH} branch"
44+
echo "Usage this script to update the ${REPO} github repo from ${BRANCH} (default) branch"
4545
echo "Options:"
4646
echo "-b (--backup) backup erased file (add extension ${BACKUPEXT} to the local file before ovewrite it) "
47+
echo "-r (--branch) to set the branch"
4748
echo "-f (--force) force update"
4849
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
4950
echo "-p (--print) print action only, do nothing"
@@ -206,14 +207,19 @@ do
206207
_PROGRESS=1;
207208
shift
208209
;;
210+
-r | --branch)
211+
BRANCH=$2
212+
shift
213+
shift
214+
;;
209215
*|-h |\? | --help)
210216
usage $0
211217
exit 1
212218
;;
213219
esac
214220
done
215221

216-
log "Starting AutoUpdate"
222+
log "Starting AutoUpdate on branch ${BRANCH}"
217223

218224
if [ ${_FORCE} = 1 ]; then
219225
log "Forcing update."
@@ -345,7 +351,8 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
345351
action "rm -Rf ${DESTOVERRIDE}/* 2>/dev/null"
346352

347353
# Everythings was OK, save the date
348-
echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
354+
echo -n $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
355+
echo " ## ${BRANCH} branch" >> /system/sdcard/.lastCommitDate
349356
echo "--------------- Reboot ------------"
350357
if [ ${_FORCEREBOOT} = 1 ]; then
351358
countdownreboot
@@ -358,6 +365,7 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
358365
fi
359366
fi
360367
else
361-
echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
368+
echo -n $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
369+
echo " ## ${BRANCH} branch" >> /system/sdcard/.lastCommitDate
362370
echo "No files to update."
363371
fi

firmware_mod/www/cgi-bin/action.cgi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,22 @@ if [ -n "$F_cmd" ]; then
571571
echo $processId
572572
return
573573
;;
574+
betaupdate)
575+
processId=$(ps | grep autoupdate.sh | grep -v grep)
576+
if [ "$processId" == "" ]
577+
then
578+
echo "===============" >> /system/sdcard/log/update.log
579+
date >> /var/log/update.log
580+
if [ "$F_login" != "" ]; then
581+
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f -r beta -u $F_login >> "/system/sdcard/log/update.log" &
582+
else
583+
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f -r beta >> "/system/sdcard/log/update.log" &
584+
fi
585+
processId=$(ps | grep autoupdate.sh | grep -v grep)
586+
fi
587+
echo $processId
588+
return
589+
;;
574590

575591
show_updateProgress)
576592
processId=$(ps | grep autoupdate.sh | grep -v grep)

firmware_mod/www/update.html

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
$('#message').text("Error starting update process");
2929
}
3030
$('#start').removeAttr('disabled');
31+
$('#startBeta').removeAttr('disabled');
3132
} else {
3233
$('#start').attr("disabled", "disabled");
34+
$('#startBeta').attr("disabled", "disabled");
3335
$('#message').text("Update in progress");
3436
$('#progress').val(log);
3537
// This is the end, start the reboot count down
@@ -55,13 +57,37 @@
5557
}).done(function(result) {
5658
if (result.length > 0) {
5759
$('#start').attr("disabled", "disabled");
60+
$('#startBeta').attr("disabled", "disabled");
5861
update(false);
5962
} else {
6063
$('#message').text("Error starting update progress");
6164
$('#start').removeAttr('disabled');
65+
$('#startBeta').removeAttr('disabled');
6266
}
6367
});
6468
}
69+
function startBeta() {
70+
var login = ""
71+
// if ($('#login').val().length > 0) {
72+
// login = "login=" + $('#login').val() + ":" + $('#password').val();
73+
// }
74+
$.ajax({
75+
'url': 'cgi-bin/action.cgi?cmd=betaupdate',
76+
'type': 'POST',
77+
'data': login
78+
}).done(function(result) {
79+
if (result.length > 0) {
80+
$('#start').attr("disabled", "disabled");
81+
$('#startBeta').attr("disabled", "disabled");
82+
update(false);
83+
} else {
84+
$('#message').text("Error starting update progress");
85+
$('#start').removeAttr('disabled');
86+
$('#startBeta').removeAttr('disabled');
87+
}
88+
});
89+
}
90+
6591
</script>
6692

6793
<div class='card status_card'>
@@ -72,15 +98,20 @@
7298
<div class="field is-horizontal">
7399
<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>
74100
</div>
75-
<div class="field is-horizontal">
76-
<div class="field-body">
77-
<div class="field">
78-
<div class="control">
79-
<input id="start" class="button is-primary" type="submit" value="Update firmware" onclick="start()" />
80-
</div>
81-
</div>
82-
</div>
83-
</div>
101+
<div class='card-content'>
102+
<div class="columns">
103+
<div class="column">
104+
<div class="control">
105+
<input id="start" class="button is-primary" type="submit" value="Update firmware (stable)" onclick="start()" />
106+
</div>
107+
</div>
108+
<div class="column">
109+
<div class="control">
110+
<input id="startBeta" class="button is-light" type="submit" value="Update firmware (beta)" onclick="startBeta()" />
111+
</div>
112+
</div>
113+
</div>
114+
</div>
84115
<h4 class="title is-4">Please note: at the end of this process the camera will reboot without notice</h4>
85116
<progress id=progress name=progress class="progress is-danger" value=0 max="100"></progress>
86117
<h1 id=message class="title is-1 has-text-centered"></h1>

0 commit comments

Comments
 (0)