mirror of
https://github.com/urlgrey/hsmm-pi
synced 2025-10-06 00:12:53 +02:00
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# File: install.sh
|
||||
@@ -126,6 +126,7 @@ fi
|
||||
OUTPUT=`sudo grep "www-data" /etc/sudoers`
|
||||
if [ -z "$OUTPUT" ]; then
|
||||
sudo bash -c "echo 'www-data ALL=(ALL) NOPASSWD: /sbin/iwlist' >> /etc/sudoers"
|
||||
sudo bash -c "echo 'www-data ALL=(ALL) NOPASSWD: /sbin/shutdown' >> /etc/sudoers"
|
||||
fi
|
||||
|
||||
# enable apache mod-rewrite
|
||||
|
@@ -1,6 +1,4 @@
|
||||
# /etc/cron.d/hsmm-pi: CRON jobs for the HSMM-Pi project
|
||||
|
||||
* * * * * root bash -c "[ -e /var/data/hsmm-pi/reboot ] && rm -f /var/data/hsmm-pi/reboot && /sbin/init 6" 2>/dev/null
|
||||
* * * * * root bash -c "[ -e /var/data/hsmm-pi/shutdown ] && rm -f /var/data/hsmm-pi/shutdown && /sbin/init 0" 2>/dev/null
|
||||
* * * * * root bash -c "[ -e /var/run/gpsd.sock ] && [ ! -e /var/run/read_gps_coordinates.lock ] && /usr/local/bin/read_gps_coordinates.pl" 2>/dev/null
|
||||
0,10,20,30,40,50 * * * * root /usr/local/bin/callsign_announcement.sh 2>/dev/null
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@@ -109,4 +109,4 @@ CakeLog::config('error', array(
|
||||
'file' => 'error',
|
||||
));
|
||||
|
||||
Configure::write('App.version','0.7.2');
|
||||
Configure::write('App.version','0.8.0');
|
||||
|
@@ -9,6 +9,8 @@ class StatusController extends AppController {
|
||||
|
||||
public function index() {
|
||||
$this->set('mesh_links', $this->get_mesh_info('links'));
|
||||
$this->set('mesh_routes', $this->get_mesh_info('routes')['routes']);
|
||||
$this->set('mesh_hosts', $this->get_mesh_hosts());
|
||||
$this->set('mesh_services', $this->get_mesh_services());
|
||||
$this->set('mesh_node_locations', $this->get_mesh_node_locations());
|
||||
$this->load_node_attributes();
|
||||
@@ -53,6 +55,33 @@ class StatusController extends AppController {
|
||||
}
|
||||
}
|
||||
|
||||
private function get_mesh_hosts() {
|
||||
$hosts = array();
|
||||
if (file_exists("/var/run/hosts_olsr")) {
|
||||
$handle = @fopen("/var/run/hosts_olsr", "r");
|
||||
if ($handle) {
|
||||
while (($buffer = fgets($handle, 1024)) !== false) {
|
||||
if ($buffer != null) {
|
||||
$host_s = trim(substr($buffer, 0, strpos($buffer, '#')));
|
||||
if (strlen($host_s) > 0) {
|
||||
$host_parts = explode("\t", $host_s);
|
||||
if (sizeof($host_parts) >= 2) {
|
||||
$ip = $host_parts[0];
|
||||
$name = $host_parts[1];
|
||||
if (!array_key_exists($ip, $hosts)) {
|
||||
$hosts[$ip] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
return $hosts;
|
||||
}
|
||||
|
||||
private function get_mesh_services() {
|
||||
$services = array();
|
||||
if (file_exists("/var/run/services_olsr")) {
|
||||
@@ -109,4 +138,3 @@ class StatusController extends AppController {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@@ -4,7 +4,7 @@ class SystemController extends AppController {
|
||||
|
||||
public function reboot() {
|
||||
|
||||
file_put_contents('/var/data/hsmm-pi/reboot', time());
|
||||
exec('sudo /sbin/shutdown -r +1');
|
||||
|
||||
$this->Flash->success(__('Reboot initiated, please reload this page in 2 minutes.'));
|
||||
$this->redirect(array('controller' => 'status', 'action' => 'index'));
|
||||
@@ -12,7 +12,7 @@ class SystemController extends AppController {
|
||||
|
||||
public function shutdown() {
|
||||
|
||||
file_put_contents('/var/data/hsmm-pi/shutdown', time());
|
||||
exec('sudo /sbin/shutdown -h +1');
|
||||
|
||||
$this->Flash->success(__('Shutdown initiated, goodbye.'));
|
||||
$this->redirect(array('controller' => 'status', 'action' => 'index'));
|
||||
|
@@ -49,10 +49,10 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
</head>
|
||||
<body>
|
||||
<!-- Reboot Modal -->
|
||||
<div id="rebootModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div id="rebootModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modalLabelReboot" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><?php echo __('Reboot Confirmation'); ?></h3>
|
||||
<h3 id="modalLabelReboot"><?php echo __('Reboot Confirmation'); ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>The node will be unavailable during the reboot. Are you sure you want to do this?</p>
|
||||
@@ -69,10 +69,10 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
</div>
|
||||
|
||||
<!-- Shutdown Modal -->
|
||||
<div id="shutdownModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div id="shutdownModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modalLabelShutdown" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><?php echo __('Shutdown Confirmation'); ?></h3>
|
||||
<h3 id="modalLabelShutdown"><?php echo __('Shutdown Confirmation'); ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>The node will be totally unavailable after shutdown. Are you sure you want to do this?</p>
|
||||
@@ -107,14 +107,14 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
'action' => 'index'));
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
<?php
|
||||
if ($this->Session->read('Auth.User')) {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li <?php if (strstr($this->here, '/hsmm-pi/network_settings') != FALSE) { echo 'class="active"'; } ?>>
|
||||
<?php
|
||||
<?php
|
||||
echo $this->Html->link(__("<i class=\"icon-signal\"></i> ".'Network'),
|
||||
array(
|
||||
'controller' => 'network_settings',
|
||||
@@ -123,7 +123,7 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
?>
|
||||
</li>
|
||||
<li <?php if (strstr($this->here, '/hsmm-pi/network_services') != FALSE) { echo 'class="active"'; } ?>>
|
||||
<?php
|
||||
<?php
|
||||
echo $this->Html->link("<i class=\"icon-bullhorn\"></i> ".__('Services'),
|
||||
array(
|
||||
'controller' => 'network_services',
|
||||
@@ -132,7 +132,7 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
?>
|
||||
</li>
|
||||
<li <?php if (strstr($this->here, '/hsmm-pi/location') != FALSE) { echo 'class="active"'; } ?>>
|
||||
<?php
|
||||
<?php
|
||||
echo $this->Html->link("<i class=\"icon-globe\"></i> ".__('Location'),
|
||||
array(
|
||||
'controller' => 'location_settings',
|
||||
@@ -162,13 +162,12 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
<li class="divider"></li>
|
||||
<li><a href="#rebootModal" data-toggle="modal"><?php echo __('<i class="icon-refresh"></i> Reboot'); ?></a></li>
|
||||
<li><a href="#shutdownModal" data-toggle="modal"><?php echo __('<i class="icon-off"></i> Shutdown'); ?></a></li>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<?php
|
||||
<?php
|
||||
if ($this->Session->read('Auth.User')) {
|
||||
?>
|
||||
<ul class="nav pull-right">
|
||||
@@ -181,8 +180,7 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<ul class="nav pull-right">
|
||||
@@ -198,6 +196,7 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -208,6 +207,6 @@ $cakeDescription = __d('cake_dev', __('HSMM-Pi'));
|
||||
</div>
|
||||
|
||||
<?php echo $this->element('sql_dump'); ?>
|
||||
<?php echo $this->Html->script('bootstrap.min', array('media' => 'screen')); ?>
|
||||
<?php echo $this->Html->script('bootstrap.min'); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -42,17 +42,17 @@ echo $this->Form->input('location_source',
|
||||
)
|
||||
);
|
||||
?>
|
||||
<span id="fixed" style="display: <?php echo (0 == strcmp($location_source, 'fixed')) ? 'block' : 'none';?>;">
|
||||
<div id="fixed" style="padding: 0; display: <?php echo (0 == strcmp($location_source, 'fixed')) ? 'block' : 'none';?>;">
|
||||
<?php
|
||||
echo $this->Form->input('lat', array('label' => __('Latitude')));
|
||||
echo $this->Form->input('lon', array('label' => __('Longitude')));
|
||||
?>
|
||||
</span>
|
||||
<span id="gps" style="display: <?php echo (0 == strcmp($location_source, 'gps')) ? 'block' : 'none';?>;">
|
||||
</div>
|
||||
<div id="gps" style="padding: 0; display: <?php echo (0 == strcmp($location_source, 'gps')) ? 'block' : 'none';?>;">
|
||||
<?php
|
||||
echo $this->Form->input('gps_device_name', array('label' => __('GPS Device Name')));
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<!-- File: /app/View/NetworkServices/index.ctp -->
|
||||
<div class="page-header">
|
||||
<p><h1>Network Services</h1></p>
|
||||
<h1>Network Services</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@@ -30,7 +30,7 @@ echo $this->Form->input('id', array(
|
||||
|
||||
<div class="tabbable"> <!-- Only required for left/right tabs -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active""><a href="#wifi" data-toggle="tab"><?php echo __('WiFi');?></a></li>
|
||||
<li class="active"><a href="#wifi" data-toggle="tab"><?php echo __('WiFi');?></a></li>
|
||||
<li><a href="#wired" data-toggle="tab"><?php echo __('Wired');?></a></li>
|
||||
<li><a href="#mesh" data-toggle="tab"><?php echo __('Mesh');?></a></li>
|
||||
<li><a href="#time" data-toggle="tab"><?php echo __('Time');?></a></li>
|
||||
@@ -61,7 +61,7 @@ echo $this->Form->input('wired_interface_mode',
|
||||
)
|
||||
);
|
||||
?>
|
||||
<span id="lan" style="display: <?php echo (0 == strcmp($wired_interface_mode, 'LAN')) ? 'block' : 'none';?>;">
|
||||
<div id="lan" style="padding: 0; display: <?php echo (0 == strcmp($wired_interface_mode, 'LAN')) ? 'block' : 'none';?>;">
|
||||
<?php
|
||||
echo $this->Form->input('lan_mode',
|
||||
array(
|
||||
@@ -77,8 +77,8 @@ echo $this->Form->input('lan_dhcp_server', array('label' => __('DHCP Server'), '
|
||||
echo $this->Form->input('lan_dhcp_start', array('label' => __('DHCP Start')));
|
||||
echo $this->Form->input('lan_dhcp_end', array('label' => __('DHCP End')));
|
||||
?>
|
||||
</span>
|
||||
<span id="wan" style="display: <?php echo (0 == strcmp($wired_interface_mode, 'WAN')) ? 'block' : 'none';?>;">
|
||||
</div>
|
||||
<div id="wan" style="padding: 0; display: <?php echo (0 == strcmp($wired_interface_mode, 'WAN')) ? 'block' : 'none';?>;">
|
||||
<?php
|
||||
echo $this->Form->input('wan_protocol',
|
||||
array(
|
||||
@@ -90,7 +90,7 @@ echo $this->Form->input('wan_dns1', array('label' => __('DNS 1')));
|
||||
echo $this->Form->input('wan_dns2', array('label' => __('DNS 2')));
|
||||
echo $this->Form->input('wan_fixed_connection', array('label' => __('WAN port is always on (periodic testing of Internet connectivity is unnecessary)'), 'type' => 'checkbox'));
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="mesh">
|
||||
<?php
|
||||
@@ -105,8 +105,8 @@ echo $this->Form->input('mesh_olsrd_secure_key', array('label' => __('OLSRD Secu
|
||||
echo $this->Form->input('ntp_server', array('label' => __('Network Time Server')));
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
|
@@ -21,7 +21,7 @@
|
||||
</script>
|
||||
|
||||
<div class="page-header">
|
||||
<p><h1>Status
|
||||
<h1>Status
|
||||
<small><?php echo $node_name;?>
|
||||
<?php
|
||||
if (array_key_exists($node_wifi_ip_address, $mesh_node_locations)) {
|
||||
@@ -31,13 +31,13 @@ if (array_key_exists($node_wifi_ip_address, $mesh_node_locations)) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
</small></h1></p>
|
||||
</small></h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span8">
|
||||
<div class="well">
|
||||
<p><h3>Mesh Links</h3></p>
|
||||
<h3>Neighbors</h3>
|
||||
|
||||
<?php
|
||||
if ($mesh_links != NULL && sizeof($mesh_links['links']) > 0) {
|
||||
@@ -49,10 +49,17 @@ if ($mesh_links != NULL && sizeof($mesh_links['links']) > 0) {
|
||||
<th>Link Quality</th>
|
||||
</tr>
|
||||
<?php
|
||||
$neighbor_ips = array();
|
||||
foreach ($mesh_links['links'] as $node) {
|
||||
$neighbor_ips[$node['remoteIP']] = 1;
|
||||
?>
|
||||
<tr>
|
||||
<?php $node_hostname = gethostbyaddr($node['remoteIP']);?>
|
||||
<?php
|
||||
$node_hostname = $mesh_hosts[$node['remoteIP']];
|
||||
if (!$node_hostname) {
|
||||
$node_hostname = $node['remoteIP'];
|
||||
}
|
||||
?>
|
||||
<td><a href="http://<?php echo $node_hostname;?>:8080/"><?php echo $node_hostname;?></a>
|
||||
<?php
|
||||
if (array_key_exists($node['remoteIP'], $mesh_node_locations)) {
|
||||
@@ -85,10 +92,60 @@ if (array_key_exists($node['remoteIP'], $mesh_node_locations)) {
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$remote_nodes = array();
|
||||
foreach ($mesh_routes as $route) {
|
||||
if ($route['genmask'] < 32) continue;
|
||||
if (array_key_exists($route['destination'], $neighbor_ips)) continue;
|
||||
$node_hostname = $mesh_hosts[$route['destination']];
|
||||
if (!$node_hostname) {
|
||||
$node_hostname = $route['destination'];
|
||||
}
|
||||
if (substr($node_hostname, 0, 8) === "dtdlink.") continue;
|
||||
$route['hostname'] = $node_hostname;
|
||||
$remote_nodes[] = $route;
|
||||
}
|
||||
if (sizeof($remote_nodes) > 0) {
|
||||
?>
|
||||
<div class="well">
|
||||
<h3>Remote Nodes</h3>
|
||||
<table class="table table-striped table-bordered">
|
||||
<tr>
|
||||
<th>Hostname</th>
|
||||
<th>IP Address</th>
|
||||
<th>Link Cost</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($remote_nodes as $node) {
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="http://<?php echo $node['hostname'];?>:8080/"><?php echo $node['hostname'];?></a>
|
||||
<?php
|
||||
if (array_key_exists($node['destination'], $mesh_node_locations)) {
|
||||
$location = $mesh_node_locations[$node['destination']];
|
||||
if ($location != NULL) {
|
||||
echo " <a href=\"#mapModal\" data-lat=\"" . $location['lat'] . "\" data-lon=\"" . $location['lon'] . "\" role=\"button\" class=\"open-mapModal icon-globe\" data-toggle=\"modal\"></a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $node['destination']; ?></td>
|
||||
<td><?php echo number_format($node['rtpMetricCost'] / 1024, 2); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well">
|
||||
<p><h3>Mesh Services</h3></p>
|
||||
<h3>Mesh Services</h3>
|
||||
|
||||
<?php
|
||||
if ($mesh_services != NULL && sizeof($mesh_services) > 0) {
|
||||
@@ -115,27 +172,25 @@ foreach ($mesh_services as $service) {
|
||||
</div>
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span8">
|
||||
<p>
|
||||
<h6>HSMM-Pi Version: <?php echo Configure::read('App.version');?></h6>
|
||||
</p>
|
||||
<h6>HSMM-Pi Version: <?php echo Configure::read('App.version');?></h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div id="mapModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div id="mapModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modalLabelMap" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Node Location Map</h3>
|
||||
<h3 id="modalLabelMap">Node Location Map</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id='mapDiv' style="position:relative; width:500px; height:350px;"></div>
|
||||
<h5>Latitude: <em id="latitude"></em> Longitude: <em id="longitude"></em>
|
||||
<h5>Latitude: <em id="latitude"></em> Longitude: <em id="longitude"></em></h5>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<!-- File: /app/View/WifiScan/index.ctp -->
|
||||
|
||||
<div class="page-header">
|
||||
<p><h1>WiFi Scan</h1></p>
|
||||
<h1>WiFi Scan</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
Reference in New Issue
Block a user