cgi脚本

[root@IDC4414_YXF_2-1_jx2wzGS13 cgi-bin]# more *.exe
::::::::::::::
coverage.exe
::::::::::::::
#!/bin/bash
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
PAT="/home/xmission/"
[ $(ls "$PAT"tmp/ -l|grep -c 'tmp_[0-9]\+$') -ne 1 ] && { echo 0;exit;}
PKG_NAME='gs.tar.gz'
SOURCE_DIR=$(ls "$PAT"tmp/ -l|grep -o '\<tmp_[0-9]\+$')
TARGET_DIR="$PAT"'jxonline2'
TARGET_DIR1=$TARGET_DIR"/gs1"
TARGET_DIR2=$TARGET_DIR"/gs2"
TARGET_DIR3=$TARGET_DIR"/gs3"
TARGET_DIR4=$TARGET_DIR"/gs4"
TARGET_DIR5=$TARGET_DIR"/gs5"
BAK_DIR="$PAT"'tmp/autoupdate_bak'
if [ ! -d "$TARGET_DIR" ]
then
    mkdir -p $TARGET_DIR && chown xmission:xmission $TARGET_DIR || { echo 0;exit;}
fi
if [ ! -d "$TARGET_DIR1" ]
then
    mkdir -p $TARGET_DIR1 && chown xmission:xmission $TARGET_DIR1 || { echo 0;exit;}
fi
if [ ! -d "$TARGET_DIR2" ]
then
    mkdir -p $TARGET_DIR2 && chown xmission:xmission $TARGET_DIR2 || { echo 0;exit;}
fi
if [ ! -d "$TARGET_DIR3" ]
then
    mkdir -p $TARGET_DIR3 && chown xmission:xmission $TARGET_DIR3 || { echo 0;exit;}
fi
if [ ! -d "$TARGET_DIR4" ]
then
    mkdir -p $TARGET_DIR4 && chown xmission:xmission $TARGET_DIR4 || { echo 0;exit;}
fi
if [ ! -d "$TARGET_DIR5" ]
then
    mkdir -p $TARGET_DIR5 && chown xmission:xmission $TARGET_DIR5 || { echo 0;exit;}
