Skip to content

Commit

Permalink
Fixed smarthtml.cgi
Browse files Browse the repository at this point in the history
  • Loading branch information
gSpotx2f committed Jan 31, 2020
1 parent 97457bd commit 69841d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
6 changes: 4 additions & 2 deletions opt/etc/smarthtml.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEMP_HISTORY=1
LOG_ALL=0
### Partitions info - fdisk support (0 - disable; 1 - enable)
USE_FDISK=1
### Capacity warning (in %)
### Capacity warning (%)
FS_CAPACITY_LIMIT_WARNING=90
### Write critical warnings to syslog (0 - disable; 1 - enable)
USE_LOGGER=1
Expand All @@ -31,7 +31,9 @@ USE_RRD=1
RRD_DB_PRESET=3
### S.M.A.R.T. attributes for RRD
RRD_SMART_ATTRS="smart3 smart190 smart194" # Spin-up time & temperature
#RRD_SMART_ATTRS="smart190 smart194" # Only a temperature data for RRD
#RRD_SMART_ATTRS="smart190 smart194" # Only a temperature data for RRD
RRD_SMART_ATTR_DEF_PIC="smart190 smart194"
### CGI-module smarthtml.cgi (0 - disable; 1 - enable)
USE_CGI_MODULE=0
CGI_USE_SUDO=0
CGI_SUDO_USER="admin"
40 changes: 26 additions & 14 deletions opt/share/www/cgi-bin/smarthtml.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,50 @@

########################################################################
#
# This is a part of S.M.A.R.T.Html v1.0 (c) 2018
# S.M.A.R.T.Html v1.0 (c) 2018
#
# Author: gSpot at wl500g.info
# License: GPLv3
# Author: gSpot <https://github.com/gSpotx2f/smarthtml>
# License: GPLv3
# Depends: smartmontools
# Recommends: rrdtool, sendmail, openssl, sudo
#
########################################################################

export PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin"
############################## Settings ################################
CGI_USE_SUDO=0
CGI_SUDO_USER="admin"

############################# Base config ##############################
export NAME="smarthtml"
export PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
export LANG="en_US.UTF-8"
SEDCMD="sed"
SMARTHTMLCMD="/opt/usr/bin/smarthtml.sh"
SUDOUSER="admin"
USE_SUDO=0
export LANGUAGE="en"

### External config
CONFIG_FILE="/opt/etc/${NAME}.conf"
[ -f "$CONFIG_FILE" ] && . "$CONFIG_FILE"

SED_CMD="sed"
SMARTHTML_CMD="/opt/usr/bin/smarthtml.sh"

SUDOCMD=`which sudo`
if [ $USE_SUDO -eq 1 -a $? -eq 0 ]; then
SMARTHTMLCMD="${SUDOCMD} -u ${SUDOUSER} ${SMARTHTMLCMD}"
if [ $CGI_USE_SUDO -eq 1 -a $? -eq 0 ]; then
SMARTHTML_CMD="${SUDOCMD} -u ${CGI_SUDO_USER} ${SMARTHTML_CMD}"
fi

eval `echo "${QUERY_STRING} " | $SEDCMD -e 's/[)(;\`\\]//g' -e 's/&/\; /g'`
############################ Main section ##############################
eval `echo "${QUERY_STRING} " | $SED_CMD -e 's/[)(;\`\\]//g' -e 's/&/\; /g'`
printf "Content-type: text/html; charset=utf-8\n\n"

case $call in
refresh)
$SMARTHTMLCMD norrd
$SMARTHTML_CMD norrd
;;
resetwarn)
$SMARTHTMLCMD resetwarn && $SMARTHTMLCMD norrd
$SMARTHTML_CMD resetwarn && $SMARTHTML_CMD norrd
;;
resetcount)
$SMARTHTMLCMD resetcount && $SMARTHTMLCMD norrd
$SMARTHTML_CMD resetcount && $SMARTHTML_CMD norrd
;;
*)
echo "Error! Wrong call (${call})..."
Expand Down

0 comments on commit 69841d3

Please sign in to comment.