B / Y / U / S
HOME À¥ È£½ºÆà µµ¸ÞÀÎ ¸Å´º¾ó °í°´Áö¿ø ¼³Á¤Á¤º¸ °èÁ¤½Åû 2024-12-30 Monday 
À¥ È£½ºÆÃ
# °øÁö »çÇ×
# ÀÚÁÖ ¹¯´Â Áú¹®
# Áú¹®°ú ´äº¯
# °¡ÀÔ ¹®ÀÇ
Ä¿¹Â´ÏƼ
# ÀÚÀ¯°Ô½ÃÆÇ
# ¸®´ª½ºÆÁ
# ¾ÆÀÌÅ¥ Å×½ºÆ®
# ³»È¨ ¼Ò°³
# °Ö·¯¸®
# ÀÚ·á½Ç

  ¸®´ª½ºÆÁ  Go Unix Power Tools Online Book Go Bash Guide
Read No. 138 article 2002-04-24 20:20:00
NickName   Ç®ºñ´©
Subject   webalizer È£½ºÆÃ¿ë °¡»óÈ£½ºÆà ºÐ¼® µî·Ï ½ºÅ©¸³Æ®
¹öÁ¯ : 0.2

»ç¿ëÇϽǶ§ /etc/webalizer/
¾Æ·¡¿¡ sed ¿ë µðÆúÆ® ÆÄÀÏÀÌ Á¸ÀçÇØ¾ß ÇÕ´Ï´Ù. ¾Æ·¡ ½ºÅ©¸³
È®ÀÎÇÏ½Ã¸é ¸¸µå½Ç ¼ö ÀÖÀ» °Ì´Ï´Ù ^^;

#!/bin/bash

# webalizer log add script 
# date: 2002.4.22
# editor: son hee tae

# 1. °èÁ¤³»¿¡ public_html/logs Æú´õ »ý¼º
# 2. /etc/webalizer -> /etc/webalizer/domain.com.conf
# 3. /etc/cron.daily/webalizer add

echo 
echo 
echo 
######################
### ºÐ¼® ½ÃÀÛ ÇÔ¼ö ###
######################

execalizer() {
echo -n "ºÐ¼®À» Å×½ºÆ®°â ½Ãµµ ÇØ º¸½Ã°Ú½À´Ï±î? [N/y] (default N) "
read execok
if [ "$execok" == "y" ] || [ "$execok" == "Y" ];then
/usr/bin/webalizer -c /etc/webalizer/$servername.conf
echo 
echo "ºÐ¼®°á°ú´Â http://$servername/logs ¿¡¼­ È®ÀÎÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù"
fi
}

#####################
### cron add ÇÔ¼ö ###
#####################

cronadd(){

### ÀÌ¹Ì µî·ÏµÇ¾î ÀÖ´ÂÁö È®ÀÎ
if (( $(cat /etc/cron.daily/webalizer|grep -c $servername) > 0 )); then
echo "/etc/cron.daily/webalizer ÆÄÀÏ¿¡ ÀÌ¹Ì µî·ÏÀÌ µÇ¾î ÀÖ½À´Ï´Ù"

else 
### cron ¿¡ µî·Ï 

echo "### °èÁ¤¸í: $account µµ¸ÞÀθí: $servername ½ºÅ©¸³Ãß°¡ÀÏ: $(date +%
Y%m%d) " >> /etc/cron.daily/webalizer
echo "/usr/bin/webalizer -c /etc/webalizer/$servername.conf" 
>> /etc/cron.daily/webalizer
echo "/etc/cron.daily/webalizer ¿¡ Á¤»óÀûÀ¸·Î Ãß°¡ µÇ¾ú½À´Ï´Ù"
echo "============================================================="yy
tail /etc/cron.daily/webalizer
echo "============================================================="yy
fi

}


##########################
### log file find ÇÔ¼ö ###
##########################

