mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #1 from billz/zbchristian-master
Code style fixes + locale update
This commit is contained in:
commit
fc4e234b45
@ -23,6 +23,8 @@ define('RASPI_OPENVPN_CLIENT_LOGIN', '/etc/openvpn/client/login.conf');
|
|||||||
define('RASPI_OPENVPN_SERVER_CONFIG', '/etc/openvpn/server/server.conf');
|
define('RASPI_OPENVPN_SERVER_CONFIG', '/etc/openvpn/server/server.conf');
|
||||||
define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc');
|
define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc');
|
||||||
define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf');
|
define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf');
|
||||||
|
define('RASPI_ACCESS_CHECK_IP', '1.1.1.1');
|
||||||
|
define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one');
|
||||||
|
|
||||||
// Constant for the 5GHz wireless regulatory domain
|
// Constant for the 5GHz wireless regulatory domain
|
||||||
define('RASPI_5GHZ_ISO_ALPHA2', array('US'));
|
define('RASPI_5GHZ_ISO_ALPHA2', array('US'));
|
||||||
|
@ -27,6 +27,8 @@ $defaults = [
|
|||||||
'RASPI_OPENVPN_SERVER_CONFIG' => '/etc/openvpn/server/server.conf',
|
'RASPI_OPENVPN_SERVER_CONFIG' => '/etc/openvpn/server/server.conf',
|
||||||
'RASPI_TORPROXY_CONFIG' => '/etc/tor/torrc',
|
'RASPI_TORPROXY_CONFIG' => '/etc/tor/torrc',
|
||||||
'RASPI_LIGHTTPD_CONFIG' => '/etc/lighttpd/lighttpd.conf',
|
'RASPI_LIGHTTPD_CONFIG' => '/etc/lighttpd/lighttpd.conf',
|
||||||
|
'RASPI_ACCESS_CHECK_IP' => '1.1.1.1',
|
||||||
|
'RASPI_ACCESS_CHECK_DNS' => 'one.one.one.one',
|
||||||
|
|
||||||
// Optional services, set to true to enable.
|
// Optional services, set to true to enable.
|
||||||
'RASPI_WIFICLIENT_ENABLED' => true,
|
'RASPI_WIFICLIENT_ENABLED' => true,
|
||||||
|
@ -1,36 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define("ACCESS_CHECK_IP","1.1.1.1");
|
$rInfo=array();
|
||||||
define("ACCESS_CHECK_DNS","one.one.one.one");
|
|
||||||
|
|
||||||
$rInfo=array();
|
|
||||||
// get all default routes
|
// get all default routes
|
||||||
exec('ip route list | sed -rn "s/default via (([0-9]{1,3}\.){3}[0-9]{1,3}).*dev (\w*).*src (([0-9]{1,3}\.){3}[0-9]{1,3}).*/\3 \4 \1/p"',$routes);
|
exec('ip route list | sed -rn "s/default via (([0-9]{1,3}\.){3}[0-9]{1,3}).*dev (\w*).*src (([0-9]{1,3}\.){3}[0-9]{1,3}).*/\3 \4 \1/p"', $routes);
|
||||||
if ( !empty($routes) ) {
|
if (!empty($routes) ) {
|
||||||
foreach ($routes as $i => $route) {
|
foreach ($routes as $i => $route) {
|
||||||
$prop=explode(' ',$route);
|
$prop=explode(' ', $route);
|
||||||
$rInfo[$i]["interface"]=$prop[0];
|
$rInfo[$i]["interface"]=$prop[0];
|
||||||
$rInfo[$i]["ip-address"]=$prop[1];
|
$rInfo[$i]["ip-address"]=$prop[1];
|
||||||
$rInfo[$i]["gateway"]=$prop[2];
|
$rInfo[$i]["gateway"]=$prop[2];
|
||||||
// resolve the name of the gateway (if possible)
|
// resolve the name of the gateway (if possible)
|
||||||
unset($host);
|
unset($host);
|
||||||
exec('host '.$prop[2].' | sed -rn "s/.*domain name pointer (.*)\./\1/p" | head -n 1',$host);
|
exec('host '.$prop[2].' | sed -rn "s/.*domain name pointer (.*)\./\1/p" | head -n 1', $host);
|
||||||
if (empty($host)) $host[0]="*";
|
$rInfo[$i]["gw-name"] = empty($host) ? "*" : $host[0];
|
||||||
$rInfo[$i]["gw-name"] = $host[0];
|
|
||||||
if (isset($checkAccess) && $checkAccess) {
|
if (isset($checkAccess) && $checkAccess) {
|
||||||
// check internet connectivity w/ and w/o DNS resolution
|
// check internet connectivity w/ and w/o DNS resolution
|
||||||
unset($okip);
|
unset($okip);
|
||||||
exec('ping -W1 -c 1 -I '.$prop[0].' '.ACCESS_CHECK_IP.' | sed -rn "s/.*icmp_seq=1.*time=.*/\&check\;/p"',$okip);
|
exec('ping -W1 -c 1 -I '.$prop[0].' '.RASPI_ACCESS_CHECK_IP.' | sed -rn "s/.*icmp_seq=1.*time=.*/OK/p"',$okip);
|
||||||
if (empty($okip)) $okip[0]="failed";
|
$rInfo[$i]["access-ip"] = empty($okip) ? false : true;
|
||||||
$rInfo[$i]["access-ip"] = $okip[0];
|
|
||||||
unset($okdns);
|
unset($okdns);
|
||||||
exec('ping -W1 -c 1 -I '.$prop[0].' '.ACCESS_CHECK_DNS.' | sed -rn "s/.*icmp_seq=1.*time=.*/\&check\;/p"',$okdns);
|
exec('ping -W1 -c 1 -I '.$prop[0].' '.RASPI_ACCESS_CHECK_DNS.' | sed -rn "s/.*icmp_seq=1.*time=.*/OK/p"',$okdns);
|
||||||
if (empty($okdns)) $okdns[0]="failed";
|
$rInfo[$i]["access-dns"] = empty($okdns) ? false : true;
|
||||||
$rInfo[$i]["access-dns"] = $okdns[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$rInfo = array("error"=>"No route to the internet found");
|
$rInfo = array("error"=>"No route to the internet found");
|
||||||
}
|
}
|
||||||
$rInfo_json = json_encode($rInfo);
|
$rInfo_json = json_encode($rInfo);
|
||||||
?>
|
?>
|
||||||
|
@ -30,12 +30,17 @@ git_source_url="https://github.com/$repo" # $repo from install.raspap.com
|
|||||||
|
|
||||||
# Prompts user to set installation options
|
# Prompts user to set installation options
|
||||||
function _config_installation() {
|
function _config_installation() {
|
||||||
_install_log "Configure installation"
|
if [ "$upgrade" == 1 ]; then
|
||||||
|
opt=(Upgrade Upgrading upgrade)
|
||||||
|
else
|
||||||
|
opt=(Install Installing installation)
|
||||||
|
fi
|
||||||
|
_install_log "Configure ${opt[2]}"
|
||||||
_get_linux_distro
|
_get_linux_distro
|
||||||
echo "Detected OS: ${DESC}"
|
echo "Detected OS: ${DESC}"
|
||||||
echo "Using GitHub repository: ${repo} ${branch} branch"
|
echo "Using GitHub repository: ${repo} ${branch} branch"
|
||||||
echo "Install directory: ${raspap_dir}"
|
echo "Configuration directory: ${raspap_dir}"
|
||||||
echo -n "Install to lighttpd root: ${webroot_dir}? [Y/n]: "
|
echo -n "lighttpd root: ${webroot_dir}? [Y/n]: "
|
||||||
if [ "$assume_yes" == 0 ]; then
|
if [ "$assume_yes" == 0 ]; then
|
||||||
read answer < /dev/tty
|
read answer < /dev/tty
|
||||||
if [ "$answer" != "${answer#[Nn]}" ]; then
|
if [ "$answer" != "${answer#[Nn]}" ]; then
|
||||||
@ -44,8 +49,12 @@ function _config_installation() {
|
|||||||
else
|
else
|
||||||
echo -e
|
echo -e
|
||||||
fi
|
fi
|
||||||
echo "Installing to lighttpd directory: ${webroot_dir}"
|
echo "${opt[1]} lighttpd directory: ${webroot_dir}"
|
||||||
echo -n "Complete installation with these values? [Y/n]: "
|
if [ "$upgrade" == 1 ]; then
|
||||||
|
echo "This will upgrade your existing install to version ${RASPAP_LATEST}"
|
||||||
|
echo "Your configuration will NOT be changed"
|
||||||
|
fi
|
||||||
|
echo -n "Complete ${opt[2]} with these values? [Y/n]: "
|
||||||
if [ "$assume_yes" == 0 ]; then
|
if [ "$assume_yes" == 0 ]; then
|
||||||
read answer < /dev/tty
|
read answer < /dev/tty
|
||||||
if [ "$answer" != "${answer#[Nn]}" ]; then
|
if [ "$answer" != "${answer#[Nn]}" ]; then
|
||||||
@ -290,6 +299,12 @@ function _download_latest_files() {
|
|||||||
git clone --branch $branch --depth 1 $git_source_url /tmp/raspap-webgui || _install_status 1 "Unable to download files from github"
|
git clone --branch $branch --depth 1 $git_source_url /tmp/raspap-webgui || _install_status 1 "Unable to download files from github"
|
||||||
|
|
||||||
sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to web root"
|
sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to web root"
|
||||||
|
if [ "$upgrade" == 1 ]; then
|
||||||
|
_install_log "Applying existing configuration to ${webroot_dir}/includes"
|
||||||
|
sudo mv /tmp/config.php $webroot_dir/includes || _install_status 1 "Unable to move config.php to ${webroot_dir}/includes"
|
||||||
|
sudo mv /tmp/defaults.php $webroot_dir/includes || _install_status 1 "Unable to move defaults.php to ${webroot_dir}/includes"
|
||||||
|
fi
|
||||||
|
|
||||||
_install_status 0
|
_install_status 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +320,12 @@ function _change_file_ownership() {
|
|||||||
|
|
||||||
# Check for existing configuration files
|
# Check for existing configuration files
|
||||||
function _check_for_old_configs() {
|
function _check_for_old_configs() {
|
||||||
|
if [ "$upgrade" == 1 ]; then
|
||||||
|
_install_log "Moving existing configuration to /tmp"
|
||||||
|
sudo mv $webroot_dir/includes/config.php /tmp || _install_status 1 "Unable to move config.php to /tmp"
|
||||||
|
sudo mv $webroot_dir/includes/defaults.php /tmp || _install_status 1 "Unable to move defaults.php to /tmp"
|
||||||
|
else
|
||||||
|
_install_log "Backing up existing configs to ${raspap_dir}/backups"
|
||||||
if [ -f /etc/network/interfaces ]; then
|
if [ -f /etc/network/interfaces ]; then
|
||||||
sudo cp /etc/network/interfaces "$raspap_dir/backups/interfaces.`date +%F-%R`"
|
sudo cp /etc/network/interfaces "$raspap_dir/backups/interfaces.`date +%F-%R`"
|
||||||
sudo ln -sf "$raspap_dir/backups/interfaces.`date +%F-%R`" "$raspap_dir/backups/interfaces"
|
sudo ln -sf "$raspap_dir/backups/interfaces.`date +%F-%R`" "$raspap_dir/backups/interfaces"
|
||||||
@ -332,6 +353,7 @@ function _check_for_old_configs() {
|
|||||||
sudo ln -sf "${raspap_dir}/backups/${filename}.`date +%F-%R`" "${raspap_dir}/backups/${filename}"
|
sudo ln -sf "${raspap_dir}/backups/${filename}.`date +%F-%R`" "${raspap_dir}/backups/${filename}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
_install_status 0
|
_install_status 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +370,7 @@ function _move_config_file() {
|
|||||||
|
|
||||||
# Set up default configuration
|
# Set up default configuration
|
||||||
function _default_configuration() {
|
function _default_configuration() {
|
||||||
|
if [ "$upgrade" == 0 ]; then
|
||||||
_install_log "Applying default configuration to installed services"
|
_install_log "Applying default configuration to installed services"
|
||||||
if [ -f /etc/default/hostapd ]; then
|
if [ -f /etc/default/hostapd ]; then
|
||||||
sudo mv /etc/default/hostapd /tmp/default_hostapd.old || _install_status 1 "Unable to remove old /etc/default/hostapd file"
|
sudo mv /etc/default/hostapd /tmp/default_hostapd.old || _install_status 1 "Unable to remove old /etc/default/hostapd file"
|
||||||
@ -371,6 +394,7 @@ function _default_configuration() {
|
|||||||
sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php"
|
sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php"
|
||||||
fi
|
fi
|
||||||
_install_status 0
|
_install_status 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install and enable RaspAP daemon
|
# Install and enable RaspAP daemon
|
||||||
@ -453,6 +477,7 @@ function _patch_system_files() {
|
|||||||
|
|
||||||
# Optimize configuration of php-cgi.
|
# Optimize configuration of php-cgi.
|
||||||
function _optimize_php() {
|
function _optimize_php() {
|
||||||
|
if [ "$upgrade" == 0 ]; then
|
||||||
_install_log "Optimize PHP configuration"
|
_install_log "Optimize PHP configuration"
|
||||||
if [ ! -f "$phpcgiconf" ]; then
|
if [ ! -f "$phpcgiconf" ]; then
|
||||||
_install_warning "PHP configuration could not be found."
|
_install_warning "PHP configuration could not be found."
|
||||||
@ -501,6 +526,7 @@ function _optimize_php() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _install_complete() {
|
function _install_complete() {
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
# Overrides the default git branch (master)
|
# Overrides the default git branch (master)
|
||||||
# -h, --help
|
# -h, --help
|
||||||
# Outputs usage notes and exits
|
# Outputs usage notes and exits
|
||||||
|
# -u, --upgrade
|
||||||
|
# Upgrades an existing installation to the latest release version
|
||||||
# -v, --version
|
# -v, --version
|
||||||
# Outputs release info and exits
|
# Outputs release info and exits
|
||||||
#
|
#
|
||||||
@ -37,6 +39,7 @@
|
|||||||
repo="billz/raspap-webgui"
|
repo="billz/raspap-webgui"
|
||||||
branch="master"
|
branch="master"
|
||||||
assume_yes=0
|
assume_yes=0
|
||||||
|
upgrade=0
|
||||||
ovpn_option=1
|
ovpn_option=1
|
||||||
adblock_option=1
|
adblock_option=1
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ Usage: raspbian.sh [OPTION]\n
|
|||||||
-r, --repo, --repository <name>\n\tOverrides the default GitHub repo (billz/raspap-webgui)
|
-r, --repo, --repository <name>\n\tOverrides the default GitHub repo (billz/raspap-webgui)
|
||||||
-b, --branch <name>\n\tOverrides the default git branch (master)
|
-b, --branch <name>\n\tOverrides the default git branch (master)
|
||||||
-h, --help\n\tOutputs usage notes and exits
|
-h, --help\n\tOutputs usage notes and exits
|
||||||
|
-u, --upgrade\n\tUpgrades an existing installation to the latest release version
|
||||||
-v, --version\n\tOutputs release info and exits\n
|
-v, --version\n\tOutputs release info and exits\n
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
@ -95,6 +99,9 @@ while :; do
|
|||||||
printf "$usage"
|
printf "$usage"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
-u|--upgrade)
|
||||||
|
upgrade=1
|
||||||
|
;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
printf "RaspAP v${RASPAP_LATEST} - Simple AP setup & WiFi management for Debian-based devices\n"
|
printf "RaspAP v${RASPAP_LATEST} - Simple AP setup & WiFi management for Debian-based devices\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -451,6 +451,9 @@ msgstr "Configures the max_num_sta option of hostapd. The default and maximum is
|
|||||||
msgid "Summary"
|
msgid "Summary"
|
||||||
msgstr "Summary"
|
msgstr "Summary"
|
||||||
|
|
||||||
|
msgid "Internet connection"
|
||||||
|
msgstr "Internet connection"
|
||||||
|
|
||||||
msgid "Current settings"
|
msgid "Current settings"
|
||||||
msgstr "Current settings"
|
msgstr "Current settings"
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
// defaults to false
|
// defaults to false
|
||||||
$bridgedEnabled = $arrHostapdConf['BridgedEnable'];
|
$bridgedEnabled = $arrHostapdConf['BridgedEnable'];
|
||||||
?>
|
?>
|
||||||
<?php if (!$bridgedEnabled): // no interface details when bridged ?>
|
<?php if (!$bridgedEnabled) : // no interface details when bridged ?>
|
||||||
<?php foreach ($interfaces as $if): ?>
|
<?php foreach ($interfaces as $if): ?>
|
||||||
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
|
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
|
||||||
<li role="presentation" class="nav-item"><a class="nav-link" href="#<?php echo $if_quoted ?>" aria-controls="<?php echo $if_quoted ?>" role="tab" data-toggle="tab"><?php echo $if_quoted ?></a></li>
|
<li role="presentation" class="nav-item"><a class="nav-link" href="#<?php echo $if_quoted ?>" aria-controls="<?php echo $if_quoted ?>" role="tab" data-toggle="tab"><?php echo $if_quoted ?></a></li>
|
||||||
@ -26,7 +26,6 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
|
|
||||||
<div role="tabpanel" class="tab-pane active" id="summary">
|
<div role="tabpanel" class="tab-pane active" id="summary">
|
||||||
<h4 class="mt-3"><?php echo _("Internet connection"); ?></h4>
|
<h4 class="mt-3"><?php echo _("Internet connection"); ?></h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -45,8 +44,8 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$checkAccess=True;
|
$checkAccess=true;
|
||||||
include("includes/internetRoute.php");
|
require "includes/internetRoute.php";
|
||||||
if (isset($rInfo["error"]) || empty($rInfo)) {
|
if (isset($rInfo["error"]) || empty($rInfo)) {
|
||||||
echo "<tr><td colspan=5>No route to the internet found</td></tr>";
|
echo "<tr><td colspan=5>No route to the internet found</td></tr>";
|
||||||
} else {
|
} else {
|
||||||
@ -55,8 +54,10 @@
|
|||||||
echo "<td>".$route["interface"]."</td>";
|
echo "<td>".$route["interface"]."</td>";
|
||||||
echo "<td>".$route["ip-address"]."</td>";
|
echo "<td>".$route["ip-address"]."</td>";
|
||||||
echo "<td>".$route["gateway"]."<br>".$route["gw-name"]."</td>";
|
echo "<td>".$route["gateway"]."<br>".$route["gw-name"]."</td>";
|
||||||
echo "<td>".$route["access-ip"]."<br>".ACCESS_CHECK_IP."</td>";
|
$checkok = $route["access-ip"] ? "✓" : "failed";
|
||||||
echo "<td>".$route["access-dns"]."<br>".ACCESS_CHECK_DNS."</td>";
|
echo "<td>".$checkok."<br>".RASPI_ACCESS_CHECK_IP."</td>";
|
||||||
|
$checkok = $route["access-dns"] ? "✓" : "failed";
|
||||||
|
echo "<td>".$checkok."<br>".RASPI_ACCESS_CHECK_DNS."</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +142,7 @@
|
|||||||
<label for="<?php echo $if_quoted ?>-dnssvralt"><?php echo _("Alternate DNS Server") ?></label>
|
<label for="<?php echo $if_quoted ?>-dnssvralt"><?php echo _("Alternate DNS Server") ?></label>
|
||||||
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-dnssvralt" placeholder="0.0.0.0">
|
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-dnssvralt" placeholder="0.0.0.0">
|
||||||
</div>
|
</div>
|
||||||
<?php if (!RASPI_MONITOR_ENABLED): ?>
|
<?php if (!RASPI_MONITOR_ENABLED) : ?>
|
||||||
<a href="#" class="btn btn-outline btn-primary intsave" data-int="<?php echo $if_quoted ?>"><?php echo _("Save settings") ?></a>
|
<a href="#" class="btn btn-outline btn-primary intsave" data-int="<?php echo $if_quoted ?>"><?php echo _("Save settings") ?></a>
|
||||||
<a href="#" class="btn btn-warning intapply" data-int="<?php echo $if_quoted ?>"><?php echo _("Apply settings") ?></a>
|
<a href="#" class="btn btn-warning intapply" data-int="<?php echo $if_quoted ?>"><?php echo _("Apply settings") ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user