Add GUI APN setting functions

pull/40/head
glen 4 years ago
parent 34eec84853
commit 9baa378636

@ -7,7 +7,7 @@ sudo ip link set wwan0 down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
sudo ip link set wwan0 up
# connect to carrier
sudo qmicli -p -d /dev/cdc-wdm0 --wds-start-network="apn='sp.koodo.com',ip-type=4" --client-no-release-cid
sudo qmicli -p -d /dev/cdc-wdm0 --wds-start-network="apn='your.apn.here',ip-type=4" --client-no-release-cid
# set default rout and IP
sudo udhcpc -i wwan0
# receive DHCP lease from network

@ -54,6 +54,16 @@ function safefilerewrite($fileName, $dataToSave)
}
}
//Function to get string between used for Mobile.sh
function get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
/**
@ -234,7 +244,8 @@ function DisplayLokinetConfig()
</li>
<li><a href="#daemon" data-toggle="tab">Daemon Settings</a>
</li>
<li><a href="#Mobile" data-toggle="tab">Mobile APN</a>
</li>
<li><a href="#whois" data-toggle="tab">WHOIS</a>
</li>
@ -265,6 +276,17 @@ function DisplayLokinetConfig()
<h5><pre><?php echo _("LA8VDcoJgiv2bSiVqyaT6hJ67LXbnQGpf9Uk3zh9ikUKPJUWeYbgsd9gxQ5ptM2hQNSsCaRETQ3GM9FLDe7BGqcm4ve69bh"); ?></pre></h5>
</div>
<div class="tab-pane fade" id="Mobile">
<form role="form" action="?page=save_hostapd_conf" method="POST">
<h5>Enter mobile provider apn:</h5>
<label for="apn">Mobile Provider APN:</label>
<input type="text" class="form-control" placeholder="enter apn address here" id="apn" name="apn">
<br/>
<?php
echo '<input type="submit" class="btn btn-success" name="apnaddress" value="Set APN" />' , PHP_EOL;
?><h5><?php echo _("Your development support is greatly appreciated | Loki Address:"); ?></h5>
<h5><pre><?php echo _("LA8VDcoJgiv2bSiVqyaT6hJ67LXbnQGpf9Uk3zh9ikUKPJUWeYbgsd9gxQ5ptM2hQNSsCaRETQ3GM9FLDe7BGqcm4ve69bh"); ?></pre></h5>
</div>
<div class="tab-pane fade" id="whois">
<form role="form" action="?page=save_hostapd_conf" method="POST">
@ -404,17 +426,42 @@ function ActivateLokinetConfig()
echo "\n";
?><form><br/><?php
//WHOIS
//WHOIS
} elseif (isset($_POST['checkaddress'])) {
$address = $_POST['lokiaddress'];
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh whois '.$address.'');
echo "<pre><strong>$output</strong></pre>";
?><form method="post"><?php
echo '<input type="submit" class="btn btn-success" name="Return" value="Return" />' , PHP_EOL;
echo "\n";
?><form><br/><?php
?><form method="post"><?php
echo '<input type="submit" class="btn btn-success" name="Return" value="Return" />' , PHP_EOL;
echo "\n";
?><form><br/><?php
//Mobile
} elseif (isset($_POST['apnaddress'])) {
$apnvalue = $_POST['apn'];
$file = "/var/lib/lokinet/mobile.sh";
$input = file_get_contents($file);
$parsed = get_string_between($input, "apn='", "',ip");
$output = str_replace($parsed, $apnvalue, $input);
echo $output;
echo $file;
file_put_contents($file, $output);
echo "<pre><strong>Reboot required to start mobile. Reboot now?</strong></pre>";
?><form method="post"><?php
echo '<input type="submit" class="btn btn-success" name="Return" value="Reboot Later" />' , PHP_EOL;
echo '<input type="submit" class="btn btn-success" name="Reboot" value="Activate Now" />' , PHP_EOL;
echo "\n";
?><form><br/><?php
} elseif (isset($_POST['Return'])) {
DisplayLokinetConfig(); }
DisplayLokinetConfig();
} elseif (isset($_POST['Reboot'])) {
shell_exec('sudo reboot now');
}
}

@ -270,7 +270,7 @@ function default_configuration() {
#changes persmission on lokilaunch.sh and mobile.sh
sudo chmod 755 /var/lib/lokinet/lokilaunch.sh
sudo chmod 755 /var/lib/lokinet/mobile.sh
sudo chmod 777 /var/lib/lokinet/mobile.sh
# Generate required lines for Rasp AP to place into rc.local file.
# #RASPAP is for removal

Loading…
Cancel
Save