Browse Source

BINAT updates

master
Evgeny Gagua 2 years ago
parent
commit
ef6c20ca4f
  1. 119
      lib/scripts/distro_web_utils.php
  2. 208
      lib/scripts/sys_utils.php
  3. 7
      lib/scripts/test.php
  4. 26
      lib/sysroot/srv/etc/boot.php
  5. 61
      lib/sysroot/srv/etc/cron.php
  6. 2
      lib/sysroot/srv/etc/system.json
  7. 21
      nm_add.php
  8. 15
      nm_error.php
  9. 102
      nm_operation.php
  10. 6
      style/style.css
  11. 11
      task_wait.php
  12. 10
      wan_cp.php
  13. 18
      wan_modem_operation.php

119
lib/scripts/distro_web_utils.php

@ -959,7 +959,14 @@ function print_TASK_PANEL(){
function print_MODEM_INFO(){
global $SYS_CONFIG;
?><table class="w_panel" width="100%" border=0>
?>
<script>
function setModemAPN( mid ){
var jaja = document.getElementById('CAN_'+mid ).value;
window.location='/task_wait.php?TID=33&MID='+mid+'&AUX='+jaja;
};
</script>
<table class="w_panel" width="100%" border=0>
<tr><td style="font-size:20px; padding-bottom: 10px;">Modem Info</td></tr>
</table><table class="w_panel" width="100%" border=0>
<tr><?php
@ -968,16 +975,25 @@ function print_MODEM_INFO(){
//print_r( $CM );
echo "<td>Modem ID:</td><td>{$MID}</td></tr>";
echo "<tr><td>Power state:</td><td><span class=\"smal_patch\" id=\"on\" >{$CM['generic']['power-state']}</span></td></tr>";
if( $CM['REGISTER_AT_BOOT'] ){
echo "<tr><td>Register at Boot Time:</td><td><input type=\"checkbox\" checked onclick=\"window.location ='/task_wait.php?TID=29&MID={$MID}';\"></td><td></td></tr>";
} else {
echo "<tr><td>Register at Boot Time:</td><td><input type=\"checkbox\" onclick=\"window.location ='/task_wait.php?TID=30&MID={$MID}';\"></td><td></td></tr>";
};
if( $CM['CONNECT_AT_BOOT'] ){
echo "<tr><td>Connect at Boot Time:</td><td><input type=\"checkbox\" checked onclick=\"window.location ='/task_wait.php?TID=31&MID={$MID}';\"></td><td></td></tr>";
} else {
echo "<tr><td>Connect at Boot Time:</td><td><input type=\"checkbox\" onclick=\"window.location ='/task_wait.php?TID=32&MID={$MID}';\"></td><td></td></tr>";
};
if( $CM['generic']['state'] == 'disabled' ){
echo "<tr><td>Modem state:</td><td><span class=\"smal_patch\" id=\"disabled\" >{$CM['generic']['state']}
</span></td><td><a class=\"link_buton\" href=\"/task_wait.php?TID=27&MID={$MID}\">enable</a></td></tr>";
} elseif( $CM['generic']['state'] == 'failed' ) {
echo "<tr><td>Failure reason:</td><td>{$CM['generic']['state-failed-reason']}</td></tr>";
} else {
echo "<tr><td>Modem state:</td><td><span class=\"smal_patch\" id=\"enabled\" >{$CM['generic']['state']}
</span></td><td><a class=\"link_buton\" href=\"/task_wait.php?TID=28&MID={$MID}\">disable</a></td></tr>";
};
if( $CM['generic']['state'] == 'failed' ) {
echo "<tr><td>Failure reason:</td><td>{$CM['generic']['state-failed-reason']}</td></tr>";
};
};
if( $CM['generic']['access-technologies'][0]!=''){
echo "<tr><td>Current Mode:</td><td><span class=\"smal_patch\" id=\"{$CM['generic']['access-technologies'][0]}\" >{$CM['generic']['access-technologies'][0]}</span></td></tr>";
};
@ -1020,6 +1036,93 @@ function print_MODEM_INFO(){
<tr><td>&nbsp;</td></tr>
</table><br/><?php
};
function print_NM_PROFILES_INFO(){
?>
<table class="w_panel" width="100%" border=0><tr><td style="font-size:20px; padding-bottom: 10px;">Network Manager Profiles</td></tr>
<tr><td><a class="link_buton" href="nm_add.php">Create New Profile</a></td></tr>
<?php
$NMP = get_NetworkManager_Profiles();
if( count( $NMP ) ){
foreach( $NMP as $P ){
if( $P['managed'] == true ){
$DP = get_NetworkManager_Device( $P['device'] );
$CP = get_NetworkManager_Connection( $P['uuid'] );
?><tr><td><table class="active_nm_profile" width="100%" border=0><tr><td width="150" align="right">Profile Name:</td><td width="200"><b><?=$P['name'];?></b></td><td width="150" align="right">Type:</td><td width="150"><b><?=$P['type'];?></b></td><td width="150" align="right">UUID:</td><td colspan=2><b><?=$P['uuid'];?></b></td></tr>
<tr><td colspan=6><table width="100%"><?php
if( $CP['GENERAL.STATE'] == 'activated' ){
echo "<tr><td align=\"right\" width=200>Current Status:</td><td><span class=\"smal_patch\" id=\"enabled\">Active</span>&nbsp;";
} else {
echo "<tr><td align=\"right\">Status:</td><td><span class=\"smal_patch\" id=\"disabled\">Not Active</span>&nbsp;";
};
if( $CP['connection.autoconnect']=='yes' ){
echo "<span class=\"smal_patch\" id=\"enabled\">Auto Connect</span>&nbsp;";
} else {
echo "<span class=\"smal_patch\" id=\"disabled\">Auto Connect</span>&nbsp;";
};
if( intval( $DP['GENERAL.STATE'] ) == 100 ){
echo "<span class=\"smal_patch\" id=\"enabled\">CONNECTED</span>&nbsp;";
echo "</td></tr>";
foreach( $CP['IP4.ADDRESS'] as $A ){
echo "<tr><td align=\"right\">IPv4 Address:</td><td>{$A}</td></tr>";
};
echo "<tr><td align=\"right\">IPv4 Gateway:</td><td>{$CP['IP4.GATEWAY']}</td></tr>";
foreach( $CP['IP4.ROUTE'] as $R ){
echo "<tr><td align=\"right\">IPv4 Route:</td><td>{$R}</td></tr>";
};
foreach( $CP['IP4.DNS'] as $D ){
echo "<tr><td align=\"right\">IPv4 DNS:</td><td>{$D}</td></tr>";
};
} else {
?><tr><td>NOT CONNECTED</td></td><?php
};
?></table></td><td width=200><table width="100%"><?php
echo "<tr><td><a class=\"link_buton\" href=\"nm_edit.php?pid={$P['uuid']}\">Edit Profile</a></td></tr>";
if( $CP['GENERAL.STATE'] == 'activated' ){
echo "<tr><td><a class=\"link_buton\" href=\"nm_operation.php?OP=7&pid={$P['uuid']}\">Disable</a></td></tr>";
} else {
echo "<tr><td><a class=\"link_buton\" href=\"nm_operation.php?OP=6&pid={$P['uuid']}\">Enable</a></td></tr>";
};
if( intval( $DP['GENERAL.STATE'] ) == 100 ){
echo "<tr><td><a class=\"link_buton\" href=\"nm_operation.php?OP=5&dev={$DP['GENERAL.DEVICE']}\">Disconnect</a></td></tr>";
} else {
echo "<tr><td><a class=\"link_buton\" href=\"nm_operation.php?OP=4&dev={$DP['GENERAL.DEVICE']}\">Connect</a></td></tr>";
};
echo "<tr><td><a class=\"link_buton\" href=\"nm_operation.php?OP=3&pid={$P['uuid']}\">Delete Profile</a></td></tr>";
?></table></td></tr></table></td></tr><?php
} else {
?><tr><td><table class="passive_nm_profile" width="100%"><tr><td width="150" align="right">Profile Name:</td><td width="200" align="center"><?=$P['name'];?></td><td width="150" align="right">Type:</td><td width="200" align="center"><?=$P['type'];?></td><td>UUID:</td><td><?=$P['uuid'];?></td><td><a class="link_buton" href="nm_operation.php?OP=6&pid=<?=$P['uuid'];?>">Try Activate</a></td></table></td></tr><?php
};
};
} else {
echo "<tr><td>No Network Manager Profile Found!</td></tr>";
};
?>
</table>
<?php
};
function print_NM_ADD_FORM(){
?>
<form action="nm_operation.php?OP=1" method="POST" accept-charset="UTF-8" enctype="multipart/form-data">
<table class="w_panel" width="100%" border=0>
<tr><td style="font-size:20px; padding-bottom: 10px;">Create NetworkManager's New Connection Profile</td></tr>
<tr><td>
<table width="100%">
<tr><td align="right">Connection Profile Name:</td><td><input name="cp_name"></td></tr>
<tr><td align="right">Connection Type:</td><td><input name="cp_type" readonly value="gsm"></td></tr>
<tr><td align="right">Auto-Connect:</td><td><input type="checkbox" name="cp_aa" value="yes"></td></tr>
<tr><td align="right">Connection Dial Number:</td><td><input name="gsm_num"></td></tr>
<tr><td align="right">Connection User:</td><td><input name="gsm_user"></td></tr>
<tr><td align="right">Connection Password:</td><td><input name="gsm_pass"></td></tr>
<tr><td align="right">Connection APN:</td><td><input name="gsm_apn"></td></tr>
<tr><td align="center" colspan=2><input type="submit" value="Create New Connection Profile"></td></tr>
</table>
</td></tr>
</table></form><?php
};
function print_MODEM_LOCATION_INFO( $MID ){
global $SYS_CONFIG;
@ -1045,7 +1148,7 @@ function print_MODEM_LOCATION_INFO( $MID ){
};
echo "</td></tr>";
};
if( $CM['generic']['state']=='registered' ){
if( $CM['generic']['state']=='registered' || $CM['generic']['state']=='connected'){
$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --location-get -J";
$LOFO = json_decode( `$CMD`, true );
$LI = $LOFO['modem']['location'];
@ -1077,7 +1180,7 @@ function print_MODEM_LOCATION_INFO( $MID ){
echo "<td>Lon:</td><td>{$I['longitude']}</td></tr>";
echo "<td colspan=2 align=\"center\"><hr></td></tr>";
};
print_r( $I );
//print_r( $I );
$GMODE = 'A';
$GFIX = 1;
$SATS = array();
@ -1104,7 +1207,7 @@ function print_MODEM_LOCATION_INFO( $MID ){
};
};
};
print_r( $SATS );
//print_r( $SATS );
break;
};
};

