mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-02 20:52:41 +02:00
fixes #1833
This commit is contained in:
@@ -177,6 +177,9 @@ ir_cut(){
|
||||
# Calibrate and control the motor
|
||||
# use like: motor up 100
|
||||
motor(){
|
||||
ov=$(onvif_srvd status)
|
||||
[ "${ov}" == "ON" ] && onvif_srvd off
|
||||
|
||||
if [ -z "$2" ]
|
||||
then
|
||||
steps=$STEP
|
||||
@@ -212,7 +215,7 @@ motor(){
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "${ov}" == "ON" ] && onvif_srvd on
|
||||
}
|
||||
|
||||
update_motor_pos(){
|
||||
@@ -319,13 +322,13 @@ recording(){
|
||||
ftp_server(){
|
||||
case "$1" in
|
||||
on)
|
||||
/system/sdcard/controlscripts/ftp_server start
|
||||
/system/sdcard/controlscripts/ftp-server start
|
||||
;;
|
||||
off)
|
||||
/system/sdcard/controlscripts/ftp_server stop
|
||||
/system/sdcard/controlscripts/ftp-server stop
|
||||
;;
|
||||
status)
|
||||
if /system/sdcard/controlscripts/ftp_server status | grep -q "PID"
|
||||
if /system/sdcard/controlscripts/ftp-server status | grep -q "PID"
|
||||
then
|
||||
echo "ON"
|
||||
else
|
||||
@@ -339,13 +342,13 @@ ftp_server(){
|
||||
mqtt_control(){
|
||||
case "$1" in
|
||||
on)
|
||||
/system/sdcard/controlscripts/mqtt_control start
|
||||
/system/sdcard/controlscripts/mqtt-control start
|
||||
;;
|
||||
off)
|
||||
/system/sdcard/controlscripts/mqtt_control stop
|
||||
/system/sdcard/controlscripts/mqtt-control stop
|
||||
;;
|
||||
status)
|
||||
if /system/sdcard/controlscripts/mqtt_control status | grep -q "PID"
|
||||
if /system/sdcard/controlscripts/mqtt-control status | grep -q "PID"
|
||||
then
|
||||
echo "ON"
|
||||
else
|
||||
@@ -379,13 +382,13 @@ mqtt_status(){
|
||||
onvif_srvd(){
|
||||
case "$1" in
|
||||
on)
|
||||
/system/sdcard/controlscripts/onvif-srvd.sh start
|
||||
/system/sdcard/controlscripts/onvif-srvd start
|
||||
;;
|
||||
off)
|
||||
/system/sdcard/controlscripts/onvif-srvd.sh stop
|
||||
/system/sdcard/controlscripts/onvif-srvd stop
|
||||
;;
|
||||
status)
|
||||
if /system/sdcard/controlscripts/onvif-srvd.sh status | grep -q "PID"
|
||||
if /system/sdcard/controlscripts/onvif-srvd status | grep -q "PID"
|
||||
then
|
||||
echo "ON"
|
||||
else
|
||||
|
@@ -13,7 +13,7 @@ echo ""
|
||||
if [ -n "$F_cmd" ]; then
|
||||
case "$F_cmd" in
|
||||
get_services)
|
||||
services="auto-night-detection debug-on-osd ftp_server mdns-responder mqtt-control mqtt-status onvif-srvd recording rtsp sound-on-startup dropbear telegram-bot timelapse lighttpd"
|
||||
services="auto-night-detection debug-on-osd ftp-server mdns-responder mqtt-control mqtt-status onvif-srvd recording rtsp sound-on-startup dropbear telegram-bot timelapse lighttpd"
|
||||
for service in $services ; do
|
||||
echo "${service}#:#$(test -f /run/${service}.pid && echo 'started' || echo 'stopped')#:#$(test -f /system/sdcard/config/autostart/${service} && echo 'true' || echo 'false')#:#false"
|
||||
done
|
||||
|
@@ -5,7 +5,7 @@ function timedRefresh(timeoutPeriod) {
|
||||
if (timeoutPeriod == 0) {
|
||||
window.location.href = window.location.href;
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
timedRefresh(timeoutPeriod)
|
||||
}, 1000);
|
||||
}
|
||||
@@ -14,17 +14,16 @@ 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)
|
||||
{
|
||||
if (onStart != true) {
|
||||
$('#message').text("Error starting update process");
|
||||
}
|
||||
} else {
|
||||
$('#message').text("Update in progress");
|
||||
$('#progress').removeAttr('style');
|
||||
$('#progress').attr('style','width:'+log+'%');
|
||||
$('#progressValue').html(log+'%');
|
||||
$('#progress').attr('style', 'width:' + log + '%');
|
||||
$('#progressValue').html(log + '%');
|
||||
// This is the end, start the reboot count down
|
||||
if (log >= 100) {
|
||||
timedRefresh(30);
|
||||
@@ -48,10 +47,10 @@ function accordionUpdate(param) {
|
||||
}
|
||||
|
||||
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);
|
||||
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) {
|
||||
@@ -59,12 +58,12 @@ function showupdatepage(result) {
|
||||
|
||||
$.ajax({
|
||||
'url': 'cgi-bin/action.cgi?cmd=check_update'
|
||||
}).done(function(result){
|
||||
}).done(function (result) {
|
||||
|
||||
var update = result.split(":")
|
||||
var repo = update[0];
|
||||
var branch = update[1];
|
||||
var update_status = parseInt(update[2],10);
|
||||
var update_status = parseInt(update[2], 10);
|
||||
|
||||
var custom = '<div class="w3-panel w3-border w3-round"> \
|
||||
<h2>Custom Firmware</h2> \
|
||||
@@ -110,7 +109,7 @@ function showupdatepage(result) {
|
||||
<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 the " + branch + " branch of the " + repo + " repo.")
|
||||
$('#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> \
|
||||
@@ -146,38 +145,38 @@ function showupdatepage(result) {
|
||||
}
|
||||
|
||||
function saveConfig() {
|
||||
$.get("cgi-bin/ui_control.cgi",{cmd: "save_config"},function(result) {
|
||||
$.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 ) {
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "del_config",file: fileName});
|
||||
function deleteConfig(fileName, dir) {
|
||||
var del = confirm("Confirm delete file: " + fileName);
|
||||
if (del) {
|
||||
$.get("cgi-bin/ui_control.cgi", { cmd: "del_config", file: fileName });
|
||||
getFiles(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});
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
//Function to get video and images files from dir
|
||||
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){
|
||||
$('#' + 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");
|
||||
if ( config_all.length == 1)
|
||||
$('#'+dir).append("<h1>No snapshot available.</h1>");
|
||||
if (config_all.length == 1)
|
||||
$('#' + dir).append("<h1>No snapshot available.</h1>");
|
||||
else {
|
||||
$('#'+dir).append("\
|
||||
<table class='w3-table-all' id='result_"+dir+"'>\
|
||||
$('#' + dir).append("\
|
||||
<table class='w3-table-all' id='result_"+ dir + "'>\
|
||||
<thead>\
|
||||
<tr class='w3-theme'>\
|
||||
<th>Filename</th>\
|
||||
@@ -187,51 +186,51 @@ function getFiles(dir) {
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>");
|
||||
for (var i = 0; i < config_all.length-1; i++) {
|
||||
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 html_photo = "";
|
||||
$('#result_'+dir).append("<tr> \
|
||||
<td>"+config_info[0]+"</td> \
|
||||
<td>"+config_info[1]+"</td> \
|
||||
<td>"+config_info[2]+"</td> \
|
||||
$('#result_' + dir).append("<tr> \
|
||||
<td>"+ config_info[0] + "</td> \
|
||||
<td>"+ config_info[1] + "</td> \
|
||||
<td>"+ config_info[2] + "</td> \
|
||||
<td> \
|
||||
<a href=\""+config_info[3]+"\" download><i class='fas fa-download' title='Download file'></i></a> \
|
||||
<span onclick=\"deleteConfig('"+config_info[3]+"','"+dir+"')\"><i class='fas fa-trash' title='Delete file'></i></span>\
|
||||
<span onclick=\"restoreConfig('"+config_info[3]+"')\" title='Restore config'><i class='fas fa-hdd'></i></span>\
|
||||
<a href=\""+ config_info[3] + "\" download><i class='fas fa-download' title='Download file'></i></a> \
|
||||
<span onclick=\"deleteConfig('"+ config_info[3] + "','" + dir + "')\"><i class='fas fa-trash' title='Delete file'></i></span>\
|
||||
<span onclick=\"restoreConfig('"+ config_info[3] + "')\" title='Restore config'><i class='fas fa-hdd'></i></span>\
|
||||
</td></tr>");
|
||||
}
|
||||
$('#'+dir).append("</tbody></table><p></p>");
|
||||
var table = $('#result_'+dir).DataTable();
|
||||
$('#result'+dir).on( 'click', 'tr', function () {
|
||||
$('#' + dir).append("</tbody></table><p></p>");
|
||||
var table = $('#result_' + dir).DataTable();
|
||||
$('#result' + dir).on('click', 'tr', function () {
|
||||
//$(this).toggleClass('selected');
|
||||
} );
|
||||
$('#result'+dir).click( function () {
|
||||
//alert( table.rows('.selected').data().length +' row(s) selected' );
|
||||
} );
|
||||
});
|
||||
$('#result' + dir).click(function () {
|
||||
//alert( table.rows('.selected').data().length +' row(s) selected' );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function start(repo,branch,mode) {
|
||||
function start(repo, branch, mode) {
|
||||
var login = "";
|
||||
// if ($('#login').val().length > 0) {
|
||||
// login = "login=" + $('#login').val() + ":" + $('#password').val();
|
||||
// }
|
||||
//Open modal window
|
||||
document.getElementById('modal_box').style.display='block'
|
||||
document.getElementById('modal_box').style.display = 'block'
|
||||
$('#modal_title').html('Update in progress');
|
||||
$('#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&repo='+repo+'&release='+branch+'&mode='+mode;
|
||||
var url = 'cgi-bin/action.cgi?cmd=update&repo=' + repo + '&release=' + branch + '&mode=' + mode;
|
||||
$.ajax({
|
||||
'url': url,
|
||||
'type': 'POST',
|
||||
'data': login
|
||||
}).done(function(result) {
|
||||
}).done(function (result) {
|
||||
|
||||
if (result.length > 0) {
|
||||
update(false);
|
||||
@@ -242,27 +241,27 @@ function start(repo,branch,mode) {
|
||||
}
|
||||
|
||||
//Function control service (stop/start)
|
||||
function controlService(action,serviceName) {
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "services",service: serviceName, action: action}, function(result){
|
||||
$('#control_'+serviceName).removeAttr('onclick');
|
||||
function controlService(action, serviceName) {
|
||||
$.get("cgi-bin/ui_control.cgi", { cmd: "services", service: serviceName, action: action }, function (result) {
|
||||
$('#control_' + serviceName).removeAttr('onclick');
|
||||
if (action == 'start') {
|
||||
$('#control_'+serviceName).attr('onclick','controlService("stop","'+serviceName+'")')
|
||||
$('#control_' + serviceName).attr('onclick', 'controlService("stop","' + serviceName + '")')
|
||||
}
|
||||
else {
|
||||
$('#control_'+serviceName).attr('onclick','controlService("start","'+serviceName+'")')
|
||||
$('#control_' + serviceName).attr('onclick', 'controlService("start","' + serviceName + '")')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//Function to control autostart
|
||||
function autoStartService(action,serviceName) {
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "autoStartService",service: serviceName, action: action});
|
||||
$('#autoStart_'+serviceName).removeAttr('onclick');
|
||||
if(action == "true") {
|
||||
$('#autoStart_'+serviceName).attr('onclick','autoStartService("false","'+serviceName+'")');
|
||||
function autoStartService(action, serviceName) {
|
||||
$.get("cgi-bin/ui_control.cgi", { cmd: "autoStartService", service: serviceName, action: action });
|
||||
$('#autoStart_' + serviceName).removeAttr('onclick');
|
||||
if (action == "true") {
|
||||
$('#autoStart_' + serviceName).attr('onclick', 'autoStartService("false","' + serviceName + '")');
|
||||
}
|
||||
else {
|
||||
$('#autoStart_'+serviceName).attr('onclick','autoStartService("true","'+serviceName+'")');
|
||||
$('#autoStart_' + serviceName).attr('onclick', 'autoStartService("true","' + serviceName + '")');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +270,7 @@ var serviceFriendlyNames = {
|
||||
"auto-night-detection": "Auto Night Detection",
|
||||
"dropbear": "SSH Server",
|
||||
"debug-on-osd": "Debug on OSD",
|
||||
"ftp_server": "FTP Server",
|
||||
"ftp-server": "FTP Server",
|
||||
"mdns-responder": "mDNSResponder",
|
||||
"mqtt-control": "MQTT Control",
|
||||
"mqtt-status": "MQTT Live Status Updates",
|
||||
@@ -287,21 +286,21 @@ 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("#:#");
|
||||
// Select button color accrding status
|
||||
var control_checked = "onclick='controlService(\"start\",\""+config_info[0]+"\")')";
|
||||
if (config_info[1] == "started")
|
||||
control_checked = "checked onclick='controlService(\"stop\",\""+config_info[0]+"\")')";
|
||||
var autostart_checked = "onclick='autoStartService(\"true\",\""+config_info[0]+"\")')";
|
||||
if(config_info[2] == "true")
|
||||
autostart_checked = "checked onclick='autoStartService(\"false\",\""+config_info[0]+"\")')";
|
||||
var friendly_name = serviceFriendlyNames[config_info[0]] || config_info[0];
|
||||
$('#tabServices').append("<tr><td>"+friendly_name+"</td>\
|
||||
<td>Stop <label class='switch'><input id='control_"+config_info[0]+"' class='w3-check' type='checkbox' "+control_checked+"> <span class='slider round'></span></label> Start</td>\
|
||||
<td>Off <label class='switch'><input id='autoStart_"+config_info[0]+"' class='w3-check' type='checkbox' "+autostart_checked+"> <span class='slider round'></span></label> On</td></tr>");
|
||||
for (var i = 0; i < config_all.length - 1; i++) {
|
||||
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")
|
||||
control_checked = "checked onclick='controlService(\"stop\",\"" + config_info[0] + "\")')";
|
||||
var autostart_checked = "onclick='autoStartService(\"true\",\"" + config_info[0] + "\")')";
|
||||
if (config_info[2] == "true")
|
||||
autostart_checked = "checked onclick='autoStartService(\"false\",\"" + config_info[0] + "\")')";
|
||||
var friendly_name = serviceFriendlyNames[config_info[0]] || config_info[0];
|
||||
$('#tabServices').append("<tr><td>" + friendly_name + "</td>\
|
||||
<td>Stop <label class='switch'><input id='control_"+ config_info[0] + "' class='w3-check' type='checkbox' " + control_checked + "> <span class='slider round'></span></label> Start</td>\
|
||||
<td>Off <label class='switch'><input id='autoStart_"+ config_info[0] + "' class='w3-check' type='checkbox' " + autostart_checked + "> <span class='slider round'></span></label> On</td></tr>");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -309,7 +308,7 @@ function getServices() {
|
||||
|
||||
function system(command) {
|
||||
//Open modal window
|
||||
document.getElementById('modal_box').style.display='block'
|
||||
document.getElementById('modal_box').style.display = 'block'
|
||||
$('#modal_title').html(command);
|
||||
if (command == "reboot") {
|
||||
$('#modal_content').html("<h4 id=message></h4>");
|
||||
|
Reference in New Issue
Block a user