Skip to content

Commit

Permalink
check for update script + SD card size + uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 committed Sep 28, 2017
1 parent 75ef810 commit 4a08906
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
36 changes: 36 additions & 0 deletions checkupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /bin/bash

# #################################################################################
#
# WebIndoor system script
# check for autoupdate
#
# #################################################################################


## working repository
if [ -z "$1" ]; then
REPO="inoteska"
else
REPO="$1"
fi


## working dir
cd /root/app


VER_LOCAL=`git log -1 | grep commit | awk '{print $2}'`
VER_REMOTE=`git ls-remote https://github.com/$REPO/indoorjs.git | grep HEAD | cut -f 1`

if [ "$VER_LOCAL" == "$VER_REMOTE" ]
then

echo "equal"

else

echo "different"

fi

4 changes: 2 additions & 2 deletions lib/exec_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ var result = function(command, cb){
});
//console.log(child);
child.on('close', function(code) {
console.log('child ended with: ' + code);
// console.log('child ended with: ' + code);
});
child.on('error', function(err) {
console.log('child errd with: ' + err);
});
child.stdout.on('data', function(d) {
console.log('child stdout: ' + d);
// console.log('child stdout: ' + d);
});
}

Expand Down
6 changes: 5 additions & 1 deletion public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ app.controller('serviceCtrl', function ($scope, $rootScope, $location, services)
services.fullAppUpdate().then(function(data){
$scope.msg = data.data;
}, function(err) {
// console.log('restartApp:',err);
// console.log('full app update:',err);
$scope.msg = err;
$location.path('/');
});
Expand Down Expand Up @@ -493,6 +493,8 @@ app.controller('mainCtrl', function ($scope, $rootScope, $location, services) {
$scope.webVer = VERSION_STR;
$scope.ip_addr = '?';
$scope.mac_addr = '?';
$scope.uptime = '?';
$scope.sdinfo = '?';
};

//** */
Expand All @@ -513,6 +515,8 @@ app.controller('mainCtrl', function ($scope, $rootScope, $location, services) {
$scope.serverVer = d.serverVer;
$scope.ip_addr = d.ipaddr;//.split(' ',1)[0];
$scope.mac_addr = d.macaddr;
$scope.uptime = d.uptime;
$scope.sdinfo = d.sdcard;
for (var i = 0; i < d.lockFlag.length; i++) {
if (d.lockFlag[i] != undefined) {
var l1 = Number('0x'+d.lockFlag[i]) & 0x0f, l2 = (Number('0x'+d.lockFlag[i]) >> 4) & 0x0f;
Expand Down
5 changes: 5 additions & 0 deletions public/views/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ <h3>Status</h3>
<td>IP address</td><td>{{ip_addr}}</td>
<td>MAC address</td><td>{{mac_addr}}</td>
</tr>
<tr>
<td>Up time</td><td>{{uptime}}</td>
<td>SD card size / available</td><td>{{sdinfo}}</td>
</tr>
<tr>
<td colspan="4"> &nbsp; </td>
</tr>
Expand Down Expand Up @@ -76,6 +80,7 @@ <h3>Status</h3>
$('#statustable td:nth-child(odd)').css({'font-weight':'bold','font-size':'16px'});
$('#statustable td:nth-child(even)').css({'font-size':'14px'});
$('#statustable tr:first td').css({'font-weight':'bold','font-size':'20px'});
$('#statustable td').css({'white-space':'nowrap'});

});
</script>
30 changes: 29 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ function iniStatStruct() {
appStatusStruct.rpiSN = store.get('system.rpi');
appStatusStruct.lockFlag = ['?','?','?','?'];
appStatusStruct.videoFlag = [];
appStatusStruct.sdcard = '?';
appStatusStruct.uptime = '?';

exec_process.result('df -h | grep /dev/root | awk \'{printf "%s / %s", $2, $4}\'',
function(err,res1){
// console.log('res1:',res1);
appStatusStruct.sdcard = res1;
/* var sdinfo = res1.toString().split(' ');
try {
appStatusStruct.sdcard = sdinfo[1] + ' / ' + sdinfo[3];
} catch(e) {
appStatusStruct.sdcard = res1;
}//*/
});

exec_process.result('uptime -p',
function(err,a){
// console.log(a);
var ut = a.toString().split(', ');
try {
appStatusStruct.uptime = ut[0] + ', ' + ut[1];
} catch(e) {
appStatusStruct.uptime = a;
}
});

}


Expand Down Expand Up @@ -359,7 +385,9 @@ var socketServer = net.createServer(function(c) {
appStatusStruct.ipaddr = msg.substr('IPADDR: '.length);
} else
if (msg.indexOf('STRUCT:') == 0) {
iniStatStruct();
// iniStatStruct();

// appStatusStruct.appConnectionFlag = 1;

msg = msg.replace(/u\'/g, '\'');
msg = msg.replace(/\'/g, '\"'); // "
Expand Down

0 comments on commit 4a08906

Please sign in to comment.