fi
if [ -d "$PAT"tmp/${SOURCE_DIR} ]
then
    cd "$PAT"tmp/${SOURCE_DIR} && {
    pkg_name=$(ls "$PAT"tmp/$SOURCE_DIR -l|grep -o '\<[^ ]*\(gz\|bz2\)$')
#    uncompress_name=$(tar ztf $pkg_name|head -1|awk -F"/" '{print $1}')
uncompress_name='gs'
    tar xzf $pkg_name && chmod 777 -R ./${uncompress_name}  && cp -rf ./${uncompress_name}/* $TARGET_DIR1 || { echo 0;exit;}
cp -rf ./${uncompress_name}/* $TARGET_DIR2
cp -rf ./${uncompress_name}/* $TARGET_DIR3
cp -rf ./${uncompress_name}/* $TARGET_DIR4
cp -rf ./${uncompress_name}/* $TARGET_DIR5
#echo "update ok!  `date -R `"
#exit 0
 #  tar zxf $pkg_name && chmod 777 -R ./gs && cp -rf ./gs/* $TARGET_DIR || { echo 0 ;exit;}
    } || { echo 0 ;exit;}
fi
echo 1
if [ ! -d ${BAK_DIR} ]
then
    mkdir -p ${BAK_DIR}
fi
if [ -d "$PAT"tmp/${SOURCE_DIR} ]
then
    mv -f "$PAT"tmp/${SOURCE_DIR}/${PKG_NAME} ${BAK_DIR}/${PKG_NAME%%.*}.$(date +%Y%m%d"_"%T).tar.gz
        if [ `ls -l ${BAK_DIR}|awk 'END{print --NR}'` -gt 10 ]
        then
                rm -rf ${BAK_DIR}/$(ls -1tr ${BAK_DIR}|head -1)
        fi
fi
exit 0
::::::::::::::
download.exe
::::::::::::::
#!/bin/bash
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
echo "1"
#echo "`date -R`"
#echo "Do downloading ...."
/usr/local/apache2/cgi-bin/downupfile.exe&
exit 0
::::::::::::::
downupfile.exe
::::::::::::::
#!/bin/bash
#downupfile.sh
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
   
PKG_URL='http://219.239.93.156/'
PKG_NAME='gs.tar.gz'
MD5_FILE='md5.txt'
KEY=$$
STATUS_FILE='status.txt'
GETOPTS=" -t 3 -T 60 "
PAT="/home/xmission/"
echo 1
cd $PAT
#func
getfile_()
{
        wget $GETOPTS ${PKG_URL}${PKG_NAME} >/dev/null 2>&1
        wget $GETOPTS ${PKG_URL}${MD5_FILE} >/dev/null 2>&1
}
getMD5sum_()
{
        if [ -f $PKG_NAME ];then
                MD5_LOCAL=$(md5sum $PKG_NAME|cut -d' ' -f1)
         else
                MD5_LOCAL=''
        fi
   
        if [ -s $MD5_FILE ];then
                MD5_REMOTE=$(awk -F"|" -v name=$PKG_NAME '$1==name{print substr($2,1,32)}' $MD5_FILE)
          else
                    MD5_REMOTE=''
        fi
}
clean_()
{
        cd "$PAT" && chmod 777 -R "$PAT"tmp/tmp_[0-9]* 
        rm -rf ./tmp/tmp_[0-9]*
}
init_()
{
        mkdir -p "$PAT"tmp/tmp_$KEY && cd "$PAT"tmp/tmp_$KEY || { echo 2;exit;}
        [ ! -f $STATUS_FILE ] && touch $STATUS_FILE || : > $STATUS_FILE
        echo "down:0" > $STATUS_FILE
}
#main
clean_
init_
getfile_
getMD5sum_
count=5
  until [ $count -eq 0 ]
    do
                 if [ -z "$MD5_LOCAL" -o  -z "$MD5_REMOTE" ];then
        rm -rf ${PKG_NAME} ${MD5_FILE}
         getfile_
         getMD5sum_
         count=`expr $count - 1`
         if [ $count -eq 1 ];then
             echo 'down:-1' > $STATUS_FILE
             exit 0
          fi
      elif [ "$MD5_LOCAL" != "$MD5_REMOTE" ];then
         rm -rf ${PKG_NAME} ${MD5_FILE}
         getfile_
         getMD5sum_
         count=`expr $count - 1`
         if [ $count -eq 1 ];then
             echo 'down:-2' > $STATUS_FILE
             exit 0
          fi
     else
          echo  "down:1" > $STATUS_FILE
          exit 0
     fi
   done
if [ $? != 0 ];then
 echo 'down:-1' > $STATUS_FILE
fi
exit 0
::::::::::::::
getinfo.exe
::::::::::::::
#!/bin/bash
#getinfo wrote by vilon 2009-03-10 9:03
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
HNAME=`hostname`
IDC_NUM=`echo $HNAME|awk -F "_" '{print $1}'`
IPADDR=`ifconfig  |grep addr |grep -v Base |grep -v 127.0.0.1`
IPINFO=`echo $IPADDR |awk '{ print $1,$4,$5,$7,"",$10,$13,$14,$16 }'`
# get CPU info
CPU_MODEL=`cat /proc/cpuinfo|grep "model name"`
CPU_NUM=`cat /proc/cpuinfo  |grep "model name" |wc -l`
CPU=`echo $CPU_MODEL |awk -F "model name :" '{print $2}'`'[*'$CPU_NUM']'
#get Memory
MEN=`free -m|grep Mem|awk '{print $2}'`"M"
#DISK info
DISK_TYPE=`dmesg|grep Vendor`
DISK_SIZE=`dmesg|grep "MB)"`
#NetCard
NETCARD=`dmesg  |grep eth |grep Connection |awk '{print $2 " "$4" "$5}'`
echo "\""$HNAME"\""
echo "\""$IPINFO"\""
echo "\""$CPU"\""
echo "\""$MEN"\""
echo "\""$DISK_TYPE"\" \""$DISK_SIZE"\""
echo "\""$NETCARD"\""
exit 0
::::::::::::::
start.exe
::::::::::::::
#!/bin/bash
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
if [ ! -f /home/xmission/jxonline2/jx2gs.start ]
then
    echo 0
    exit 1
fi
cd /home/xmission/jxonline2;./jx2gs.start 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
    echo 0
    exit 1
fi
echo 1
exit 1
::::::::::::::
testdownload.exe
::::::::::::::
#!/bin/bash
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
PAT="/home/xmission/"
[ $(ls "$PAT"tmp/ -l|grep -c 'tmp_[0-9]\+$') -ne 1 ] && { echo 0;exit;}
STATUS_FILE='status.txt'
SOURCE_DIR=$(ls "$PAT"tmp/ -l|grep -o '\<tmp_[0-9]\+$')
if [ -f "$PAT"tmp/${SOURCE_DIR}/${STATUS_FILE} ]
then
    status=$(awk -F: '/^down/{print $2}'  "$PAT"tmp/${SOURCE_DIR}/${STATUS_FILE})
    if [ ! -z "$status" ]
    then
        echo $status
    else
        echo 0
        exit 1
    fi
fi
exit 0
::::::::::::::
test.exe
::::::::::::::
#!/bin/bash
echo "Content-type: text/plain; charset=iso-8859-1"
echo ""
status=$(ps -e | awk '{print $4}'| grep SO2GameSvrD | wc -l)
if [ $status -ne 0 ]
then
        echo 1
else
        echo 0
        exit 1
fi
exit 0


你可能感兴趣的:(cgi脚本)