| Server IP : 118.27.122.248 / Your IP : 216.73.217.142 Web Server : Apache System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64 User : c9415830 ( 11735) PHP Version : 8.4.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/jp-secure/siteguardlite/ |
Upload File : |
#!/bin/sh
#
# dbupdate_waf -- script for updating databases.
# -- for SiteGuard Lite
# -- use wget command to retrieve latest-lite.zip
# -- get the latest pattern file from ${LATEST_URL} to ${databasedirectory}
# -- write update log to log/dbupdate_waf.log
#
export LANG=C
export PATH=$PATH:/usr/local/bin
PRODUCT=siteguardlite
prefix=/opt/jp-secure/siteguardlite
OS=`uname -s`
WGET_CMD=wget
TRIAL=`grep -c 'TRIAL' $prefix/conf/license.txt`
WGET_OPTION="--timeout=5 --tries=1 --cache=off --ca-certificate=${prefix}/misc/ca-cert.crt"
logdir=$prefix/logs
resultfile=$logdir/get_version_result.txt
tmpdirectory=./tmp
### Read Configuration file###
for var in use_proxy http_proxy_host http_proxy_port use_proxyauth http_proxyauth_user http_proxyauth_pass sig_download_user sig_download_pass use_getversion ; do
eval ${var}="\`perl -ne 'if(/^${var}=(.*)/){\$v=\$1; \$v =~ s/([^\w\.\-])/chr(0x25) . sprintf(\"%02x\", ord(\$1))/eg; print \$v;}' conf/dbupdate.conf\`" # '
done
if [ -r conf/dbupdate_waf.conf ] ; then
. conf/dbupdate_waf.conf
fi
### ADD URL conf file
if [ -r conf/dbupdate_waf_url.conf ] ; then
. conf/dbupdate_waf_url.conf
fi
INI_URL=${LATEST_URL%/*}/
if [ "${use_proxy}" = "yes" ] ; then
if [ "${use_proxyauth}" = "yes" ];then
export https_proxy="http://${http_proxyauth_user}:${http_proxyauth_pass}@${http_proxy_host}:${http_proxy_port}/"
else
export https_proxy="http://${http_proxy_host}:${http_proxy_port}/"
fi
fi
USER_AUTH="--http-user=${sig_download_user} --http-password=${sig_download_pass}"
message(){
if $tty; then
echo "$*"
fi
}
error(){
if $tty; then
echo `basename $0`: "$*" >&2
fi
}
usage(){
message "Usage:"
message
message "$0 [-f <targetfile>"
message "default file: version.ini"
message
exit 1
}
parsecommandline() {
verfile="version.ini"
while [ "$#" != 0 ]; do
case $1 in
-v)
tty=true
;;
-f)
shift
verfile=$1
;;
--help)
usage
;;
-*)
error "Invalid option $1"
usage
;;
*)
# We already got update directory
error "Too many arguments"
usage
;;
esac
shift
done
}
parsecommandline $*
cd $prefix || (echo "Cannot change to directory [$prefix]"; exit 1)
cd $tmpdirectory || (echo "Cannot change to directory [$tmpdirectory]"; exit 1)
if [ "${verfile}" = "header.ini" ]; then
resultfile=$logdir/get_header_result.txt
fi
#if [ -e ${verfile} ]; then
# rm -fr ${verfile}
#fi
if [ $TRIAL -ge 1 ]; then
error "Can not connect because of trial or use_getversion is no."
exit 1
fi
if [ -n ${use_getversion} ]; then
if [ "X${use_getversion}" = "Xno" ]; then
error "Can not connect because of trial or use_getversion is no."
exit 1
fi
fi
# Time Check
if [ -e "${verfile}.tmp" ]; then
# if [ $(( $(date +%s)0 - $(stat -c %Y "${verfile}.tmp")0 )) -le $((60 * 60 * 24)) ];then
# if [ "$(find "${verfile}.tmp" -mmin -$((60*24)) | wc -l)" -ne 0 ];then
if [ ${OS} = 'FreeBSD' ]; then
if [ "$(find "${verfile}.tmp" -mmin -$((60*24)) | wc -l)" -ne 0 ];then
if [ -e ${verfile} ]; then
cat ${verfile}
exit 0;
fi
fi
else
if [ "$(find "${verfile}.tmp" -mtime -1 | wc -l)" -ne 0 ];then
if [ -e ${verfile} ]; then
cat ${verfile}
exit 0;
fi
fi
fi
fi
which $WGET_CMD >/dev/null 2>&1
result=$?
if [ $result -eq 1 ]; then
error "wget command not found."
exit 1
fi
${WGET_CMD} ${WGET_OPTION} --header="License-No: ${LICENSE}" --header="Version-No:${VERSION}" --header="SGL-Version:${SGL_VERSION}" ${USER_AUTH} ${INI_URL}${verfile} -O ${verfile} >$resultfile 2>&1
result=$?
if egrep "[Ff]ailed:? " $resultfile >/dev/null 2>&1 ; then
result_str=`perl -ne 'print "$1\n" if/[Ff]ailed:? (.*)$/' $resultfile | head -n1`
else
result_str=`cat $resultfile | tail -1`
fi
if [ $result != 0 ]; then
error "Get Version failed. Error code: $result msg: $result_str"
echo $result_str
exit 1
fi
cat ${verfile}
touch "${verfile}.tmp"
exit 0;