Created
November 16, 2015 07:39
-
-
Save diablowu/a65140083e39ffb09ac6 to your computer and use it in GitHub Desktop.
centos mirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mirror_site="rsync://mirrors.yun-idc.com/centos/" | |
| local_path="/app/mirrors/data/centos/" | |
| excludes_path="/app/mirrors/conf/excludes.d/centos.list" | |
| pid_file="/app/mirrors/var/run/centos.pid" | |
| log_file="/app/mirrors/var/logs/centos.log" | |
| # check update yum server pid | |
| MY_PID=$$ | |
| if [ -f $pid_file ]; then | |
| get_pid=`/bin/cat $pid_file` | |
| get_system_pid=`/bin/ps -ef|grep -v grep|grep $get_pid|wc -l` | |
| if [ $get_system_pid -eq 0 ]; then | |
| echo $MY_PID>$pid_file | |
| else | |
| echo "Have update yum server now!" | |
| exit 1 | |
| fi | |
| else | |
| echo $MY_PID>$pid_file | |
| fi | |
| # sync yum source | |
| echo "Start sync $mirror_site at `date +%Y%m%d_%H%M%S`" >> $log_file | |
| rsync -avrtzH --delete --exclude-from="$excludes_path" $mirror_site $local_path >> $log_file | |
| # clean lock file | |
| `/bin/rm -rf $pid_file` | |
| echo "sync end at `date +%Y%m%d_%H%M%S`" >> $log_file | |
| exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment