mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-02 12:43:02 +02:00
Allow custom firmware repositories (#1651)
* Add repo option to autoupdate.sh * Fix repo option in autoupdate.sh * Use local repo when checking for updates * Use default repo if non given in VERSION file in autoupdates.sh * Pass custom repo to web ui and update cgi * Add custom firmware update to web ui * Fix update messages * Fix update start arguments * Fix update input labels * Add custom upgrade button when on custom firmware
This commit is contained in:
@@ -48,6 +48,7 @@ usage()
|
||||
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 "-x (--repo) to set the repo"
|
||||
echo "-r (--branch) to set the branch"
|
||||
echo "-f (--force) force update"
|
||||
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
|
||||
@@ -169,7 +170,7 @@ countdownreboot()
|
||||
# Generate VERSION file
|
||||
generateVersionFile ()
|
||||
{
|
||||
echo "{\"date\":\"${REMOTECOMMITDATE}\",\"branch\":\"${BRANCH}\",\"commit\":\"${REMOTECOMMITID}\"}" > $VERSION_FILE
|
||||
echo "{\"date\":\"${REMOTECOMMITDATE}\",\"repo\":\"${REPO}\",\"branch\":\"${BRANCH}\",\"commit\":\"${REMOTECOMMITID}\"}" > $VERSION_FILE
|
||||
}
|
||||
##########################################################################
|
||||
# Curl with optional authentication
|
||||
@@ -228,6 +229,11 @@ do
|
||||
_PROGRESS=1;
|
||||
shift
|
||||
;;
|
||||
-x | --repo)
|
||||
REPO=$2;
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-r | --branch)
|
||||
BRANCH=$2
|
||||
shift
|
||||
@@ -263,15 +269,22 @@ fi
|
||||
action "rm -rf ${DESTOVERRIDE} 2>/dev/null"
|
||||
|
||||
if [ -f "$VERSION_FILE" ]; then
|
||||
LOCALCOMMITID=$(${JQ} -r .commit ${VERSION_FILE})
|
||||
if [ ${LOCALCOMMITID} = ${REMOTECOMMITID} ]; then
|
||||
LOCALCOMMITID=$(${JQ} -r .commit ${VERSION_FILE})
|
||||
LOCALREPO=$(${JQ} -r .repo ${VERSION_FILE})
|
||||
if [ -z "$LOCALREPO" ]; then LOCALREPO="$REPO"; fi
|
||||
if [ ${LOCALREPO} = ${REPO} ] && [ ${LOCALCOMMITID} = ${REMOTECOMMITID} ]; then
|
||||
logerror "You are currently on the latest version"
|
||||
echo "You are currently on the latest version"
|
||||
exit 1
|
||||
else
|
||||
elif [ ${LOCALREPO} = ${REPO} ]; then
|
||||
echo "Need to upgrade from ${LOCALCOMMITID} to ${REMOTECOMMITID}"
|
||||
log "Getting list of remote files."
|
||||
FILES=$(curl -s ${GITHUBURL}/${REPO}/compare/${LOCALCOMMITID}...${REMOTECOMMITID} | ${JQ} -r '.files[].raw_url' | grep ${REMOTEFOLDER})
|
||||
else
|
||||
echo "Repo has changed. Upgrade to last commit ${REMOTECOMMITID}"
|
||||
log "Getting list of remote files."
|
||||
FIRST=$(curl -s ${GITHUBURL}/${REPO}/contents/${REMOTEFOLDER}?ref=${BRANCH})
|
||||
FILES=$(getfiles "${FIRST}")
|
||||
fi
|
||||
else
|
||||
echo "Version file missing. Upgrade to last commit ${REMOTECOMMITID}"
|
||||
@@ -306,10 +319,10 @@ do
|
||||
fi
|
||||
# sometimes zero byte files are received, which overwrite the local files, we ignore those files
|
||||
# exception: files that are hidden i.e. start with dot. Ex: files like ".gitkeep"
|
||||
if [[ ! -s ${TMPFILE} ]] && [[ $(basename ${LOCALFILE} | cut -c1-1) != "." ]]; then
|
||||
echo "Received zero byte file $i, exiting."
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -s ${TMPFILE} ]] && [[ $(basename ${LOCALFILE} | cut -c1-1) != "." ]]; then
|
||||
echo "Received zero byte file $i, exiting."
|
||||
exit 1
|
||||
fi
|
||||
# Check the file exists in local
|
||||
if [ -f "${DESTFOLDER}/${LOCALFILE}" ]; then
|
||||
REMOTESHA=$(${SHA} ${TMPFILE} 2>/dev/null | cut -d "=" -f 2)
|
||||
|
@@ -803,13 +803,15 @@ github_curl() {
|
||||
# Check commit between VERSION file and github
|
||||
check_commit() {
|
||||
if [ -s /system/sdcard/VERSION ]; then
|
||||
localrepo=$(/system/sdcard/bin/jq -r .repo /system/sdcard/VERSION)
|
||||
if [ -z "$localrepo" ]; then localrepo="EliasKotlyar"; fi
|
||||
localcommit=$(/system/sdcard/bin/jq -r .commit /system/sdcard/VERSION)
|
||||
localbranch=$(/system/sdcard/bin/jq -r .branch /system/sdcard/VERSION)
|
||||
remotecommit=$(github_curl -s https://api.github.com/repos/EliasKotlyar/Xiaomi-Dafang-Hacks/commits/${localbranch} | /system/sdcard/bin/jq -r '.sha[0:7]')
|
||||
remotecommit=$(github_curl -s https://api.github.com/repos/${localrepo}/commits/${localbranch} | /system/sdcard/bin/jq -r '.sha[0:7]')
|
||||
if [ ${localcommit} = ${remotecommit} ]; then
|
||||
echo "${localcommit} ( No update available)"
|
||||
else
|
||||
commitbehind=$(github_curl -s https://api.github.com/repos/EliasKotlyar/Xiaomi-Dafang-Hacks/compare/${remotecommit}...${localcommit} | /system/sdcard/bin/jq -r '.behind_by')
|
||||
commitbehind=$(github_curl -s https://api.github.com/repos/${localrepo}/compare/${remotecommit}...${localcommit} | /system/sdcard/bin/jq -r '.behind_by')
|
||||
echo "${localcommit} ( ${commitbehind} commits behind Github)"
|
||||
fi
|
||||
else
|
||||
|
@@ -533,10 +533,14 @@ auto_night_mode_status)
|
||||
|
||||
update)
|
||||
processId=$(ps | grep autoupdate.sh | grep -v grep)
|
||||
release=""
|
||||
if [ $F_release == "beta" ]; then
|
||||
release="-r beta"
|
||||
fi
|
||||
repo=$(printf '%b' "${F_repo//%/\\x}")
|
||||
if [ -n "$repo" ]; then
|
||||
repo="-x $repo"
|
||||
fi
|
||||
release=$(printf '%b' "${F_release//%/\\x}")
|
||||
if [ -n "$release" ]; then
|
||||
release="-r $release"
|
||||
fi
|
||||
if [ $F_mode == "full" ]; then
|
||||
mv /system/sdcard/VERSION /system/sdcard/VERSION.old
|
||||
fi
|
||||
@@ -545,9 +549,9 @@ auto_night_mode_status)
|
||||
date >> /var/log/update.log
|
||||
github_token=$(get_config /system/sdcard/config/updates.conf github_token)
|
||||
if [ "$github_token" != "" ]; then
|
||||
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f ${release} -t "$github_token" >> "/system/sdcard/log/update.log" &
|
||||
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f ${repo} ${release} -t "$github_token" >> "/system/sdcard/log/update.log" &
|
||||
else
|
||||
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f ${release} >> "/system/sdcard/log/update.log" &
|
||||
/system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f ${repo} ${release} >> "/system/sdcard/log/update.log" &
|
||||
fi
|
||||
processId=$(ps | grep autoupdate.sh | grep -v grep)
|
||||
fi
|
||||
@@ -695,17 +699,19 @@ motion_detection_mqtt_snapshot_status)
|
||||
;;
|
||||
check_update)
|
||||
if [ -s /system/sdcard/VERSION ]; then
|
||||
localrepo=$(/system/sdcard/bin/jq -r .repo /system/sdcard/VERSION)
|
||||
if [ -z "$localrepo" ]; then localrepo="EliasKotlyar"; fi
|
||||
localcommit=$(/system/sdcard/bin/jq -r .commit /system/sdcard/VERSION)
|
||||
localbranch=$(/system/sdcard/bin/jq -r .branch /system/sdcard/VERSION)
|
||||
remotecommit=$(github_curl -s https://api.github.com/repos/EliasKotlyar/Xiaomi-Dafang-Hacks/commits/${localbranch} | /system/sdcard/bin/jq -r '.sha[0:7]')
|
||||
commitbehind=$(github_curl -s https://api.github.com/repos/EliasKotlyar/Xiaomi-Dafang-Hacks/compare/${remotecommit}...${localcommit} | /system/sdcard/bin/jq -r '.behind_by')
|
||||
remotecommit=$(github_curl -s https://api.github.com/repos/${localrepo}/commits/${localbranch} | /system/sdcard/bin/jq -r '.sha[0:7]')
|
||||
commitbehind=$(github_curl -s https://api.github.com/repos/${localrepo}/compare/${remotecommit}...${localcommit} | /system/sdcard/bin/jq -r '.behind_by')
|
||||
if [ ${localcommit} = ${remotecommit} ]; then
|
||||
echo "${localbranch}:0"
|
||||
echo "${localrepo}:${localbranch}:0"
|
||||
else
|
||||
echo "${localbranch}:${commitbehind}"
|
||||
echo "${localrepo}:${localbranch}:${commitbehind}"
|
||||
fi
|
||||
else
|
||||
echo "null:-1"
|
||||
echo "null:null:-1"
|
||||
fi
|
||||
return
|
||||
;;
|
||||
|
@@ -14,7 +14,7 @@ function timedRefresh(timeoutPeriod) {
|
||||
function update(onStart) {
|
||||
$.ajax({
|
||||
'url': 'cgi-bin/action.cgi?cmd=show_updateProgress'
|
||||
}).done(function(log) {
|
||||
}).done(function(log) {
|
||||
if (log < 0) {
|
||||
if (onStart != true)
|
||||
{
|
||||
@@ -44,65 +44,103 @@ function accordionUpdate(param) {
|
||||
panel.style.maxHeight = null;
|
||||
} else {
|
||||
panel.style.maxHeight = panel.scrollHeight + "px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function startCustom(el) {
|
||||
var repo = $('#custom_repo').val();
|
||||
var branch = $('#custom_branch').val();
|
||||
var mode = $('#custom_full').is(":checked") ? 'full' : 'cumul';
|
||||
start(repo, branch, mode);
|
||||
}
|
||||
|
||||
function showupdatepage(result) {
|
||||
$('#update').html('<h2 id="updatemsg">Seaching for updates ...</h2>');
|
||||
|
||||
$.ajax({
|
||||
'url': 'cgi-bin/action.cgi?cmd=check_update'
|
||||
}).done(function(result){
|
||||
|
||||
|
||||
var update = result.split(":")
|
||||
var update_status = parseInt(update[1],10);
|
||||
var repo = update[0];
|
||||
var branch = update[1];
|
||||
var update_status = parseInt(update[2],10);
|
||||
|
||||
var custom = '<div class="w3-panel w3-border w3-round"> \
|
||||
<h2>Custom Firmware</h2> \
|
||||
<label for="custom_repo">Repository</label> \
|
||||
<input id="custom_repo" class="w3-input w3-block w3-theme" type="text" value="' + repo + '" /><br /> \
|
||||
<label for="custom_branch">Branch</label> \
|
||||
<input id="custom_branch" class="w3-input w3-block w3-theme" type="text" value="' + branch + '" /><br /> \
|
||||
<input id="custom_full" class="w3-check w3-theme" type="checkbox" checked="checked" /> \
|
||||
<label for="custom_full">Force full update</label><br /><br /> \
|
||||
<button class="w3-btn w3-block w3-theme" onclick="startCustom();">Update custom firmware</Button><br /> \
|
||||
</div>';
|
||||
|
||||
if (update_status == 0) {
|
||||
$('#updatemsg').html("You have already the latest version from the " + update[0] + " branch")
|
||||
if (update[0] == "master") {
|
||||
$('#updatemsg').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
$('#updatemsg').html("You have already the latest version from the " + branch + " branch of the " + repo + " repo.")
|
||||
if (branch == "master") {
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"> <p></p>\
|
||||
<input id="switchBeta" class="w3-btn w3-block w3-theme" type="text" value="Switch to BETA firmware" onclick="start(\'beta\',\'full\')"/><br /> \
|
||||
<input id="fullStable" class="w3-btn w3-block w3-theme" type="text" value="Force full update to STABLE (remove version file + update)" onclick="start(\'master\',\'full\')"/><br /> \
|
||||
</div>');
|
||||
|
||||
<input id="switchBeta" class="w3-btn w3-block w3-theme" type="text" value="Switch to BETA firmware" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
<input id="fullStable" class="w3-btn w3-block w3-theme" type="text" value="Force full update to STABLE (remove version file + update)" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
|
||||
}
|
||||
else if (branch == "beta") {
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"> <p></p>\
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
}
|
||||
else {
|
||||
$('#updatemsg').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"> <p></p>\
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'beta\',\'full\')"/><br /> \
|
||||
</div>');
|
||||
<input id="fullCustom" class="w3-btn w3-block w3-theme" type="text" value="Force full update to CUSTOM (remove version file + update)" onclick="start(\'' + repo + '\',\'' + branch + '\',\'full\')"/><br /> \
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (update_status == -1) {
|
||||
$('#updatemsg').html("No version file found. <br /> You can update the firmware on this camera to the latest version from <a target='_blank' href='https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks'>Github repository</a>. <br />Settings will be retained after update.")
|
||||
$('#updatemsg').append('\
|
||||
<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'master\',\'cumul\')"/><br /> \
|
||||
<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'beta\',\'cumul\')"/><br />');
|
||||
$('#update').append('\
|
||||
<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'EliasKotlyar\',\'master\',\'cumul\')"/><br /> \
|
||||
<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'EliasKotlyar\',\'beta\',\'cumul\')"/><br />' + custom);
|
||||
}
|
||||
else if (update_status > 0) {
|
||||
$('#updatemsg').html("You are "+ update_status +" commits behind "+ update[0] + " branch");
|
||||
if (update[0] == "master") {
|
||||
$('#updatemsg').append('<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'master\',\'cumul\')"/><br />');
|
||||
$('#updatemsg').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
$('#updatemsg').html("You are "+ update_status +" commits behind the " + branch + " branch of the " + repo + " repo.")
|
||||
if (branch == "master") {
|
||||
$('#update').append('<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'' + repo + '\',\'master\',\'cumul\')"/><br />');
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"><p></p> \
|
||||
<input id="switchBeta" class="w3-btn w3-block w3-theme" type="text" value="Switch to BETA firmware" onclick="start(\'beta\',\'full\')"/><br /> \
|
||||
<input id="fullStable" class="w3-btn w3-block w3-theme" type="text" value="Force full update to STABLE (remove version file + update)" onclick="start(\'master\',\'full\')"/><br /> \
|
||||
</div>');
|
||||
<input id="switchBeta" class="w3-btn w3-block w3-theme" type="text" value="Switch to BETA firmware" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
<input id="fullStable" class="w3-btn w3-block w3-theme" type="text" value="Force full update to STABLE (remove version file + update)" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
}
|
||||
else if (branch == "beta") {
|
||||
$('#update').append('<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'' + repo + '\',\'beta\',\'cumul\')"/><br />');
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"> <p></p>\
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
}
|
||||
else {
|
||||
$('#updatemsg').append('<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'beta\',\'cumul\')"/><br />');
|
||||
$('#updatemsg').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
$('#update').append('<input id="updateCustom" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (CUSTOM)" onclick="start(\'' + repo + '\',\'' + branch + '\',\'cumul\')"/><br />');
|
||||
$('#update').append('<button class="accordion" type="button" onclick="accordionUpdate(this);">Other Update Options</button> \
|
||||
<div class="panel"> <p></p>\
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'beta\',\'full\')"/><br /> \
|
||||
</div>');
|
||||
<input id="switchStable" class="w3-btn w3-block w3-theme" type="text" value="Switch to STABLE firmware" onclick="start(\'' + repo + '\',\'master\',\'full\')"/><br /> \
|
||||
<input id="fullBeta" class="w3-btn w3-block w3-theme" type="text" value="Force full update to BETA (remove version file + update)" onclick="start(\'' + repo + '\',\'beta\',\'full\')"/><br /> \
|
||||
' + custom + '</div>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#updatemsg').text("There is a problem with your VERSION file. Please do a full update to create a valid VERSION file.");
|
||||
$('#updatemsg').append('\
|
||||
<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'master\',\'cumul\')"/><br /> \
|
||||
<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'beta\',\'cumul\')"/><br />');
|
||||
$('#update').append('\
|
||||
<input id="updateStable" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (STABLE)" onclick="start(\'EliasKotlyar\',\'master\',\'cumul\')"/><br /> \
|
||||
<input id="updateBeta" class="w3-btn w3-block w3-theme" type="text" value="Update firmware (BETA)" onclick="start(\'EliasKotlyar\',\'beta\',\'cumul\')"/><br />' + custom);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -111,12 +149,12 @@ function saveConfig() {
|
||||
$.get("cgi-bin/ui_control.cgi",{cmd: "save_config"},function(result) {
|
||||
getFiles('config');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function deleteConfig(fileName,dir) {
|
||||
var del = confirm("Confirm delete file: "+fileName);
|
||||
if ( del ) {
|
||||
if ( del ) {
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "del_config",file: fileName});
|
||||
getFiles(dir);
|
||||
}
|
||||
@@ -125,7 +163,7 @@ function deleteConfig(fileName,dir) {
|
||||
function restoreConfig(fileName) {
|
||||
var restore = confirm("Are you sure to restore config file: "+fileName+"\n Camera will reboot at the end of the process");
|
||||
if ( restore ) {
|
||||
$.get("cgi-bin/ui_control.cgi",{cmd: "restore_config",file: fileName});
|
||||
$.get("cgi-bin/ui_control.cgi",{cmd: "restore_config",file: fileName});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +171,8 @@ function restoreConfig(fileName) {
|
||||
function getFiles(dir) {
|
||||
// Get files from dir
|
||||
$('#'+dir).html("<p><button class='w3-btn w3-theme' onclick='saveConfig();'>Take config snapshot</button></p>");
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "getFiles", dir: dir}, function(config){
|
||||
var config_all = config.split("\n");
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "getFiles", dir: dir}, function(config){
|
||||
var config_all = config.split("\n");
|
||||
if ( config_all.length == 1)
|
||||
$('#'+dir).append("<h1>No snapshot available.</h1>");
|
||||
else {
|
||||
@@ -151,7 +189,7 @@ function getFiles(dir) {
|
||||
<tbody>");
|
||||
for (var i = 0; i < config_all.length-1; i++) {
|
||||
var config_info = config_all[i].split("#:#");
|
||||
var file_info = config_info[3].split(".");
|
||||
var file_info = config_info[3].split(".");
|
||||
var html_photo = "";
|
||||
$('#result_'+dir).append("<tr> \
|
||||
<td>"+config_info[0]+"</td> \
|
||||
@@ -177,8 +215,8 @@ function getFiles(dir) {
|
||||
}
|
||||
|
||||
|
||||
function start(branch,mode) {
|
||||
var login = "";
|
||||
function start(repo,branch,mode) {
|
||||
var login = "";
|
||||
// if ($('#login').val().length > 0) {
|
||||
// login = "login=" + $('#login').val() + ":" + $('#password').val();
|
||||
// }
|
||||
@@ -188,7 +226,7 @@ function start(branch,mode) {
|
||||
$('#modal_content').html('<h4>Please note: at the end of this process the camera will reboot without notice!</h4> \
|
||||
<div class="w3-light-grey"><div id="progress" class="w3-container w3-theme" style="width:0%"><span id="progressValue">0%</span></div></div><br><h4 id=message></h4>');
|
||||
|
||||
var url = 'cgi-bin/action.cgi?cmd=update&release='+branch+'&mode='+mode;
|
||||
var url = 'cgi-bin/action.cgi?cmd=update&repo='+repo+'&release='+branch+'&mode='+mode;
|
||||
$.ajax({
|
||||
'url': url,
|
||||
'type': 'POST',
|
||||
@@ -246,10 +284,10 @@ var serviceFriendlyNames = {
|
||||
//Function get config
|
||||
function getServices() {
|
||||
// get config and put to hmtl elements
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "get_services"}, function(config){
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "get_services"}, function(config){
|
||||
var config_all = config.split("\n");
|
||||
for (var i = 0; i < config_all.length-1; i++) {
|
||||
var config_info = config_all[i].split("#:#");
|
||||
var config_info = config_all[i].split("#:#");
|
||||
// Select button color accrding status
|
||||
var control_checked = "onclick='controlService(\"start\",\""+config_info[0]+"\")')";
|
||||
if (config_info[1] == "started")
|
||||
@@ -290,5 +328,3 @@ function onLoad() {
|
||||
}
|
||||
|
||||
onLoad();
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user