208
lib/scripts/sys_utils.php

@ -1,7 +1,8 @@
<?php
require_once( '/srv/scripts/SQLite_Class.php');
$WEB_USER_SUDO_PWD='ujpQFE/<\'Deq+kK5=tL>8~';
$WEB_USER_SUDO_PWD='terrarium';
if( file_exists( '/srv/etc/system.json' ) ){
$SYS_CONFIG = json_decode( file_get_contents( '/srv/etc/system.json' ), true );
@ -38,18 +39,65 @@ function out_log( $str ){
function run_command( $CMD ){
$FD = @popen( $CMD, "r" );
$Out = array();
if( $FD ){
while (($buffer = fgets( $FD ) ) !== false ){
//out_log( $buffer );
$Out[] = $buffer;
};
if( !feof( $FD ) ){
out_log( "Error: unexpected fgets() fail" );
}
pclose($FD);
};
};
function run_root_command( $CMD ){
$sodo_user_pwd = 'terrarium';
$EXEC = "echo \"{$sodo_user_pwd}\" | sudo -S {$CMD}";
$FD = @popen( $EXEC, "r" );
$Out = array();
if( $FD ){
while (($buffer = fgets( $FD ) ) !== false ){
out_log( $buffer );
//out_log( $buffer );
$Out[] = $buffer;
};
if( !feof( $FD ) ){
out_log( "Error: unexpected fgets() fail" );
}
pclose($FD);
};
return $Out;
};
function nmcli_list_gsm_connections(){
$O = run_root_command( "nmcli -c no -s -t connection show" );
$Out = array();
foreach( $O as $CL ){
$T = explode( ':', trim( $CL ) );
if( $T[2] == 'gsm' ) $Out[]=$T[0];
};
return $Out;
};
function nmcli_get_connection_info( $CN ){
$O = run_root_command( "nmcli -c no -s -t connection show {$CN}" );
$Out = array();
foreach( $O as $CL ){
$T = explode( ':', trim( $CL ) );
$D = explode( '.', $T[0] );
$Out[$D[0]][$D[1]] = $T[1];
};
return $Out;
};
function nmcli_create_connection( $name, $type ){
$O = run_root_command( "nmcli -c no -s -t add con-name \"{$name}\" type {$type} ifname \"*\"" );
};
//sudo nmcli c mod mycon connection.autoconnect yes
function create_cron_task( $TID, $Params = '' ){
if( file_exists( '/srv/etc/cron.json' ) ) return false;
@unlink( '/srv/tmp/task_log.var' );
@ -148,6 +196,7 @@ function sync_time(){
};
function get_network_config(){
$Data = file_get_contents( '/etc/network/interfaces' );
$TArr = explode("\n", $Data );
@ -1123,4 +1172,159 @@ function clear_history(){
start_BACKEND_APPLICATION();
};
function reload_modem_data( $MID ){
global $SYS_CONFIG;
$MANU = json_decode( `mmcli -m $MID --output-json`, true );
$LOLO = json_decode( `mmcli -m $MID --location-status --output-json`, true );
if( isset( $LOLO['modem'] ) ){
$MANU['modem']['location'] = $LOLO['modem']['location'];
};
$CD = $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID];
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID] = $MANU['modem'];
if( isset( $CD['REGISTER_AT_BOOT'] )){
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['REGISTER_AT_BOOT'] = $CD['REGISTER_AT_BOOT'];
} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['REGISTER_AT_BOOT'] = false;
if( isset( $CD['CONNECT_AT_BOOT'] )){
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CONNECT_AT_BOOT'] = $CD['CONNECT_AT_BOOT'];
} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CONNECT_AT_BOOT'] = false;
if( isset( $CD['CUSTOM_APN'] ) ){
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN'] = $CD['CUSTOM_APN'];
} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN'] = '';
if( isset( $CD['CUSTOM_APN_USER'] ) ){
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_USER'] = $CD['CUSTOM_APN_USER'];
} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_USER'] = '';
if( isset( $CD['CUSTOM_APN_PASSWORD'] ) ){
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_PASSWORD'] = $CD['CUSTOM_APN_PASSWORD'];
} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_PASSWORD'] = '';
};
function get_NetworkManager_Profiles(){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli -c no -e no -t -s connection";
$LL = `$CMD`;
$TArr = explode( "\n", $LL );
$Data = array();
foreach( $TArr as $T ){
$ZZ = explode( ':',trim( $T ) );
if( count( $ZZ ) > 3 ){
$CC = array();
$CC['name']=$ZZ[0];
$CC['uuid']=$ZZ[1];
$CC['type']=$ZZ[2];
$CC['device'] = $ZZ[3];
$CC['managed'] = true;
if( strlen( $CC['device'] ) < 3 ) {
$CC['managed'] = false;
};
$Data[] = $CC;
};
};
return $Data;
};
function get_NetworkManager_Device( $DN ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli -c no -e no -t -s device show {$DN}";
$LL = `$CMD`;
$TArr = explode( "\n", $LL );
$Data = array();
foreach( $TArr as $T ){
$ZZ = explode( ':',trim( $T ) );
if( strpos( $ZZ[0], '[' ) !== false ){
$TA = explode( '[', $ZZ[0] );
if( array_key_exists($TA[0],$Data) ){
$Data[$TA[0]][]=$ZZ[1];
} else {
$Data[$TA[0]]=array();
$Data[$TA[0]][0]=$ZZ[1];
};
} else {
$Data[$ZZ[0]] = $ZZ[1];
};
};
return $Data;
};
function get_NetworkManager_Connection( $CN ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli -c no -e no -t -s connection show {$CN}";
$LL = `$CMD`;
$TArr = explode( "\n", $LL );
$Data = array();
foreach( $TArr as $T ){
$ZZ = explode( ':',trim( $T ) );
if( strpos( $ZZ[0], '[' ) !== false ){
$TA = explode( '[', $ZZ[0] );
if( array_key_exists($TA[0],$Data) ){
$Data[$TA[0]][]=$ZZ[1];
} else {
$Data[$TA[0]]=array();
$Data[$TA[0]][0]=$ZZ[1];
};
} else {
$Data[$ZZ[0]] = $ZZ[1];
};
};
return $Data;
};
function create_NetworkManager_Profile( $type, $name, $add_params='' ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli connection add save yes +connection.type {$type} +connection.id \"{$name}\" ";
if( is_array( $add_params ) ){
if( count( $add_params ) ){
foreach( $add_params as $Key=>$Val ){
$CMD .= "+{$Key} \"{$Value}\" ";
};
};
};
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
function delete_NetworkManager_Profile( $name ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli connection down \"{$name}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) === false ) return false;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli connection delete \"{$name}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
function connect_NetworkManager_Device( $dev ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli device connect \"{$dev}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
function disconnect_NetworkManager_Device( $dev ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli device disconnect \"{$dev}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
function activate_NetworkManager_Profile( $name ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli connection up \"{$name}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
function deactivate_NetworkManager_Profile( $name ){
global $WEB_USER_SUDO_PWD;
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S nmcli connection down \"{$name}\" ";
$LL = `$CMD`;
if( strpos( $LL, 'successful' ) !== false ) return true;
return false;
};
?>

7
lib/scripts/test.php

@ -10,6 +10,11 @@
// echo "False!\n";
// };
apply_application_config( serialize_current_application_config() );
//apply_application_config( serialize_current_application_config() );
$CL = nmcli_list_gsm_connections();
foreach( $CL as $C ){
$ZZ = nmcli_get_connection_info( $C );
print_r( $ZZ );
};
?>

26
lib/sysroot/srv/etc/boot.php

@ -22,8 +22,11 @@
$MID = intval( $AMO[count($AMO)-1] );
$MANU = json_decode( `mmcli -m $MID --output-json`, true );
$LOLO = json_decode( `mmcli -m $MID --location-status --output-json`, true );
$MANU['modem']['location'] = $LOLO['modem']['location'];
if( isset( $LOLO['modem'] ) ){
$MANU['modem']['location'] = $LOLO['modem']['location'];
};
$MANU['modem']['CONNECT_AT_BOOT'] = false;
$MANU['modem']['REGISTER_AT_BOOT'] = false;
$MANU['modem']['CUSTOM_APN'] = '';
$MANU['modem']['CUSTOM_APN_USER'] = '';
$MANU['modem']['CUSTOM_APN_PASSWORD'] = '';
@ -34,6 +37,9 @@
};
} else {
foreach( $SYS_CONFIG['MODEM_CONFIG']['DEVICES'] as $MID=>$CD ){
if( isset( $CD['REGISTER_AT_BOOT'] )){
$L = `mmcli -m $MID --enable`;
};
if( isset( $CD['CONNECT_AT_BOOT'] )){
// Connect Modem
if( $CD['CONNECT_AT_BOOT'] ){
@ -46,11 +52,19 @@
$L = `$CMD`;
};
};
//echo "Load Modem {$ID} NFO\n";
$MANU = json_decode( `mmcli -m $MID --output-json`, true );
$LOLO = json_decode( `mmcli -m $MID --location-status --output-json`, true );
$MANU['modem']['location'] = $LOLO['modem']['location'];
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID] = $MANU['modem'];
reload_modem_data( $MID );
//$MANU = json_decode( `mmcli -m $MID --output-json`, true );
//$LOLO = json_decode( `mmcli -m $MID --location-status --output-json`, true );
//if( isset( $LOLO['modem'] ) ){
// $MANU['modem']['location'] = $LOLO['modem']['location'];
//};
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID] = $MANU['modem'];
//if( isset( $CD['REGISTER_AT_BOOT'] )){
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['REGISTER_AT_BOOT'] = $CD['REGISTER_AT_BOOT'];
//} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['REGISTER_AT_BOOT'] = false;
//if( isset( $CD['CONNECT_AT_BOOT'] )){
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CONNECT_AT_BOOT'] = $CD['CONNECT_AT_BOOT'];
//} else $SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CONNECT_AT_BOOT'] = false;
};
};
save_system_config();

61
lib/sysroot/srv/etc/cron.php

@ -266,10 +266,12 @@
$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --enable";
out_log( $CMD );
$L=`$CMD`;
$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --output-json";
out_log( $CMD );
$MANU = json_decode( `$CMD`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]=$MANU['modem'];
//$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --output-json";
//out_log( $CMD );
//$MANU = json_decode( `$CMD`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['REGISTER_AT_BOOT']=true;
reload_modem_data( $CRON_CONFIG['parameter'] );
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]=$MANU['modem'];
save_system_config();
break;
};
@ -279,10 +281,53 @@
$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --disable";
out_log( $CMD );
$L=`$CMD`;
$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --output-json";
out_log( $CMD );
$MANU = json_decode( `$CMD`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]=$MANU['modem'];
//$CMD = "mmcli -m {$CRON_CONFIG['parameter']} --output-json";
//out_log( $CMD );
//$MANU = json_decode( `$CMD`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['REGISTER_AT_BOOT']=false;
reload_modem_data( $CRON_CONFIG['parameter'] );
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]=$MANU['modem'];
save_system_config();
break;
};
case 29:{
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['REGISTER_AT_BOOT']=false;
save_system_config();
break;
};
case 30:{
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['REGISTER_AT_BOOT']=true;
save_system_config();
break;
};
case 31:{
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['CONNECT_AT_BOOT']=false;
save_system_config();
break;
};
case 32:{
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$CRON_CONFIG['parameter']]['CONNECT_AT_BOOT']=true;
save_system_config();
break;
};
case 33:{
$TArr = explode( ':', $CRON_CONFIG['parameter'] );
$MID = intval( $TArr[0] );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN']=$TArr[1];
save_system_config();
break;
};
case 34:{
$TArr = explode( ':', $CRON_CONFIG['parameter'] );
$MID = intval( $TArr[0] );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_USER']=$TArr[1];
save_system_config();
break;
};
case 35:{
$TArr = explode( ':', $CRON_CONFIG['parameter'] );
$MID = intval( $TArr[0] );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]['CUSTOM_APN_PASSWORD']=$TArr[1];
save_system_config();
break;
};

