#!/bin/bash SCRIPT="index.cgi" SCRIPT_SET="set.cgi" SRC="/opt/adwarfg/www/cgi_common.sh" . $SRC load_settings [ -r "$WEBIMPORT" ] && . "$WEBIMPORT" g_serverurl=${g_serverurl:-$DEF_SERVER} echo "Content-type: text/html" echo "Cache-Control: no-cache" echo "Pragma: no-cache" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "Dwarfguard Agent" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "

Dwarfguard Agent

" echo "" echo "" echo "" echo "" echo "" echo "
" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "
Status
" echo "" echo "" echo "
General Info
" echo "
" echo "" echo "" echo "
System Logs
" echo "
Configuration
" echo "" echo "" echo "
Global
" echo "
" echo "" echo "" echo "
Log Levels
" echo "
General
" echo "" echo "" echo "
Return
" echo "
" echo "
" echo "
" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "
Dwarfguard General Information
" echo "
" echo "" echo " " echo " " echo "" echo " " echo "" echo " " echo "" echo " " echo "" echo " " echo "" echo "" echo " " echo "" echo "
Dwarfguard server URL/IP:" if [ -z "$g_serverurl" ] ; then echo " URL is empty, agent initialization is probably not yet finished." fi echo " $g_serverurl" echo " " echo "
Device Dwarfguard ID:" echo " " if [ -z "$g_devid" ] ; then echo "Not registered" else echo "$g_devid" fi echo "" echo " " echo "
Agent version:" echo " $AGVER" echo " " echo "
Agent PID:" echo " " OASTR="$AGENTPID" ASTR="$OASTR" COLORSTYLE="" if [[ -z "$AGENTPID" || 0 -eq "$AGENTPID" ]] ; then COLORSTYLE="style=\"color:red\"" ASTR="Agent is not running..." else if [[ -n "$pcnt_errors" && "$pcnt_errors" -gt 0 ]] ; then COLORSTYLE="style=\"color:red\"" ASTR="$ASTR, errors: $pcnt_errors" fi if [[ -n "$pcnt_connfails" && "$pcnt_connfails" -gt 0 ]] ; then [ -z "$COLORSTYLE" ] && COLORSTYLE="style=\"color:orange\"" ASTR="$ASTR, connection errors: $pcnt_connfails" fi fi echo "$ASTR" echo "" echo " " echo "
Next sync with server:" if [ -n "$time_target" ] ; then ATIME=$(date "+%T") echo " $time_target (localtime is $ATIME)" else echo " time is being calculated..." fi echo " " echo "
Actions:" if [ 0 -eq "$AGENTPID" ] ; then echo "

" else echo "

" fi if [ -n "$time_target" ] ; then echo "

" fi echo "
" # in there, status - registered/not registered, Dwarfguard device ID (e.g. ABBA), agent PID and server URL is to be shown # server URL change should lead to the connection menu item (below) echo "
  • " if [ -z "$g_serverurl" ] ; then echo "
    • Agent initialization incomplete!
    • " echo "
    • Detected empty server URL. This typically means you are loading this page before agent initialization is complete. If you see this message more than a minute after agent installation, something went wrong. You may attempt setting the server URL in settings but agent removal and new installation is usually a better option.
  • " else echo "performing ping to $g_serverurl ... " if (test -n "$g_serverurl" && ping -c 1 "$g_serverurl" 2>/dev/null 1>&2); then echo "OK" PINGOK="123" else echo "FAILED." PINGOK="" fi if [ -n "$PINGOK" ] ; then echo "
  • Dwarfguard service health check... " MRES=$(curl --connect-timeout 10 -k -s https://"$g_serverurl"/dwarfg/d/h) if [ $? -ne 0 ] ; then echo "FAILED (is Dwarfguard installed on $g_serverurl?).
  • " else MPID="${MRES%%/*}" if [ "$MPID" != "${MPID//[^0-9]}" ] ; then echo "FAILED - invalid response (is Dwarfguard installed on $g_serverurl?)." elif [ "$MPID" -eq 0 ] ; then echo "FAILED - Dwarfguard daemon not running." else echo "OK." fi fi fi fi echo "
" echo "
" echo "
" echo "
" echo "" echo "" exit 0