OpenVPN_Management_GUI/install/index.php

147 lines
4.0 KiB
PHP
Raw Normal View History

2012-07-16 21:32:35 +02:00
<?php
function check_perms($path,$perm)
{
clearstatcache();
$configmod = substr(sprintf('%o', fileperms($path)), -4);
$trcss = (($configmod != $perm) ? "background-color:#fd7a7a;" : "background-color:#91f587;");
if($configmod != $perm) define("FAIL_INST", 1);
echo "<tr style=".$trcss.">";
echo "<td style=\"border:0px;\">". $path ."</td>";
echo "<td style=\"border:0px;\">$perm</td>";
echo "<td style=\"border:0px;\">$configmod</td>";
echo "</tr>";
}
?>
<html>
<head><title>VPNManagement Installer Page</title></head>
<body>
<h1>Install VPNManagement</h1>
<p>Checking PHP...
<?php
if (version_compare(PHP_VERSION, '4.3.3') < 0)
{
echo "<font color=red> [FAIL]</font></p>";
die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to install SchulVPN');
}
else
{
echo "<font color=lime> [OK]</font></p>";
}
?>
</p>
<p>Checking OpenVPN...
<?php
$vpn = shell_exec("/usr/sbin/openvpn --version");
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $vpn, $versionvpn);
if (version_compare($versionvpn[0], '2.1.0') < 0)
{
echo "<font color=red> [FAIL]</font></p>";
die("You are running an unsupported OpenVPN version (".$versionvpn[0]."). Please upgrade to OpenVPN 2.1.0 or higher before trying to install SchulVPN");
}
else
{
echo "<font color=lime> [OK]</font></p>";
}
?>
</p>
<p>Checking MySQL...
<?php
$mysql = shell_exec('mysql -V');
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $mysql, $version);
if (version_compare($version[0], '5.0.00') < 0)
{
echo "<font color=red> [FAIL]</font></p>";
die('You are running an unsupported MySQL version (".$version[0]."). Please upgrade to MySQL 5.0.00 or higher before trying to install SchulVPN');
}
else
{
echo "<font color=lime> [OK]</font></p>";
}
?>
</p>
<p>Checking OpenSSL...
<?php
$ssl=exec("echo \$OPENSSL_CONF");;
if($ssl == "/etc/openvpn/easy-rsa2/openssl.cnf")
{
echo "<font color=lime> [OK]</font></p>";
}
else
{
echo "<font color=red> [FAIL]</font></p>";
die("No OpenSSL Config found: ".$ssl." should be: /etc/openvpn/easy-rsa2/openssl.cnf!");
}
?>
</p>
<p>Checking Directorys...
<table width=\"70%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">
<tr>
<th style="border:5px;"><b>File/Folder Name</b></th>
<th style="border:5px;"><b>Needed Chmod</b></th>
<th style="border:5px;"><b>Current Chmod</b></th>
</tr>
<?php
2012-07-16 21:40:07 +02:00
check_perms("/srv/www/vhosts_admhaasch/vpn.sprinternet.at/public_html","0775");
2012-07-16 21:58:49 +02:00
check_perms("/etc/openvpn","0777");
check_perms("/etc/openvpn/easy-rsa2","0777");
check_perms("/etc/openvpn/easy-rsa2/keys","0777");
check_perms("/etc/openvpn/config/server.conf","0666");
check_perms("/etc/openvpn/config/database","0666");
2012-07-16 21:32:35 +02:00
?>
</table>
<?php
if(FAIL_INST == 1)
{
die('Please change the folder/file permissions!');
}
?>
</p>
<form action="install1.php" method="post">
<table>
<br>
<tr>
<td>Rootuser/Server:</td>
<td><input type="text" name="name" size="50" value="root"><td>
</tr>
<tr>
<td>Rootuser/Server Email:</td>
<td><input type="text" name="email" size="50"><td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="pwd" size="50"></td>
</tr>
<tr>
<td>Datenbank Server:</td>
<td><input type="text" name="dbserv" size="50" value="localhost"><td>
</tr>
<tr>
<td>Datenbank Port:</td>
<td><input type="text" name="dbport" size="50" value="3306"></td>
</tr>
<tr>
<td>Datenbank Name:</td>
<td><input type="text" name="dbname" size="50" value="openvpn"></td>
</tr>
<tr>
<td>Datenbank User:</td>
<td><input type="text" name="dbuser" size="50"></td>
</tr>
<tr>
<td>Datenbank Passwort:</td>
<td><input type="password" name="dbpwd" size="50"></td>
</tr>
<tr>
<td>OpenVPN Config Directory (WITHOUT ending /):</td>
<td><input type="text" name="vpndir" size="50" value="/etc/openvpn/config"></td>
</tr>
</table>
<input type="submit" value="Install! STEP 1">
</form>
</body>
</html>