2
lib/sysroot/srv/etc/system.json

@ -1 +1 @@
{"PERIODIC_JOB_COUNTS":0,"SAMBA_IS_ON":true,"ARGUS_CONFIG":{"app_is_running":true,"webui_is_running":true},"MODEM_SETUP":true,"MODEM_CONFIG":{"DEVICES":[{"3gpp":{"enabled-locks":[],"eps":{"initial-bearer":{"dbus-path":"--","settings":{"apn":"--","ip-type":"--","password":"--","user":"--"}},"ue-mode-operation":"csps-1"},"imei":"860147051348496","operator-code":"42501","operator-name":"Partner","pco":"--","registration-state":"--"},"cdma":{"activation-state":"--","cdma1x-registration-state":"--","esn":"--","evdo-registration-state":"--","meid":"--","nid":"--","sid":"--"},"dbus-path":"\/org\/freedesktop\/ModemManager1\/Modem\/0","generic":{"access-technologies":["lte"],"bearers":[],"carrier-configuration":"ROW_Gen_VoLTE","carrier-configuration-revision":"05010822","current-bands":["egsm","dcs","utran-1","utran-5","utran-8","eutran-1","eutran-3","eutran-5","eutran-7","eutran-8","eutran-20","eutran-38","eutran-40","eutran-41"],"current-capabilities":["gsm-umts, lte"],"current-modes":"allowed: 2g, 3g, 4g; preferred: 4g","device":"\/sys\/devices\/pci0000:00\/0000:00:14.0\/usb1\/1-2","device-identifier":"370583bd437ad3b0629ff381ca0c81fc37647d4a","drivers":["option1","qmi_wwan"],"equipment-identifier":"860147051348496","hardware-revision":"10000","manufacturer":"QUALCOMM INCORPORATED","model":"SIMCOM_SIM7600E-H","own-numbers":[],"plugin":"simtech","ports":["cdc-wdm0 (qmi)","ttyUSB1 (qcdm)","ttyUSB2 (gps)","ttyUSB3 (at)","ttyUSB4 (at)","ttyUSB5 (audio)","wwan0 (net)"],"power-state":"on","primary-port":"cdc-wdm0","revision":"LE20B04SIM7600M22_210318","signal-quality":{"recent":"yes","value":"59"},"sim":"\/org\/freedesktop\/ModemManager1\/SIM\/0","state":"enabled","state-failed-reason":"--","supported-bands":["egsm","dcs","utran-1","utran-5","utran-8","eutran-1","eutran-3","eutran-5","eutran-7","eutran-8","eutran-20","eutran-38","eutran-40","eutran-41"],"supported-capabilities":["gsm-umts, lte"],"supported-ip-families":["ipv4","ipv6","ipv4v6"],"supported-modes":["allowed: 2g; preferred: none","allowed: 3g; preferred: none","allowed: 4g; preferred: none","allowed: 2g, 3g; preferred: 3g","allowed: 2g, 3g; preferred: 2g","allowed: 2g, 4g; preferred: 4g","allowed: 2g, 4g; preferred: 2g","allowed: 3g, 4g; preferred: 4g","allowed: 3g, 4g; preferred: 3g","allowed: 2g, 3g, 4g; preferred: 4g","allowed: 2g, 3g, 4g; preferred: 3g","allowed: 2g, 3g, 4g; preferred: 2g"],"unlock-required":"sim-pin2","unlock-retries":["sim-pin (3)","sim-puk (10)","sim-pin2 (3)","sim-puk2 (10)"]}}]},"NET_CONFIG":{"lo":{"flags":{"hotplug":0,"auto":1},"net":[],"fam":"inet","mode":"loopback"},"enp6s0":{"flags":{"hotplug":1,"auto":0},"net":[],"fam":"inet","mode":"dhcp"}}}
{"PERIODIC_JOB_COUNTS":0,"SAMBA_IS_ON":true,"ARGUS_CONFIG":{"app_is_running":true,"webui_is_running":true},"MODEM_SETUP":true,"MODEM_CONFIG":{"DEVICES":[{"3gpp":{"enabled-locks":[],"eps":{"initial-bearer":{"dbus-path":"--","settings":{"apn":"--","ip-type":"--","password":"--","user":"--"}},"ue-mode-operation":"csps-1"},"imei":"860147051348496","operator-code":"42501","operator-name":"Partner","pco":"--","registration-state":"home"},"cdma":{"activation-state":"--","cdma1x-registration-state":"--","esn":"--","evdo-registration-state":"--","meid":"--","nid":"--","sid":"--"},"dbus-path":"\/org\/freedesktop\/ModemManager1\/Modem\/0","generic":{"access-technologies":["lte"],"bearers":["\/org\/freedesktop\/ModemManager1\/Bearer\/0"],"carrier-configuration":"ROW_Gen_VoLTE","carrier-configuration-revision":"05010822","current-bands":["egsm","dcs","utran-1","utran-5","utran-8","eutran-1","eutran-3","eutran-5","eutran-7","eutran-8","eutran-20","eutran-38","eutran-40","eutran-41"],"current-capabilities":["gsm-umts, lte"],"current-modes":"allowed: 2g, 3g, 4g; preferred: 4g","device":"\/sys\/devices\/pci0000:00\/0000:00:14.0\/usb1\/1-4","device-identifier":"370583bd437ad3b0629ff381ca0c81fc37647d4a","drivers":["option1","qmi_wwan"],"equipment-identifier":"860147051348496","hardware-revision":"10000","manufacturer":"QUALCOMM INCORPORATED","model":"SIMCOM_SIM7600E-H","own-numbers":[],"plugin":"simtech","ports":["cdc-wdm0 (qmi)","ttyUSB0 (qcdm)","ttyUSB1 (gps)","ttyUSB2 (at)","ttyUSB3 (at)","ttyUSB4 (audio)","wwan0 (net)"],"power-state":"on","primary-port":"cdc-wdm0","revision":"LE20B04SIM7600M22_210318","signal-quality":{"recent":"yes","value":"89"},"sim":"\/org\/freedesktop\/ModemManager1\/SIM\/0","state":"connected","state-failed-reason":"--","supported-bands":["egsm","dcs","utran-1","utran-5","utran-8","eutran-1","eutran-3","eutran-5","eutran-7","eutran-8","eutran-20","eutran-38","eutran-40","eutran-41"],"supported-capabilities":["gsm-umts, lte"],"supported-ip-families":["ipv4","ipv6","ipv4v6"],"supported-modes":["allowed: 2g; preferred: none","allowed: 3g; preferred: none","allowed: 4g; preferred: none","allowed: 2g, 3g; preferred: 3g","allowed: 2g, 3g; preferred: 2g","allowed: 2g, 4g; preferred: 4g","allowed: 2g, 4g; preferred: 2g","allowed: 3g, 4g; preferred: 4g","allowed: 3g, 4g; preferred: 3g","allowed: 2g, 3g, 4g; preferred: 4g","allowed: 2g, 3g, 4g; preferred: 3g","allowed: 2g, 3g, 4g; preferred: 2g"],"unlock-required":"sim-pin2","unlock-retries":["sim-pin (3)","sim-puk (10)","sim-pin2 (3)","sim-puk2 (10)"]},"location":{"capabilities":["3gpp-lac-ci","gps-raw","gps-nmea","gps-unmanaged","agps-msa","agps-msb"],"enabled":["3gpp-lac-ci"],"gps":{"assistance":[],"assistance-servers":[],"refresh-rate":"30","supl-server":"--"},"signals":"no"},"REGISTER_AT_BOOT":false,"CONNECT_AT_BOOT":false,"CUSTOM_APN":"","CUSTOM_APN_USER":"","CUSTOM_APN_PASSWORD":""}]},"NET_CONFIG":{"lo":{"flags":{"hotplug":0,"auto":1},"net":[],"fam":"inet","mode":"loopback"},"enp6s0":{"flags":{"hotplug":1,"auto":0},"net":[],"fam":"inet","mode":"dhcp"}}}

