bugfix -> register ETREE file before deploying (else we have no etree to dispatch)

This commit is contained in:
xdrm-brackets 2017-09-28 17:42:16 +02:00
parent 85d4930e85
commit 7464903e66
5 changed files with 81 additions and 44 deletions

View File

@ -0,0 +1,17 @@
#!/bin/bash
# (1) Get iface name #
iface="`hciconfig | awk '{print $1'} | grep -P ':$' | sed 's/://' | head -n 1`";
# (2) Enable secure pairing #
sudo hciconfig $iface sspmode 1;
sudo hciconfig $Iface piscan;
# (3) Find device mac addr #
macaddr="`hcitool scan | grep -vP '^Scan'`";
# If nothing found -> exit
# (4) Pair with device #
# newiface target channel
sudo rfcomm bind /dev/rfcomm1 $macaddr 1;

View File

@ -0,0 +1,6 @@
apt-get install libbluetooth-dev
pip install pybluez
# v2
apt-get install bluetooth bluez python-serial

View File

@ -0,0 +1,9 @@
from bluetooth import *;
sock = BluetoothSocket( RFCOMM );
sock.bind( ('', PORT_ANY) );
sock.listen(1);
port = sock.getsockname()[1];

View File

@ -25,8 +25,29 @@
} }
/* [2] Get etrees list
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['etrees']) || !is_array($arr_r['etrees']) ){
slog('No \'etree\' found in response file', "api:deploy", 'update');
return 127;
}
/* [2] Get the list of daemons (features) /* (2) Reset file */
file_put_contents(ETREE_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(ETREE_CONF, 'w');
foreach($arr_r['etrees'] as $etree)
$f->fwrite( $etree.PHP_EOL );
$f = null;
/* [3] Get the list of daemons (features)
=========================================================*/ =========================================================*/
$feature = []; $feature = [];
$f = new SplFileObject(ETREE_CONF, 'r'); $f = new SplFileObject(ETREE_CONF, 'r');
@ -44,53 +65,11 @@
$feature[] = $etree; $feature[] = $etree;
} }
/* [3] Launch deploy script for each feature
=========================================================*/
/* (1) For each feature */
foreach($feature as $feat_name){
/* (2) Check if specific data in response */
if( !isset($arr_r['feature'][$feat_name]) )
continue;
/* (3) Check for feature deploy script */
if( !file_exists(SOURCE_DIR."/feature/$feat_name/deploy") )
continue;
/* (4) Write useful exclusive data to tmp file */
file_put_contents(TMP_DIR."/$feat_name", json_encode($arr_r['feature'][$feat_name]));
/* (4) Execute deploy script */
$sync_suffix = $sync ? ' sync' : '';
syscall(SOURCE_DIR."/feature/$feat_name/deploy$sync");
}
/* [4] Get etrees list
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['etrees']) || !is_array($arr_r['etrees']) ){
slog('No \'etree\' found in response file', "$FEATURE:deploy", 'update');
return 127;
}
/* (2) Reset file */
file_put_contents(ETREE_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(ETREE_CONF, 'w');
foreach($arr_r['etrees'] as $etree)
$f->fwrite( $etree.PHP_EOL );
$f = null; $f = null;
/* [5] Remove features' entries /* [4] Remove features' entries
=========================================================*/ =========================================================*/
/* (0) We are done if @sync */ /* (0) We are done if @sync */
if( $sync ){ if( $sync ){
@ -129,6 +108,30 @@
} }
/* [5] Launch deploy script for each feature
=========================================================*/
/* (1) For each feature */
foreach($feature as $feat_name){
/* (2) Check if specific data in response */
if( !isset($arr_r['feature'][$feat_name]) )
continue;
/* (3) Check for feature deploy script */
if( !file_exists(SOURCE_DIR."/feature/$feat_name/deploy") )
continue;
/* (4) Write useful exclusive data to tmp file */
file_put_contents(TMP_DIR."/$feat_name", json_encode($arr_r['feature'][$feat_name]));
/* (4) Execute deploy script */
$sync_suffix = $sync ? ' sync' : '';
syscall(SOURCE_DIR."/feature/$feat_name/deploy$sync");
}
return 0; return 0;
} }

View File

@ -24,6 +24,8 @@
} }
$f = null;
/* [2] Fetch & generate useful data from features /* [2] Fetch & generate useful data from features