apache 자동다운받기

Posted by 주원이^^
2016.03.04 06:22 리눅스/스크립트

#!/bin/bash


folder="/httpd"
name="httpd"
start="1"
end="20"

ls -l /httpd | awk -F " " '{print $8}' > /httpd/httpd_list.txt

cd $folder
for ((i=$start;i<=$end;i++)); do
        start_cnt=`ls -l | grep ${name}-${i} | wc -l`
        if [[ $start_cnt != 0 ]]; then
                for ((j=$start;j<=$end;j++)); do
                        middle_cnt=`ls -l | grep ${name}-${i}.${j} | wc -l`
                        if [[ $middle_cnt != 0 ]]; then
                                if [[ `ls -l | grep ${name}-${i}.${j}.last | wc -l` != 0 ]]; then
                                        rm_name="`ls -v | grep ${name}-${i}.${j}.last`"
                                        rm -rf "$rm_name"
                                fi
                                        end_cnt=`ls -v | grep ${name}-${i}.${j} | wc -l`
                                        sed_name=`ls -v | grep ${name}-${i}.${j} | sed "/${name}-${i}.${j}.last/d" | sed -n "${end_cnt},${end_cnt}p"`
                                        ln -s ${sed_name} ${name}-${i}.${j}.last.tar.gz
                        fi
                        continue
                done
        fi

done

curl http://archive.apache.org/dist/httpd/ | grep httpd-2 | grep tar.gz | awk -F "href=\"" '{print $2}' | awk -F " " '{print $1}' | awk -F "\"" '{print $1}' | grep tar.gz$ | grep -v alpha | grep -v deps | grep -v beta > /httpd/httpd_list
_http_list

while read line; do
        while read line2; do
                if [[ $line == $line2 ]]; then
                        check=0
                        break;
                else
                        check=1
                fi
        done < /httpd/httpd_list
        if [ $check == 1 ]; then
                wget -O /httpd/$line http://archive.apache.org/dist/httpd/$line
        fi
done < /httpd/httpd_list.txt 
ls -l /httpd | awk -F " " '{print $8}' > /httpd/httpd_list.txt
rm -rf /httpd/httpd_list

'리눅스 > 스크립트' 카테고리의 다른 글

ssh_bruteforce 자동차단  (0) 2016.11.04
웹 트래픽 로그 순위 추출  (0) 2016.11.03
apache 자동다운받기  (0) 2016.03.04
mysql replication 상태체크  (0) 2016.01.13
폴더내 파일 소문자로 일괄변경  (0) 2015.07.16
7일뒤 로그 삭제  (0) 2015.07.14
이 댓글을 비밀 댓글로