21
nm_add.php

@ -0,0 +1,21 @@
<?php
require_once('../../scripts/sys_utils.php');
require_once('../../scripts/distro_web_utils.php');
foreach( $SYS_CONFIG['MODEM_CONFIG']['DEVICES'] as $ID=>$CD ){
reload_modem_data( $ID );
//$MANU = json_decode( `mmcli -m $ID --output-json`, true );
//$LOLO = json_decode( `mmcli -m $ID --location-status --output-json`, true );
//$MANU['modem']['location'] = $LOLO['modem']['location'];
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$ID]=$MANU['modem'];
};
print_PAGE_HEADER();
if( $SYS_CONFIG['NGINX_AUTH_IS_SET'] == false ) {
print_AUTH_WARNING();
};
print_NM_ADD_FORM();
print_PAGE_BOTTOM();
?>

15
nm_error.php

@ -0,0 +1,15 @@
<?php
require_once('../../scripts/sys_utils.php');
require_once('../../scripts/distro_web_utils.php');
print_PAGE_HEADER();
if( isset( $_GET['eid'] ) ){
switch( intval( $_GET['eid'] ) ){
case 7: echo "Error: While Disconnecting Device!";
};
} else {
};
print_PAGE_BOTTOM();
?>

102
nm_operation.php

