creating setup-routine to run basic configuration in browser. Reorganized some config-constants

This commit is contained in:
dg9vh 2016-05-20 12:16:33 +00:00
parent 78d44de12d
commit 0d43078be4
9 changed files with 138 additions and 99 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
Links.txt Links.txt
config/config.php

View file

@ -24,7 +24,8 @@ Installation
============ ============
* Please ensure to not put loglevels at 0 in MMDVM.ini. * Please ensure to not put loglevels at 0 in MMDVM.ini.
* Copy all files into your webroot and enjoy working with it. * Copy all files into your webroot and enjoy working with it.
* Edit config.php located in /config-folder in your web-folder. * Create a config/config.php by calling setup.php and giving suitable values
* If Dashboard is working, remove setup.php from your webroot
For detailled installation see `linux-step-by-step.md` within this repository. For detailled installation see `linux-step-by-step.md` within this repository.

View file

@ -1,92 +0,0 @@
<?php
date_default_timezone_set('UTC');
define("MMDVMLOGPATH", "/mnt/ramdisk/"); // hint: add trailing / !!!
define("MMDVMLOGPREFIX", "MMDVM");
define("MMDVMLOGFILE", MMDVMLOGPATH . MMDVMLOGPREFIX . "-" . date("Y-m-d") . ".log");
define("MMDVMINIPATH", "/etc/mmdvm/"); // hint: add trailing / !!!
define("MMDVMINIFILENAME", "MMDVM.ini");
define("MMDVMHOSTPATH", "/usr/local/bin/"); // hint: add trailing / !!!
// enter exact path to your log files.
// If your Linux is a MARYLAND-DSTAR-Image, this paths would work.
// Adjust to suit, uncomment correct line, if none of the given distributions fit, customize
// OTHER to suitable paths.
//define("DISTRIBUTION", "MARYLAND");
define("DISTRIBUTION", "WESTERN");
//define("DISTRIBUTION", "DL5DI_DEBIAN");
//define("DISTRIBUTION", "DL5DI_CENTOS");
//define("DISTRIBUTION", "OTHER");
switch (DISTRIBUTION) {
case "MARYLAND":
// Configuration for Maryland-Dstar-Image
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc/gateway");
define("DSTARREPEATERLOGPATH", LOGPATH . "/dstarrepeater_1");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_Repeater-1-");
define("LINKLOGPATH", LOGPATH . "/gateway/Links.log");
define("HRDLOGPATH", LOGPATH . "/gateway/Headers.log");
break;
case "WESTERN":
// Configuration for Western-Dstar-Image
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH . "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "DL5DI_CENTOS":
// Configuration for DL5DI-Installation-packages on CENTOS
define("LOGPATH", "/var/log/dstar");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH . "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_1-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "DL5DI_DEBIAN":
// Configuration for DL5DI-Installation-packages on DEBIAN
define("LOGPATH", "/var/log/opendv");
define("CONFIGPATH", "/home/opendv/ircddbgateway");
define("DSTARREPEATERLOGPATH", LOGPATH . "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_1-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "OTHER":
// Configuration for all others, please customize
// if necessary
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH . "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
}
define("CONFIGFILENAME", "ircddbgateway");
define("GATEWAYCONFIGPATH", CONFIGPATH . "/" . CONFIGFILENAME);
// set to called ircddbgateway-programm like ircddbgatewayd or ircddbgateway
define("IRCDDBGATEWAY", "ircddbgatewayd");
// set time to refresh page
define("REFRESHAFTER", "60");
// enables CPU-temperature alert
define("TEMPERATUREALERT", true);
// defines temperature of warning
define("TEMPERATUREHIGHLEVEL", 60);
// enables progress-bars
define("SHOWPROGRESSBARS", true);
// defines number of lines in last heard list
define("LHLINES", 20);
?>

View file

@ -2,7 +2,7 @@
function getMMDVMHostVersion() { function getMMDVMHostVersion() {
// returns creation-time of MMDVMHost as version-number // returns creation-time of MMDVMHost as version-number
$filename = MMDVMHOSTPATH . "MMDVMHost"; $filename = MMDVMHOSTPATH."/MMDVMHost";
exec($filename." -v 2>&1", $output); exec($filename." -v 2>&1", $output);
if (!startsWith(substr($output[0],18,8),"20")) { if (!startsWith(substr($output[0],18,8),"20")) {
return getMMDVMHostFileVersion(); return getMMDVMHostFileVersion();
@ -13,7 +13,7 @@ function getMMDVMHostVersion() {
function getMMDVMHostFileVersion() { function getMMDVMHostFileVersion() {
// returns creation-time of MMDVMHost as version-number // returns creation-time of MMDVMHost as version-number
$filename = MMDVMHOSTPATH . "MMDVMHost"; $filename = MMDVMHOSTPATH."/MMDVMHost";
if (file_exists($filename)) { if (file_exists($filename)) {
return date("d M y", filectime($filename)); return date("d M y", filectime($filename));
} }
@ -85,7 +85,7 @@ function showMode($mode, $mmdvmconfigs) {
function getLog() { function getLog() {
// Open Logfile and copy loglines into LogLines-Array() // Open Logfile and copy loglines into LogLines-Array()
$logLines = array(); $logLines = array();
if ($log = fopen(MMDVMLOGFILE,'r')) { if ($log = fopen(MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log", 'r')) {
while ($logLine = fgets($log)) { while ($logLine = fgets($log)) {
if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK")) { if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK")) {
array_push($logLines, $logLine); array_push($logLines, $logLine);

View file

@ -2,7 +2,7 @@
exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp); exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp);
exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq); exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq);
$cputemp = $cputemp[0] / 1000; $cputemp = $cputemp[0] / 1000;
if (TEMPERATUREALERT && $cputemp > TEMPERATUREHIGHLEVEL) { if (defined("TEMPERATUREALERT") && $cputemp > TEMPERATUREHIGHLEVEL) {
?> ?>
<script> <script>
function deleteLayer(id) { function deleteLayer(id) {
@ -110,7 +110,7 @@
<td><?php echo $sysload; ?> %</td> <td><?php echo $sysload; ?> %</td>
<td> <td>
<?php <?php
if (SHOWPROGRESSBARS) { if (defined("SHOWPROGRESSBARS")) {
?> ?>
<div class="progress"><div class="progress-bar <?php <div class="progress"><div class="progress-bar <?php
if ($cpuusage < 30) if ($cpuusage < 30)

View file

@ -44,4 +44,21 @@ function isProcessRunning($processname) {
} }
} }
function createConfigLines() {
$out ="";
foreach($_GET as $key=>$val) {
if($key != "cmd") {
$out .= "define(\"$key\", \"$val\");"."\n";
}
}
return $out;
}
function checkSetup() {
if (file_exists ("setup.php")) {
?>
<div class="alert alert-danger" role="alert">You forgot to remove setup.php in root-directory of your dashboard! Please delete the file!</div>
<?php
}
}
?> ?>

View file

@ -36,6 +36,7 @@ include "include/functions.php";
<h4>MMDVMHost by G4KLX Version: <?php echo getMMDVMHostVersion() ?></h4> <h4>MMDVMHost by G4KLX Version: <?php echo getMMDVMHostVersion() ?></h4>
</div> </div>
<?php <?php
checkSetup();
// Here you can feel free to disable info-sections by commenting out with // before include // Here you can feel free to disable info-sections by commenting out with // before include
include "include/sysinfo.php"; include "include/sysinfo.php";
include "include/repeaterinfo.php"; include "include/repeaterinfo.php";

View file

@ -60,7 +60,7 @@ This short howto describes step-by-step how to install the MMDVMHost-Dashboard o
>rm index.html >rm index.html
9. When this is done you should configure the dashboard by editing /var/www/html/config/config.php respective /var/www/config/config.php to your personal fits. 9. When this is done you should configure the dashboard by calling setup.php in your browser to create /var/www/html/config/config.php respective /var/www/config/config.php with your personal fits.
10. Last step is to put www-user into sudoers by editing `/etc/sudoers` with 10. Last step is to put www-user into sudoers by editing `/etc/sudoers` with

111
setup.php Normal file
View file

@ -0,0 +1,111 @@
<?php
include "include/tools.php";
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Das neueste kompilierte und minimierte CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optionales Theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Das neueste kompilierte und minimierte JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>MMDVM-Dashboard by DG9VH - Setup</title>
</head>
<body>
<?php
if ($_GET['cmd'] =="writeconfig") {
$configfile = fopen("config/config.php", w);
fwrite($configfile,"<?php\n");
fwrite($configfile,"# This is an auto-generated config-file!\n");
fwrite($configfile,"# Be careful, when manual editing this!\n\n");
fwrite($configfile, createConfigLines());
fwrite($configfile,"?>\n");
fclose($configfile);
?>
<div class="page-header">
<h1><small>MMDVM-Dashboard by DG9VH</small> Setup-Process</h1>
<div class="alert alert-success" role="alert">Your config-file is written in config/config.php, please remove setup.php for security reasons!</div>
<p><a href="index.php">Your dashboard is now available.</a></p>
</div>
<?php
} else {
?>
<div class="page-header">
<h1><small>MMDVM-Dashboard by DG9VH</small> Setup-Process</h1>
<h4>Please give necessary information below</h4>
</div>
<form id="config" action="setup.php" method="get">
<input type="hidden" name="cmd" value="writeconfig">
<div class="container">
<h2>MMDVMHost-Configuration</h2>
<div class="input-group">
<span class="input-group-addon" id="MMDVMLOGPATH" style="width: 300px">Path to MMDVMHost-logfile</span>
<input type="text" name="MMDVMLOGPATH" class="form-control" placeholder="/var/log/mmdvm/" aria-describedby="MMDVMLOGPATH">
</div>
<div class="input-group">
<span class="input-group-addon" id="MMDVMLOGPREFIX" style="width: 300px">Logfile-prefix</span>
<input type="text" name="MMDVMLOGPREFIX" class="form-control" placeholder="MMDVM" aria-describedby="MMDVMLOGPREFIX">
</div>
<div class="input-group">
<span class="input-group-addon" id="MMDVMINIPATH" style="width: 300px">Path to MMDVM.ini</span>
<input type="text" name="MMDVMINIPATH" class="form-control" placeholder="/etc/mmdvm/" aria-describedby="MMDVMINIPATH">
</div>
<div class="input-group">
<span class="input-group-addon" id="MMDVMINIFILENAME" style="width: 300px">MMDVM.ini-filename</span>
<input type="text" name="MMDVMINIFILENAME" class="form-control" placeholder="MMDVM.ini" aria-describedby="MMDVMINIFILENAME">
</div>
<div class="input-group">
<span class="input-group-addon" id="MMDVMHOSTPATH" style="width: 300px">Path to MMDVMHost-executable</span>
<input type="text" name="MMDVMHOSTPATH" class="form-control" placeholder="/usr/local/bin/" aria-describedby="MMDVMHOSTPATH">
</div>
</div>
<div class="container">
<h2>ircddbgateway-Configuration</h2>
<div class="input-group">
<span class="input-group-addon" id="LINKLOGPATH" style="width: 300px">Path to Links.log</span>
<input type="text" name="LINKLOGPATH" class="form-control" placeholder="/var/log/" aria-describedby="LINKLOGPATH">
</div>
<div class="input-group">
<span class="input-group-addon" id="IRCDDBGATEWAY" style="width: 300px">Name of ircddbgateway-executeable</span>
<input type="text" name="IRCDDBGATEWAY" class="form-control" placeholder="ircddbgatewayd" aria-describedby="IRCDDBGATEWAY">
</div>
</div>
<div class="container">
<h2>Global Configuration</h2>
<div class="input-group">
<span class="input-group-addon" id="REFRESHAFTER" style="width: 300px">Refresh page after in seconds</span>
<input type="text" name="REFRESHAFTER" class="form-control" placeholder="60" aria-describedby="REFRESHAFTER">
</div>
<div class="input-group">
<span class="input-group-addon" id="SHOWPROGRESSBARS" style="width: 300px">Show progressbars</span>
<div class="panel-body"><input type="checkbox" name="SHOWPROGRESSBARS"></div>
</div>
<div class="input-group">
<span class="input-group-addon" id="TEMPERATUREALERT" style="width: 300px">Enable CPU-temperature-warning</span>
<div class="panel-body"><input type="checkbox" name="TEMPERATUREALERT"></div>
</div>
<div class="input-group">
<span class="input-group-addon" id="TEMPERATUREHIGHLEVEL" style="width: 300px">Warning temperature</span>
<input type="text" name="TEMPERATUREHIGHLEVEL" class="form-control" placeholder="60" aria-describedby="TEMPERATUREHIGHLEVEL">
</div>
<div class="input-group">
<span class="input-group-addon" id="LHLINES" style="width: 300px">Last heard list lines:</span>
<input type="text" name="LHLINES" class="form-control" placeholder="20" aria-describedby="LHLINES">
</div>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" form="config">Save configuration</button>
</span>
</div>
</div>
</form>
<?php
}
?>
</body>
</html>