logfilefind() {

### µµ¸ÞÀÎ ³×ÀÓ º¯¼ö È®ÀÎ
if [ ! $servername ]; then
echo "µµ¸ÞÀÎ ³×ÀÓÀÌ ÁöÁ¤µÇÁö ¾Ê¾È½À´Ï´Ù "
exit
fi

logfilename=$(cat /etc/httpd/conf/httpd.conf|egrep -A7 $account|grep -
A7 "public_html$"|grep "access"|awk '{print $2}'|sed s/"logs\/"//g)
echo
cat /etc/httpd/conf/httpd.conf|grep -A7 $account|grep -A7 "public_html$"
echo
echo -n "### ·Î±×ÆÄÀÏÀÌ $logfilename ÀÌ ¸Â½À´Ï±î? [Y/n] (default y) "
read logfileok
if [ "$logfileok" == "n" ] || [ "$logfileok" == "N" ]; then
echo -n "### ·Î±× ÆÄÀÏ À̸§À» Àû¾îÁÖ¼¼¿ä : "
read logfilename
fi
}

####################################
### webalizer configuration ÇÔ¼ö ###
####################################

addweblog() {


### logfinename º¯¼ö°¡ ºó°æ¿ì 
if [ ! $logfilename ]; then
echo "logfilename ÀÌ ¾ø½À´Ï´Ù ½ºÅ©¸³À» Á¾·áÇÕ´Ï´Ù"
exit
fi

### µµ¸ÞÀÎ ³×ÀÓ º¯¼ö È®ÀÎ
if [ ! $servername ]; then
echo "µµ¸ÞÀÎ ³×ÀÓÀÌ ÁöÁ¤µÇÁö ¾Ê¾È½À´Ï´Ù "
exit
fi

### sed »ý¼º 
echo "s|###logfileinput|LogFile         /var/log/httpd/$logfilename|g" 
> /tmp/change.temp
echo "s|###outputdirinput|OutputDir     $which/public_html/logs/|g" 
>> /tmp/change.temp
echo "s|###hostnameinput|HostName       $servername|g" 
>> /tmp/change.temp
echo "sed Á¤º¸ »ý¼º /tmp/change.temp "
cat /tmp/change.temp

### sed Á¤º¸ È®ÀÎ 
echo
echo -n "### sed Á¤º¸°¡ Á¤È®Çմϱî? [Y/n] (default Y) "
read sedok
if [ "$edok" == "n" ] || [ "$sedok" == "N" ]; then
echo "´Ù½Ã ½ÃÀÛÇϽñ⠹ٶø´Ï´Ù"
exit
fi

### webalizer.conf ÆÄÀÏ »ý¼º
if [ -f /tmp/change.temp ] ; then
sed -f /tmp/change.temp /etc/webalizer/autowebalizer.conf 
> /etc/webalizer/$servername.conf
echo
echo "/etc/webalizer/$servername.conf ÆÄÀÏÀÌ »ý¼ºµÇ¾ú½À´Ï´Ù"
else 
echo "/tmp/change.temp sed ÆÄÀÏÀÌ ¾ø½À´Ï´Ù"
exit
fi

### conf ÆÄÀÏÀÌ ÀÖ´Â °æ¿ì 

}

#############################
### µµ¸ÞÀÎ Á¤º¸ ½Àµæ ÇÔ¼ö ###
#############################

whatdomain() {
servercount=$(cat /etc/httpd/conf/httpd.conf|egrep "$account"|grep -
c "ServerName")

### °Ï»öÀÌ Çϳª¸¸ µü °É¸°°æ¿ì ^^ 
if (( $servercount == 1 )); then
servername=$(cat /etc/httpd/conf/httpd.conf|egrep "$account"|grep "Server
Name"|awk '{print $2}')
echo
echo -n "### µµ¸ÞÀÎ ³×ÀÓÀÌ $servername ÀÌ ¸Â½À´Ï±î? [Y/n] (default Y) : "
read okdomain
else
servername=$(cat /etc/httpd/conf/httpd.conf|egrep -C $account|egrep -
A1 "public_html$"|grep "ServerName"|awk '{print $2}')
cat httpd.conf |grep -C $account|egrep -A1 "public_html"
echo
echo "µµ¸ÞÀÎ ³×ÀÓÀÌ ¿©·¯°³ µî·ÏµÇ¾î ÀÖ½À´Ï´Ù"
echo -n "### µµ¸ÞÀÎ ³×ÀÓÀÌ $servername ÀÌ ¸Â½À´Ï´Ù? [Y/n] (default Y) : "
read okdomain
fi 

if [ "$okdomain" == "n" ] || [ "$okdomain" == "N" ]; then
putdomain
fi
}

########################
### µµ¸ÞÀÎ µî·Ï ÇÔ¼ö ###
########################

putdomain() {
echo
echo -n "### µµ¸ÞÀÎ ³×ÀÓÀ» ÀûÀ¸¼¼¿ä (ex:domain.com) : "
read servername
}

#####################
### main ½ºÅ©¸³Æ® ###
#####################

### µî·Ï °èÁ¤ ÀÔ·Â
echo 
echo "### Webalizer logs auto add script ###"
echo 
echo -n "### Ãß°¡½Ãų °èÁ¤ ¸íÀ» ÀûÀ¸¼¼¿ä: "
read account

### °èÁ¤ À§Ä¡ ã±â 
which=$(find /home*/ -maxdepth 1 -name "$account")

### °èÁ¤ÀÌ ¾ø´Â °æ¿ì (¿ÀŸ)
if [ ! $which ] ;then
echo "±×·± °èÁ¤Àº Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù"
exit
fi

### public_html °¹¼ö Á¶È¸
echo "°èÁ¤ À§Ä¡ : $which"
homecount=$(ls -l $which|grep -c "public_html" )

### public_html Æú´õ°¡ ¾ø´Â °æ¿ì
if (( $homecount == 0 )) ; then
echo "public_html Æú´õ°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù"
exit 
fi

### public_html Æú´õ°¡ Çϳª Á¸ÀçÇÏ´Â °æ¿ì 
if (( $homecount == 1 )) ; then
echo "public_html Æú´õ°¡ Çϳª Á¸ÀçÇÕ´Ï´Ù"

### logs Æú´õ°¡ ºóÆú´õ ÀÎÁö È®ÀÎ 
if (( $(ls $which/public_html/logs/|grep -c "*.*") == 0 )) ;then
        if [ ! -d $which/public_html/logs ];then
        mkdir $which/public_html/logs
        echo ">>> logs µð·ºÀ» »ý¼ºÇÏ¿´½À´Ï´Ù"
        fi
whatdomain
logfilefind
addweblog
cronadd
execalizer
exit
fi
fi

### public_html Æú´õ°¡ Çϳª ÀÌ»ó Á¸ÀçÇÏ´Â °æ¿ì
if (( $homecount > 1 )) ; then
echo "public_html Æú´õ°¡ ÇϳªÀÌ»ó Á¸ÀçÇÕ´Ï´Ù"
echo "±âº» Æú´õÀÎ public_html ¿¡ ¼³Ä¡ ÁøÇàµË´Ï´Ù"
if (( $(ls $which/public_html/logs/|grep -c "*.*") == 0 )) ;then
        if [ ! -d $which/public_html/logs ];then
        mkdir $which/public_html/logs
        echo ">>> logs µð·ºÀ» »ý¼ºÇÏ¿´½À´Ï´Ù"
        fi
whatdomain
logfilefind
addweblog
cronadd
execalizer
exit
fi
fi
Regist Addr [ 192.168.0.2 ] ¸ñ·Ïº¸±â À­±Û ¾Æ·§±Û
Á¤±ÔÇ¥Çö½Ä [ »ó¼¼ °Ë»ö ]
Page Loading [ 0.05 Sec ] SQL Time [ 0.02 Sec ]

Copyleft 1999-2024 by JSBoard Open Project
Theme Designed by IDOO And follow GPL2

°³ÀÎÁ¤º¸ Ãë±Þ¹æħ ÀÌ¿ë ¾à°ü »çÀÌÆ® ¸Ê ¾îµå¹Î °ü¸®