@ -0,0 +1,102 @@
<?php
require_once('../../scripts/sys_utils.php');
require_once('../../scripts/distro_web_utils.php');
if( isset( $_GET['OP'] ) ){
$OP = intval( $_GET['OP'] );
switch( $OP ){
case 1:{
// Creating New Profile
if( !isset( $_POST['cp_name'] ) ){
header('location: nm_error.php?eid=1');
exit();
} else {
$add_params = array();
if( isset($_POST['cp_aa']) && $_POST['cp_aa'] == 'yes' ) $add_params['connection.autoconnect'] = 'yes';
if( strlen( $_POST['gsm_num'] ) ) $add_params['gsm.number'] = $_POST['gsm_num'];
if( strlen( $_POST['gsm_user'] ) ) $add_params['gsm.username'] = $_POST['gsm_user'];
if( strlen( $_POST['gsm_pass'] ) ) $add_params['gsm.password'] = $_POST['gsm_pass'];
if( strlen( $_POST['gsm_apn'] ) ) $add_params['gsm.apn'] = $_POST['gsm_apn'];
if( !create_NetworkManager_Profile( $_POST['cp_type'], $_POST['cp_name'], $add_params ) ){
header('location: nm_error.php?eid=2');
exit();
};
};
break;
};
case 2:{
// modify
break;
};
case 3:{
// delete
if( isset( $_GET['pid'] ) ){
if( !delete_NetworkManager_Profile( $_GET['pid'] ) ){
header('location: nm_error.php?eid=3');
exit();
};
} else {
header('location: nm_error.php?eid=4');
exit();
};
break;
};
case 4:{
// connect
if( isset( $_GET['dev'] ) ){
if( !connect_NetworkManager_Device( $_GET['dev'] ) ){
header('location: nm_error.php?eid=5');
exit();
};
} else {
header('location: nm_error.php?eid=6');
exit();
};
break;
};
case 5:{
// disconnect
if( isset( $_GET['dev'] ) ){
if( !disconnect_NetworkManager_Device( $_GET['dev'] ) ){
header('location: nm_error.php?eid=7');
exit();
};
} else {
header('location: nm_error.php?eid=6');
exit();
};
break;
};
case 6:{
// set Active
if( isset( $_GET['pid'] ) ){
if( !activate_NetworkManager_Profile( $_GET['pid'] ) ){
header('location: nm_error.php?eid=8');
exit();
};
} else {
header('location: nm_error.php?eid=9');
exit();
};
break;
};
case 7:{
// unset Active
if( isset( $_GET['pid'] ) ){
if( !deactivate_NetworkManager_Profile( $_GET['pid'] ) ){
header('location: nm_error.php?eid=10');
exit();
};
} else {
header('location: nm_error.php?eid=9');
exit();
};
break;
};
};
header('location: /wan_cp.php');
} else {
print_PAGE_HEADER();
echo "WRONG USE";
print_PAGE_BOTTOM();
};
?>

