mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #648 from billz/feature/bind-addr
Feature: Add server.bind address option to System UI
This commit is contained in:
commit
b2b3d58afd
@ -77,19 +77,36 @@ function DisplaySystem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!RASPI_MONITOR_ENABLED) {
|
if (!RASPI_MONITOR_ENABLED) {
|
||||||
if (isset($_POST['SaveServerPort'])) {
|
if (isset($_POST['SaveServerSettings'])) {
|
||||||
|
$good_input = true;
|
||||||
|
// Validate server port
|
||||||
if (isset($_POST['serverPort'])) {
|
if (isset($_POST['serverPort'])) {
|
||||||
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
|
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
|
||||||
$status->addMessage('Invalid value for port number', 'danger');
|
$status->addMessage('Invalid value for port number', 'danger');
|
||||||
|
$good_input = false;
|
||||||
} else {
|
} else {
|
||||||
$serverPort = escapeshellarg($_POST['serverPort']);
|
$serverPort = escapeshellarg($_POST['serverPort']);
|
||||||
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
}
|
||||||
foreach ($return as $line) {
|
}
|
||||||
$status->addMessage($line, 'info');
|
// Validate server bind address
|
||||||
}
|
$serverBind = escapeshellarg('');
|
||||||
|
if ($_POST['serverBind'] && $_POST['serverBind'] !== null ) {
|
||||||
|
if (!filter_var($_POST['serverBind'], FILTER_VALIDATE_IP)) {
|
||||||
|
$status->addMessage('Invalid value for bind address', 'danger');
|
||||||
|
$good_input = false;
|
||||||
|
} else {
|
||||||
|
$serverBind = escapeshellarg($_POST['serverBind']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Save settings
|
||||||
|
if ($good_input) {
|
||||||
|
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
||||||
|
foreach ($return as $line) {
|
||||||
|
$status->addMessage($line, 'info');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['system_reboot'])) {
|
if (isset($_POST['system_reboot'])) {
|
||||||
$status->addMessage("System Rebooting Now!", "warning", false);
|
$status->addMessage("System Rebooting Now!", "warning", false);
|
||||||
$result = shell_exec("sudo /sbin/reboot");
|
$result = shell_exec("sudo /sbin/reboot");
|
||||||
@ -106,7 +123,8 @@ function DisplaySystem()
|
|||||||
}
|
}
|
||||||
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
||||||
$conf = ParseConfig($return);
|
$conf = ParseConfig($return);
|
||||||
$ServerPort = $conf['server.port'];
|
$serverPort = $conf['server.port'];
|
||||||
|
$serverBind = str_replace('"', '',$conf['server.bind']);
|
||||||
|
|
||||||
// define locales
|
// define locales
|
||||||
$arrLocales = array(
|
$arrLocales = array(
|
||||||
@ -132,5 +150,5 @@ function DisplaySystem()
|
|||||||
'vi_VN.UTF-8' => 'Tiếng Việt (Vietnamese)'
|
'vi_VN.UTF-8' => 'Tiếng Việt (Vietnamese)'
|
||||||
);
|
);
|
||||||
|
|
||||||
echo renderTemplate("system", compact("arrLocales", "status", "ServerPort"));
|
echo renderTemplate("system", compact("arrLocales", "status", "serverPort", "serverBind"));
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Updates lighttpd server.port and restarts the service
|
# Updates lighttpd config settings and restarts the service
|
||||||
# @author billz
|
# @author billz
|
||||||
# license: GNU General Public License v3.0
|
# license: GNU General Public License v3.0
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -o errexit
|
||||||
|
# Exit on error inside functions
|
||||||
|
set -o errtrace
|
||||||
|
# Turn on traces, disabled by default
|
||||||
|
#set -o xtrace
|
||||||
|
|
||||||
server_port=$1
|
server_port=$1
|
||||||
lighttpd_conf=$2
|
server_bind=$2
|
||||||
host=$3
|
lighttpd_conf=$3
|
||||||
|
host=$4
|
||||||
restart_service=0
|
restart_service=0
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
@ -25,11 +33,22 @@ if [ "$restart_service" = 1 ]; then
|
|||||||
echo "Restarting lighttpd in 3 seconds..."
|
echo "Restarting lighttpd in 3 seconds..."
|
||||||
sleep 3
|
sleep 3
|
||||||
systemctl restart lighttpd.service
|
systemctl restart lighttpd.service
|
||||||
else
|
fi
|
||||||
echo "Changing lighttpd server.port to $server_port..."
|
if [ -n "$server_port" ]; then
|
||||||
|
echo "Changing lighttpd server.port to $server_port ..."
|
||||||
sed -i "s/^\(server\.port *= *\)[0-9]*/\1$server_port/g" "$lighttpd_conf"
|
sed -i "s/^\(server\.port *= *\)[0-9]*/\1$server_port/g" "$lighttpd_conf"
|
||||||
|
echo "RaspAP will now be available at port $server_port"
|
||||||
echo "RaspAP will now be available at $host:$server_port"
|
conf_change=1
|
||||||
echo "Restart lighttpd for new setting to take effect"
|
fi
|
||||||
|
if [ -n "$server_bind" ]; then
|
||||||
|
echo "Changing lighttpd server.bind to $server_bind ..."
|
||||||
|
grep -q 'server.bind' "$lighttpd_conf" && \
|
||||||
|
sed -i "s/^\(server\.bind.*= \)\".*\"*/\1\"$server_bind\"/g" "$lighttpd_conf" || \
|
||||||
|
printf "server.bind \t\t\t\t = \"$server_bind\"\n" >> "$lighttpd_conf"
|
||||||
|
echo "RaspAP will now be available at address $server_bind"
|
||||||
|
conf_change=1
|
||||||
|
fi
|
||||||
|
if [ "$conf_change" == 1 ]; then
|
||||||
|
echo "Restart lighttpd for new settings to take effect"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -533,6 +533,12 @@ msgstr "System Rebooting Now!"
|
|||||||
msgid "System Shutting Down Now!"
|
msgid "System Shutting Down Now!"
|
||||||
msgstr "System Shutting Down Now!"
|
msgstr "System Shutting Down Now!"
|
||||||
|
|
||||||
|
msgid "Web server port"
|
||||||
|
msgstr "Web server port"
|
||||||
|
|
||||||
|
msgid "Web server bind address"
|
||||||
|
msgstr "Web server bind address"
|
||||||
|
|
||||||
#: includes/themes.php
|
#: includes/themes.php
|
||||||
msgid "Theme settings"
|
msgid "Theme settings"
|
||||||
msgstr "Theme settings"
|
msgstr "Theme settings"
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
<!-- advanced tab -->
|
<!-- advanced tab -->
|
||||||
<div role="tabpanel" class="tab-pane" id="advanced">
|
<div role="tabpanel" class="tab-pane" id="advanced">
|
||||||
<h4 class="mt-3"><?php echo _("Advanced settings") ;?></h4>
|
<h4 class="mt-3"><?php echo _("Advanced settings") ;?></h4>
|
||||||
<div class="row">
|
<?php if (!RASPI_MONITOR_ENABLED) : ?>
|
||||||
<div class="form-group col-md-6">
|
<form action="?page=system_info" method="POST">
|
||||||
<label for="code"><?php echo _("Web server port") ;?></label>
|
<?php echo CSRFTokenFieldTag() ?>
|
||||||
<form action="?page=system_info" method="POST">
|
<div class="row">
|
||||||
<?php echo CSRFTokenFieldTag() ?>
|
<div class="form-group col-md-6">
|
||||||
<?php if (!RASPI_MONITOR_ENABLED) : ?>
|
<label for="code"><?php echo _("Web server port") ;?></label>
|
||||||
<input type="text" class="form-control" name="serverPort" value="<?php echo htmlspecialchars($ServerPort, ENT_QUOTES); ?>" />
|
<input type="text" class="form-control" name="serverPort" value="<?php echo htmlspecialchars($serverPort, ENT_QUOTES); ?>" />
|
||||||
<?php endif ?>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<input type="submit" class="btn btn-outline btn-primary" name="SaveServerPort" value="<?php echo _("Save settings"); ?>" />
|
<div class="form-group col-md-6">
|
||||||
<input type="submit" class="btn btn-warning" name="RestartLighttpd" value="<?php echo _("Restart lighttpd"); ?>" />
|
<label for="code"><?php echo _("Web server bind address") ;?></label>
|
||||||
</div>
|
<input type="text" class="form-control" name="serverBind" value="<?php echo htmlspecialchars($serverBind, ENT_QUOTES); ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="submit" class="btn btn-outline btn-primary" name="SaveServerSettings" value="<?php echo _("Save settings"); ?>" />
|
||||||
|
<input type="submit" class="btn btn-warning" name="RestartLighttpd" value="<?php echo _("Restart lighttpd"); ?>" />
|
||||||
|
</form>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user