mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Fixed up PHP notices. Added text when IP Address, MAC Address, and Subnet mask aren't found.
Also added function to backup configuration files /etc/network/interfaces and /etc/hostapd/hostapd.conf files if found.
This commit is contained in:
parent
97fd8dc13e
commit
a36e525f98
@ -15,19 +15,19 @@ function DisplayDashboard(){
|
|||||||
$strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 );
|
$strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 );
|
||||||
|
|
||||||
// Parse results from ifconfig/iwconfig
|
// Parse results from ifconfig/iwconfig
|
||||||
preg_match( '/HWaddr ([0-9a-f:]+)/i',$strWlan0,$result );
|
preg_match( '/HWaddr ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = 'No MAC Address Found';
|
||||||
$strHWAddress = $result[1];
|
$strHWAddress = $result[1];
|
||||||
preg_match( '/inet addr:([0-9.]+)/i',$strWlan0,$result );
|
preg_match( '/inet addr:([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No IP Address Found';
|
||||||
$strIPAddress = $result[1];
|
$strIPAddress = $result[1];
|
||||||
preg_match( '/Mask:([0-9.]+)/i',$strWlan0,$result );
|
preg_match( '/Mask:([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No Subnet Mask Found';
|
||||||
$strNetMask = $result[1];
|
$strNetMask = $result[1];
|
||||||
preg_match( '/RX packets:(\d+)/',$strWlan0,$result );
|
preg_match( '/RX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data';
|
||||||
$strRxPackets = $result[1];
|
$strRxPackets = $result[1];
|
||||||
preg_match( '/TX packets:(\d+)/',$strWlan0,$result );
|
preg_match( '/TX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data';
|
||||||
$strTxPackets = $result[1];
|
$strTxPackets = $result[1];
|
||||||
preg_match( '/RX bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result );
|
preg_match( '/RX bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result ) || $result[1] = 'No Data';
|
||||||
$strRxBytes = $result[1];
|
$strRxBytes = $result[1];
|
||||||
preg_match( '/TX Bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result );
|
preg_match( '/TX Bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result ) || $result[1] = 'No Data';
|
||||||
$strTxBytes = $result[1];
|
$strTxBytes = $result[1];
|
||||||
preg_match( '/ESSID:\"([a-zA-Z0-9\s]+)\"/i',$strWlan0,$result );
|
preg_match( '/ESSID:\"([a-zA-Z0-9\s]+)\"/i',$strWlan0,$result );
|
||||||
$strSSID = str_replace( '"','',$result[1] );
|
$strSSID = str_replace( '"','',$result[1] );
|
||||||
|
@ -83,6 +83,8 @@ function create_raspap_directories() {
|
|||||||
sudo mv $raspap_dir $raspap_dir.original || install_error "Unable to move old '$raspap_dir' out of the way"
|
sudo mv $raspap_dir $raspap_dir.original || install_error "Unable to move old '$raspap_dir' out of the way"
|
||||||
fi
|
fi
|
||||||
sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'"
|
sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'"
|
||||||
|
# Create a directory for existing file backups.
|
||||||
|
sudo mkdir -p "$raspap_dir/backups"
|
||||||
|
|
||||||
sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'"
|
sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'"
|
||||||
}
|
}
|
||||||
@ -108,6 +110,17 @@ function change_file_ownership() {
|
|||||||
sudo chown -R $raspap_user:$raspap_user "$webroot_dir" || install_error "Unable to change file ownership for '$webroot_dir'"
|
sudo chown -R $raspap_user:$raspap_user "$webroot_dir" || install_error "Unable to change file ownership for '$webroot_dir'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check for existing /etc/network/interfaces and /etc/hostapd/hostapd.conf files
|
||||||
|
function check_for_old_configs() {
|
||||||
|
if [ -f /etc/network/interfaces ]; then
|
||||||
|
sudo mv /etc/network/interfaces "$raspap_dir/backups"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/hostapd/hostapd.conf ]; then
|
||||||
|
sudo mv /etc/hostapd/hostapd.conf "$raspap_dir/backups"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Move configuration file to the correct location
|
# Move configuration file to the correct location
|
||||||
function move_config_file() {
|
function move_config_file() {
|
||||||
if [ ! -d "$raspap_dir" ]; then
|
if [ ! -d "$raspap_dir" ]; then
|
||||||
@ -178,6 +191,7 @@ function install_raspap() {
|
|||||||
install_dependencies
|
install_dependencies
|
||||||
enable_php_lighttpd
|
enable_php_lighttpd
|
||||||
create_raspap_directories
|
create_raspap_directories
|
||||||
|
check_for_old_configs
|
||||||
download_latest_files
|
download_latest_files
|
||||||
change_file_ownership
|
change_file_ownership
|
||||||
move_config_file
|
move_config_file
|
||||||
|
Loading…
Reference in New Issue
Block a user