6
style/style.css

@ -155,4 +155,10 @@ body{
.smal_patch#lte{
color: yellow;
background-color: blue;
}
.active_nm_profile{
border: black 2px solid;
}
.passive_nm_profile{
border: silver 2px solid;
}

11
task_wait.php

@ -23,8 +23,15 @@
intval( $_GET['CTSS'] ));
break;
};
case 27: $CPARAM = $_GET['MID']; break;
case 28: $CPARAM = $_GET['MID']; break;
case 27:
case 28:
case 29:
case 30:
case 31:
case 32: $CPARAM = $_GET['MID']; break;
case 33:
case 34:
case 35: $CPARAM = $_GET['MID'] .':'. $_GET['AUX']; break;
};
if( !create_cron_task( $CTID, $CPARAM ) ){
header('location: /');

10
wan_cp.php

@ -4,10 +4,11 @@
require_once('../../scripts/distro_web_utils.php');
foreach( $SYS_CONFIG['MODEM_CONFIG']['DEVICES'] as $ID=>$CD ){
$MANU = json_decode( `mmcli -m $ID --output-json`, true );
$LOLO = json_decode( `mmcli -m $ID --location-status --output-json`, true );
$MANU['modem']['location'] = $LOLO['modem']['location'];
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$ID]=$MANU['modem'];
reload_modem_data( $ID );
//$MANU = json_decode( `mmcli -m $ID --output-json`, true );
//$LOLO = json_decode( `mmcli -m $ID --location-status --output-json`, true );
//$MANU['modem']['location'] = $LOLO['modem']['location'];
//$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$ID]=$MANU['modem'];
};
print_PAGE_HEADER();
@ -15,6 +16,7 @@
print_AUTH_WARNING();
};
print_MODEM_INFO();
print_NM_PROFILES_INFO();
print_PAGE_BOTTOM();
?>

