Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Minor fixes, validation for IP/Netmask/Hostnames for final release
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan-mccracken committed Jun 8, 2017
1 parent 45c837e commit 6ba6830
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 deletions.
2 changes: 1 addition & 1 deletion base/testUbuntuBinRequirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [[ $(which apt-get 2>&-) != "" ]]; then
logNoNewLine "Checking for required Ubuntu binaries..."

# Ensure that the package lists are re-created to avoid installation failure
rm -rf /var/lib/apt/lists/*
# rm -rf /var/lib/apt/lists/*
# Update package lists
apt-get -q update >> $logFile
if [[ $? -ne 0 ]]; then
Expand Down
31 changes: 29 additions & 2 deletions webadmin/var/www/webadmin/dateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@

?>

<script>
function showErr(id, valid)
{
if (valid || document.getElementById(id).value == "")
{
document.getElementById(id).style.borderColor = "";
document.getElementById(id).style.backgroundColor = "";
}
else
{
document.getElementById(id).style.borderColor = "#a94442";
document.getElementById(id).style.backgroundColor = "#f2dede";
}
}
function enableButton(id, enable)
{
document.getElementById(id).disabled = !enable;
}

function validateTimeserver()
{
var validTimeserver = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/.test(document.getElementById("timeserver").value);
showErr("timeserver", validTimeserver);
enableButton("SaveDateTime", validTimeserver);
}
</script>

<h2>Date/Time</h2>

<div class="row">
Expand All @@ -45,11 +72,11 @@

<span class="label label-default">Network Time Server</span>
<span class="description">Server to use to synchronize the date/time (e.g. "pool.ntp.org")</span>
<input type="text" name="timeserver" id="timeserver" class="form-control input-sm" value="<?php echo getCurrentTimeServer();?>" />
<input type="text" name="timeserver" id="timeserver" class="form-control input-sm" value="<?php echo getCurrentTimeServer();?>" onKeyUp="validateTimeserver();" onChange="validateTimeserver();" />

<br>

<input type="submit" class="btn btn-primary" value="Save" name="SaveDateTime"/>
<input type="submit" class="btn btn-primary" value="Save" name="SaveDateTime" id="SaveDateTime" disabled="disabled" />

</form>

Expand Down
2 changes: 1 addition & 1 deletion webadmin/var/www/webadmin/netBoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function enableButton(id, enable)
{
document.getElementById(id).disabled = !enable;
}
// netbootName

function validateName()
{
var validName = /^[A-Za-z0-9._+\-]{1,256}$/.test(document.getElementById("netbootName").value) || document.getElementById("netbootName").value == "";
Expand Down
53 changes: 44 additions & 9 deletions webadmin/var/www/webadmin/networkSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,41 @@
?>

<script>
function showErr(id, valid)
{
if (valid || document.getElementById(id).value == "")
{
document.getElementById(id).style.borderColor = "";
document.getElementById(id).style.backgroundColor = "";
}
else
{
document.getElementById(id).style.borderColor = "#a94442";
document.getElementById(id).style.backgroundColor = "#f2dede";
}
}
function enableButton(id, enable)
{
document.getElementById(id).disabled = !enable;
}

function validateNetwork()
{
var validHostname = /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/.test(document.getElementById("hostname").value);
var validIP = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(document.getElementById("ip").value);
var validNetmask = /^((255|254|252|248|240|224|192|128|0?)\.){3}(255|254|252|248|240|224|192|128|0)$/.test(document.getElementById("netmask").value);
var validGateway = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(document.getElementById("gateway").value);
var validDNS1 = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(document.getElementById("dns1").value);
var validDNS2 = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(document.getElementById("dns2").value) || document.getElementById("dns2").value == "";
showErr("hostname", validHostname);
showErr("ip", validIP);
showErr("netmask", validNetmask);
showErr("gateway", validGateway);
showErr("dns1", validDNS1);
showErr("dns2", validDNS2);
enableButton("SaveNetwork", validHostname && validIP && validNetmask && validGateway && validDNS1 && validDNS2);
}

window.onload = function()
{
document.getElementById('ip').disabled = document.getElementById('dhcp').checked;
Expand All @@ -106,7 +141,7 @@
<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3">

<label class="control-label">Hostname</label>
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo getCurrentHostname(); ?>" />
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo getCurrentHostname(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />

<label class="control-label">Type</label>
<!-- <select onchange="disableStaticOptions(this.value);" name="selectedNetType">
Expand All @@ -115,35 +150,35 @@
</select> -->

<div class="radio radio-primary">
<input type="radio" name="nettype" value="dhcp" id="dhcp" <?php echo ($type=="dhcp"?" checked=\"checked\"":"") ?> onclick="disableStaticOptions(this.value);" />
<input type="radio" name="nettype" value="dhcp" id="dhcp" <?php echo ($type=="dhcp"?" checked=\"checked\"":"") ?> onclick="disableStaticOptions(this.value); validateNetwork();" />
<label for="dhcp">DHCP</label>
</div>

<div class="radio radio-primary">
<input type="radio" name="nettype" value="static" id="static" <?php echo ($type=="static"?" checked=\"checked\"":"") ?> onclick="disableStaticOptions(this.value);" />
<input type="radio" name="nettype" value="static" id="static" <?php echo ($type=="static"?" checked=\"checked\"":"") ?> onclick="disableStaticOptions(this.value); validateNetwork();" />
<label for="static">Static</label>
</div>

<label class="control-label">IP Address</label>
<input type="text" name="ip" id="ip" class="form-control input-sm" value="<?php echo getCurrentIP(); ?>" />
<input type="text" name="ip" id="ip" class="form-control input-sm" value="<?php echo getCurrentIP(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />

<label class="control-label">Netmask</label>
<input type="text" name="netmask" id="netmask" class="form-control input-sm" value="<?php echo getCurrentNetmask(); ?>" />
<input type="text" name="netmask" id="netmask" class="form-control input-sm" value="<?php echo getCurrentNetmask(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />

</div>

<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3">

<label class="control-label">Gateway</label>
<input type="text" name="gateway" id="gateway" class="form-control input-sm" value="<?php echo getCurrentGateway(); ?>" />
<input type="text" name="gateway" id="gateway" class="form-control input-sm" value="<?php echo getCurrentGateway(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />


<label class="control-label">DNS Server 1</label>
<input type="text" name="dns1" id="dns1" class="form-control input-sm" value="<?php if (isset($dns[0])) { echo $dns[0]; } ?>" />
<input type="text" name="dns1" id="dns1" class="form-control input-sm" value="<?php if (isset($dns[0])) { echo $dns[0]; } ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />


<label class="control-label">DNS Server 2</label>
<input type="text" name="dns2" id="dns2" class="form-control input-sm" value="<?php if (isset($dns[1])) { echo $dns[1]; } ?>" />
<input type="text" name="dns2" id="dns2" class="form-control input-sm" value="<?php if (isset($dns[1])) { echo $dns[1]; } ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
<br>

<input type="submit" class="btn btn-sm <?php if (getSSHstatus()) { echo 'btn-success" value="Disable'; } else { echo'btn-danger" value="Enable'; } ?> SSH" name="SSH"/>
Expand All @@ -158,7 +193,7 @@

<div class="row">
<div class="col-xs-12 col-md-8 col-lg-6">
<input type="submit" class="btn btn-primary" value="Save" name="SaveNetwork"/>
<input type="submit" class="btn btn-primary" value="Save" name="SaveNetwork" id="SaveNetwork" disabled="disabled" />
<br>
<br>
<hr>
Expand Down
2 changes: 1 addition & 1 deletion webadmin/webadminInstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ sed -i 's/^session.gc_probability =.*/session.gc_probability = 1/' $php_ini
if [ ! -f "/var/appliance/conf/appliance.conf.xml" ]; then
shelluser=$(env | grep SUDO_USER | sed 's/SUDO_USER=//g')
# If SUDO_USER is empty this is probably being installed in the root account and we will need to create the shelluser if it doesn't exist
if [[ $shelluser == "" ]]; then
if [[ $shelluser == "" ]] || [[ $shelluser == "root" ]]; then
shelluser=shelluser
if [[ $(getent passwd shelluser) == "" ]]; then
useradd -c 'shelluser' -d /home/shelluser -G wheel -m -s /bin/bash shelluser
Expand Down

0 comments on commit 6ba6830

Please sign in to comment.