mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Add _usb_info, _wpa_info and -w --write option
This commit is contained in:
parent
54e154c01a
commit
9663832f0d
@ -12,7 +12,7 @@
|
|||||||
# Usage: debuglog.sh [options]
|
# Usage: debuglog.sh [options]
|
||||||
#
|
#
|
||||||
# OPTIONS:
|
# OPTIONS:
|
||||||
# -p, --path Overrides the debug logfile write path (/tmp)
|
# -w, --write Writes the debug log to /tmp (useful if sourced directly)
|
||||||
# -i, --install Overrides the default RaspAP install location (/var/www/html)
|
# -i, --install Overrides the default RaspAP install location (/var/www/html)
|
||||||
#
|
#
|
||||||
# NOTE
|
# NOTE
|
||||||
@ -35,8 +35,9 @@ readonly DNSMASQ_D_DIR="/etc/dnsmasq.d"
|
|||||||
readonly RASPAP_DHCDPCD="/etc/dhcpcd.conf"
|
readonly RASPAP_DHCDPCD="/etc/dhcpcd.conf"
|
||||||
readonly RASPAP_HOSTAPD="$RASPAP_DIR/hostapd.ini"
|
readonly RASPAP_HOSTAPD="$RASPAP_DIR/hostapd.ini"
|
||||||
readonly RASPAP_PROVIDER="$RASPAP_DIR/provider.ini"
|
readonly RASPAP_PROVIDER="$RASPAP_DIR/provider.ini"
|
||||||
|
readonly RASPAP_LOGPATH="/tmp"
|
||||||
|
readonly RASPAP_LOGFILE="$RASPAP_LOGPATH/raspap_debug.log"
|
||||||
readonly RASPAP_DEBUG_VERSION="1.0"
|
readonly RASPAP_DEBUG_VERSION="1.0"
|
||||||
|
|
||||||
readonly PREAMBLE="
|
readonly PREAMBLE="
|
||||||
888888ba .d888888 888888ba
|
888888ba .d888888 888888ba
|
||||||
88 8b d8 88 88 8b
|
88 8b d8 88 88 8b
|
||||||
@ -74,14 +75,13 @@ function _main() {
|
|||||||
|
|
||||||
function _parse_params() {
|
function _parse_params() {
|
||||||
# default option values
|
# default option values
|
||||||
logfile_path="/tmp"
|
|
||||||
install_dir="/var/www/html"
|
install_dir="/var/www/html"
|
||||||
|
writelog=0
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
case "${1-}" in
|
case "${1-}" in
|
||||||
-p|--path)
|
-w|--write)
|
||||||
logfile_path="$2"
|
writelog=1
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
-i|--install)
|
-i|--install)
|
||||||
install_dir="$2"
|
install_dir="$2"
|
||||||
@ -101,11 +101,12 @@ function _parse_params() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _generate_log() {
|
function _generate_log() {
|
||||||
timestamp=$(date)
|
_log_write "Debug log generation started at $(date)"
|
||||||
_log_write "Debug log generation started at ${timestamp}"
|
|
||||||
_system_info
|
_system_info
|
||||||
_packages_info
|
_packages_info
|
||||||
_raspap_info
|
_raspap_info
|
||||||
|
_usb_info
|
||||||
|
_wpa_info
|
||||||
_dnsmasq_info
|
_dnsmasq_info
|
||||||
_interface_info
|
_interface_info
|
||||||
_routing_info
|
_routing_info
|
||||||
@ -116,6 +117,7 @@ function _generate_log() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fetches hardware, OS, uptime & used memory
|
||||||
function _system_info() {
|
function _system_info() {
|
||||||
local model=$(tr -d '\0' < /proc/device-tree/model)
|
local model=$(tr -d '\0' < /proc/device-tree/model)
|
||||||
local system_uptime=$(uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/){if ($9=="min") {d=$6;m=$8} else {d=$6;h=$8;m=$9}} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')
|
local system_uptime=$(uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/){if ($9=="min") {d=$6;m=$8} else {d=$6;h=$8;m=$9}} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')
|
||||||
@ -128,6 +130,7 @@ function _system_info() {
|
|||||||
_log_write "Memory Usage: ${free_mem}%"
|
_log_write "Memory Usage: ${free_mem}%"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Outputs installed package versions
|
||||||
function _packages_info() {
|
function _packages_info() {
|
||||||
local php_version=$(php -v | grep -oP "PHP \K[0-9]+\.[0-9]+.*")
|
local php_version=$(php -v | grep -oP "PHP \K[0-9]+\.[0-9]+.*")
|
||||||
local dnsmasq_version=$(dnsmasq -v | grep -oP "Dnsmasq version \K[0-9]+\.[0-9]+")
|
local dnsmasq_version=$(dnsmasq -v | grep -oP "Dnsmasq version \K[0-9]+\.[0-9]+")
|
||||||
@ -142,6 +145,7 @@ function _packages_info() {
|
|||||||
_log_write "vnStat Version: ${vnstat_version}"
|
_log_write "vnStat Version: ${vnstat_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Outputs installed RaspAP version & settings
|
||||||
function _raspap_info() {
|
function _raspap_info() {
|
||||||
local version=$(grep "RASPI_VERSION" $install_dir/includes/defaults.php | awk -F"'" '{print $4}')
|
local version=$(grep "RASPI_VERSION" $install_dir/includes/defaults.php | awk -F"'" '{print $4}')
|
||||||
local hostapd_ini=$(cat ${RASPAP_HOSTAPD} || echo "Not present")
|
local hostapd_ini=$(cat ${RASPAP_HOSTAPD} || echo "Not present")
|
||||||
@ -153,6 +157,19 @@ function _raspap_info() {
|
|||||||
_log_write "RaspAP provider.ini: ${provider_ini}"
|
_log_write "RaspAP provider.ini: ${provider_ini}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _usb_info() {
|
||||||
|
local stdout=$(lsusb)
|
||||||
|
_log_separator "USB DEVICES"
|
||||||
|
_log_write "${stdout}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _wpa_info() {
|
||||||
|
local stdout=$(wpa_cli status)
|
||||||
|
_log_separator "WPA SUPPLICANT"
|
||||||
|
_log_write "${stdout}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Iterates the contents of RaspAP's 090_*.conf files in dnsmasq.d
|
||||||
function _dnsmasq_info() {
|
function _dnsmasq_info() {
|
||||||
local stdout=$(ls -h ${DNSMASQ_D_DIR}/090_*.conf)
|
local stdout=$(ls -h ${DNSMASQ_D_DIR}/090_*.conf)
|
||||||
local contents
|
local contents
|
||||||
@ -220,7 +237,7 @@ function _output_preamble() {
|
|||||||
_log_write "${PREAMBLE}\n"
|
_log_write "${PREAMBLE}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determines host Linux distribution details
|
# Fetches host Linux distribution details
|
||||||
function _get_linux_distro() {
|
function _get_linux_distro() {
|
||||||
if type lsb_release >/dev/null 2>&1; then # linuxbase.org
|
if type lsb_release >/dev/null 2>&1; then # linuxbase.org
|
||||||
OS=$(lsb_release -si)
|
OS=$(lsb_release -si)
|
||||||
@ -241,6 +258,9 @@ function _get_linux_distro() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _initialize() {
|
function _initialize() {
|
||||||
|
if [ -e "${RASPAP_LOGFILE}" ]; then
|
||||||
|
rm "${RASPAP_LOGFILE}"
|
||||||
|
fi
|
||||||
_get_linux_distro
|
_get_linux_distro
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +276,12 @@ function _log_separator(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _log_write() {
|
function _log_write() {
|
||||||
echo -e "${@}"
|
if [ "${writelog}" = 1 ]; then
|
||||||
|
echo -e "${@}" | tee -a $RASPAP_LOGFILE
|
||||||
|
else
|
||||||
|
echo -e "${@}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_main "$@"
|
_main "$@"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user