18
wan_modem_operation.php

@ -1,4 +1,6 @@
<?php
require_once('../../scripts/sys_utils.php');
if( isset( $_GET['MID'] ) || isset( $_POST['MID'] ) ){
$COP = 0;
if( isset( $_GET['MID'] ) ){
@ -15,9 +17,8 @@
switch( $COP ){
case 1:{
//Enable Modem
$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --enable";
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S mmcli -m {$MID} --enable";
$LL = `$CMD`;
require_once('../../scripts/sys_utils.php');
$MANU = json_decode( `mmcli -m $MID --output-json`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]=$MANU['modem'];
save_system_config();
@ -26,9 +27,8 @@
};
case 2:{
//Disable Modem
$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --disable";
$CMD = "echo \"{$WEB_USER_SUDO_PWD}\" | sudo -S mmcli -m {$MID} --disable";
$LL = `$CMD`;
require_once('../../scripts/sys_utils.php');
$MANU = json_decode( `mmcli -m $MID --output-json`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]=$MANU['modem'];
save_system_config();
@ -47,9 +47,10 @@
case 'agps-msb': $ENG = 'agps-msb'; break;
};
if( $ENG != '' ){
$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --location-enable-{$ENG}";
$LL = `$CMD`;
//$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --location-enable-{$ENG}";
//$LL = `$CMD`;
require_once('../../scripts/sys_utils.php');
run_root_command( "mmcli -m {$MID} --location-enable-{$ENG}" );
$MANU = json_decode( `mmcli -m $MID -J`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]=$MANU['modem'];
save_system_config();
@ -69,9 +70,10 @@
case 'agps-msb': $ENG = 'agps-msb'; break;
};
if( $ENG != '' ){
$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --location-disable-{$ENG}";
$LL = `$CMD`;
//$CMD = "echo \"terrarium\" | sudo -S mmcli -m {$MID} --location-disable-{$ENG}";
//$LL = `$CMD`;
require_once('../../scripts/sys_utils.php');
run_root_command( "mmcli -m {$MID} --location-disable-{$ENG}" );
$MANU = json_decode( `mmcli -m $MID -J`, true );
$SYS_CONFIG['MODEM_CONFIG']['DEVICES'][$MID]=$MANU['modem'];
save_system_config();

Loading…
Cancel
Save