├── mirror_project ├── config │ ├── glpi.list │ ├── mysql.list │ ├── remi.list │ ├── docker.list │ ├── epel6.list │ ├── epel7.list │ ├── mariadb.list │ ├── mongodb3.6.list │ ├── centos6.list │ ├── centos7.list │ ├── zabbix-for-centos6.list │ ├── zabbix-for-centos7.list │ ├── gilbc-2.15-wget-list │ ├── pinpoint-wget-list │ ├── nginx6-wget-list │ ├── CurlConfigFile │ ├── nginx7-wget-list │ └── glibc2.17_for_6-wget-list ├── stack.sh ├── static-repo.sh ├── README.md ├── add.sh ├── php.sh └── mirros.sh ├── .gitignore ├── README.md ├── texlive ├── README.md └── install-texlive.sh ├── kvm ├── README.md ├── base.sh └── virt.sh ├── install-docker └── CentOS │ ├── README.md │ ├── local-docker.sh │ └── docker.sh ├── k8s └── pull_kubernetes_images_form_aliyun.sh ├── voidlinux └── void-install.sh ├── xen └── xe-update.sh └── Gentoo-Install ├── Config.sh └── install.sh /mirror_project/config/glpi.list: -------------------------------------------------------------------------------- 1 | repodata -------------------------------------------------------------------------------- /mirror_project/config/mysql.list: -------------------------------------------------------------------------------- 1 | repodata -------------------------------------------------------------------------------- /mirror_project/config/remi.list: -------------------------------------------------------------------------------- 1 | repodata -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */.DS_Store 2 | 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 常用的脚本 2 | 3 | 4 | - 同步镜像脚本 5 | 6 | -------------------------------------------------------------------------------- /mirror_project/config/docker.list: -------------------------------------------------------------------------------- 1 | i386 2 | ppc64 3 | -------------------------------------------------------------------------------- /mirror_project/config/epel6.list: -------------------------------------------------------------------------------- 1 | i386 2 | ppc64 3 | -------------------------------------------------------------------------------- /mirror_project/config/epel7.list: -------------------------------------------------------------------------------- 1 | aarch64 2 | ppc64 3 | ppc64le 4 | -------------------------------------------------------------------------------- /mirror_project/config/mariadb.list: -------------------------------------------------------------------------------- 1 | rpms/*-10.3.7-* 2 | rpms/*-10.3.8-* 3 | rpms/*-10.3.10-* 4 | srpms/*-10.3.7-* 5 | srpms/*-10.3.8-* 6 | srpms/*-10.3.10-* 7 | rpms/*-10.3.11-* 8 | -------------------------------------------------------------------------------- /mirror_project/config/mongodb3.6.list: -------------------------------------------------------------------------------- 1 | repodata 2 | *-3.6.0-* 3 | *-3.6.1-* 4 | *-3.6.2-* 5 | *-3.6.3-* 6 | *-3.6.4-* 7 | *-3.6.5-* 8 | *-3.6.7-* 9 | *-3.6.8-* 10 | *-3.6.9-* -------------------------------------------------------------------------------- /mirror_project/config/centos6.list: -------------------------------------------------------------------------------- 1 | centosplus/i386/ 2 | cloud/ 3 | sclo/ 4 | contrib/i386/ 5 | cr/i386/ 6 | extras/i386/ 7 | fasttrack/i386/ 8 | isos/ 9 | os/ 10 | updates/i386/ 11 | -------------------------------------------------------------------------------- /texlive/README.md: -------------------------------------------------------------------------------- 1 | # Texlive Install 2 | 3 | Install Texlive for Linux 4 | 5 | 6 | 7 | # QA 8 | 如果你在CentOS运行这个脚本你可能需要安装以下内容 9 | ```sh 10 | yum install wget perl perl-Digest-MD5 -y 11 | ``` 12 | -------------------------------------------------------------------------------- /kvm/README.md: -------------------------------------------------------------------------------- 1 | ## KVM常用的脚本 2 | 3 | - virt.sh 4 | 5 | 这个脚本我为了方便创建虚拟机和管理虚拟机使用的详细的可以直接执行看到。 6 | 需要注意的是需要用root或者是sudo 去执行,你可以修改sudoers文件+别名的方式方便使用。 7 | 8 | 9 | - base.sh 10 | 11 | 这个是方便我去管理我内网的虚拟机去使用的,使用`virt.sh`批量创建虚拟机之后可以直接使用这个脚本修改ip~ 12 | 13 | -------------------------------------------------------------------------------- /mirror_project/config/centos7.list: -------------------------------------------------------------------------------- 1 | SRPMS 2 | aarch64 3 | ppc64 4 | ppc64le 5 | debug 6 | repodata 7 | EFI 8 | LiveOS 9 | images 10 | isolinux 11 | CentOS_BuildTag 12 | EULA 13 | GPL 14 | RPM-GPG-KEY-CentOS-7 15 | RPM-GPG-KEY-CentOS-Testing-7 16 | drpms 17 | -------------------------------------------------------------------------------- /mirror_project/config/zabbix-for-centos6.list: -------------------------------------------------------------------------------- 1 | repodata 2 | *-3.4.0-* 3 | *-3.4.1-* 4 | *-3.4.2-* 5 | *-3.4.3-* 6 | *-3.4.4-* 7 | *-3.4.5-* 8 | *-3.4.6-* 9 | *-3.4.7-* 10 | *-3.4.8-* 11 | *-3.4.9-* 12 | *-3.4.11-* 13 | *-3.4.12-* 14 | *-3.4.13-* 15 | *-3.4.14-* 16 | -------------------------------------------------------------------------------- /mirror_project/config/zabbix-for-centos7.list: -------------------------------------------------------------------------------- 1 | repodata 2 | *-3.4.0-* 3 | *-3.4.1-* 4 | *-3.4.2-* 5 | *-3.4.3-* 6 | *-3.4.4-* 7 | *-3.4.5-* 8 | *-3.4.6-* 9 | *-3.4.7-* 10 | *-3.4.8-* 11 | *-3.4.9-* 12 | *-3.4.11-* 13 | *-3.4.12-* 14 | *-3.4.13-* 15 | *-3.4.14-* 16 | -------------------------------------------------------------------------------- /texlive/install-texlive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | REMOTE="http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet" 4 | INSTALL="/tmp/install-texlive" 5 | 6 | mkdir -p "$INSTALL" 7 | curl -sSL "$REMOTE/install-tl-unx.tar.gz" | tar -xzv -C "$INSTALL" --strip-components=1 8 | 9 | cat << EOF > "$INSTALL/tl.profile" 10 | selected_scheme scheme-full 11 | tlpdbopt_autobackup 0 12 | EOF 13 | 14 | "$INSTALL/install-tl" -profile "$INSTALL/tl.profile" -repository "$REMOTE" -------------------------------------------------------------------------------- /mirror_project/config/gilbc-2.15-wget-list: -------------------------------------------------------------------------------- 1 | http://ftp.redsleeve.org/pub/steam/glibc-2.15-60.el6.x86_64.rpm 2 | http://ftp.redsleeve.org/pub/steam/glibc-common-2.15-60.el6.x86_64.rpm 3 | http://ftp.redsleeve.org/pub/steam/glibc-debuginfo-2.15-60.el6.x86_64.rpm 4 | http://ftp.redsleeve.org/pub/steam/glibc-debuginfo-common-2.15-60.el6.x86_64.rpm 5 | http://ftp.redsleeve.org/pub/steam/glibc-devel-2.15-60.el6.x86_64.rpm 6 | http://ftp.redsleeve.org/pub/steam/glibc-headers-2.15-60.el6.x86_64.rpm 7 | http://ftp.redsleeve.org/pub/steam/glibc-static-2.15-60.el6.x86_64.rpm 8 | http://ftp.redsleeve.org/pub/steam/glibc-utils-2.15-60.el6.x86_64.rpm 9 | -------------------------------------------------------------------------------- /kvm/base.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | ### base ip config 5 | 6 | ## eth0 192.168.10.0/24 7 | ## eth1 10.0.0.0/24 8 | 9 | 10 | ## eth0 11 | 12 | cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF 13 | TYPE="Ethernet" 14 | BOOTPROTO="none" 15 | IPV6INIT="no" 16 | NAME="eth0" 17 | DEVICE="eth0" 18 | ONBOOT="yes" 19 | IPADDR="192.168.10.$1" 20 | PREFIX="24" 21 | EOF 22 | 23 | ## eth1 24 | 25 | 26 | 27 | cat > /etc/sysconfig/network-scripts/ifcfg-eth1 << EOF 28 | TYPE="Ethernet" 29 | BOOTPROTO="none" 30 | DEFROUTE="yes" 31 | IPV6INIT="no" 32 | NAME="eth1" 33 | DEVICE="eth1" 34 | ONBOOT="yes" 35 | IPADDR="10.0.0.$1" 36 | PREFIX="24" 37 | GATEWAY=10.0.0.1 38 | EOF -------------------------------------------------------------------------------- /install-docker/CentOS/README.md: -------------------------------------------------------------------------------- 1 | # 安装Docker脚本 2 | 3 | > 环境 4 | 5 | Tips:不适用于 CentOS6.x 6 | 7 | CentOS7.x 8 | docker-ce.18.09 9 | 10 | > 使用 11 | 12 | - 安装 13 | 14 | ```sh 15 | curl -fsSL https://raw.githubusercontent.com/slmoby/script/master/install-docker/CentOS/docker.sh | bash -s install 16 | ``` 17 | 18 | - 删除Docker 19 | 20 | ```sh 21 | curl -fsSL https://raw.githubusercontent.com/slmoby/script/master/install-docker/CentOS/docker.sh | bash -s remove 22 | ``` 23 | 24 | - 配置加速器 25 | 26 | ```sh 27 | curl -fsSL https://raw.githubusercontent.com/slmoby/script/master/install-docker/CentOS/docker.sh | bash -s config 28 | ``` 29 | 30 | 31 | ## local docker 32 | 33 | 这个是我内网的安装脚本,因为虚拟机的源之类的都定义好了,可以直接用 34 | -------------------------------------------------------------------------------- /mirror_project/config/pinpoint-wget-list: -------------------------------------------------------------------------------- 1 | https://www-us.apache.org/dist/hbase/2.1.1/hbase-2.1.1-bin.tar.gz 2 | https://raw.githubusercontent.com/naver/pinpoint/master/hbase/scripts/hbase-create.hbase 3 | https://github.com/naver/pinpoint/blob/master/web/src/main/resources/sql/CreateTableStatement-mysql.sql 4 | https://github.com/naver/pinpoint/blob/master/web/src/main/resources/sql/SpringBatchJobRepositorySchema-mysql.sql 5 | https://github.com/naver/pinpoint/releases/download/1.8.0/pinpoint-web-1.8.0.war 6 | https://github.com/naver/pinpoint/releases/download/1.8.0/pinpoint-collector-1.8.0.war 7 | https://github.com/naver/pinpoint/releases/download/1.8.0/pinpoint-collector-1.8.0.war 8 | http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz 9 | https://github.com/naver/pinpoint/releases/download/1.8.0/pinpoint-agent-1.8.0.tar.gz -------------------------------------------------------------------------------- /k8s/pull_kubernetes_images_form_aliyun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Check version in https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/ 6 | # Search "Running kubeadm without an internet connection" 7 | # For running kubeadm without an internet connection you have to pre-pull the required master images for the version of choice: 8 | KUBE_VERSION=v1.14.7 9 | KUBE_PAUSE_VERSION=3.1 10 | ETCD_VERSION=3.3.10 11 | DNS_VERSION=1.3.1 12 | 13 | GCR_URL=k8s.gcr.io 14 | ALIYUN_URL=registry.cn-shenzhen.aliyuncs.com/cookcodeblog 15 | 16 | images=(kube-proxy-amd64:${KUBE_VERSION} 17 | kube-scheduler-amd64:${KUBE_VERSION} 18 | kube-controller-manager-amd64:${KUBE_VERSION} 19 | kube-apiserver-amd64:${KUBE_VERSION} 20 | pause-amd64:${KUBE_PAUSE_VERSION} 21 | etcd-amd64:${ETCD_VERSION} 22 | k8s-dns-sidecar-amd64:${DNS_VERSION} 23 | k8s-dns-kube-dns-amd64:${DNS_VERSION} 24 | k8s-dns-dnsmasq-nanny-amd64:${DNS_VERSION}) 25 | 26 | 27 | for imageName in ${images[@]} ; do 28 | docker pull $ALIYUN_URL/$imageName 29 | docker tag $ALIYUN_URL/$imageName $GCR_URL/$imageName 30 | docker rmi $ALIYUN_URL/$imageName 31 | done 32 | 33 | docker images 34 | 35 | -------------------------------------------------------------------------------- /install-docker/CentOS/local-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## local install docker-ce 4 | 5 | 6 | source /etc/profile 7 | 8 | 9 | function Remove_Old_Version(){ 10 | sudo yum remove docker \ 11 | docker-client \ 12 | docker-client-latest \ 13 | docker-common \ 14 | docker-latest \ 15 | docker-latest-logrotate \ 16 | docker-logrotate \ 17 | docker-selinux \ 18 | docker-engine-selinux \ 19 | docker-engine -y 20 | } 21 | 22 | function Install_Dokcer(){ 23 | sudo yum install -y yum-utils \ 24 | device-mapper-persistent-data \ 25 | lvm2 docker-ce 26 | } 27 | 28 | 29 | 30 | function Remove_Docker(){ 31 | yum remove docker -y 32 | } 33 | 34 | function Config_Docker_mirrors(){ 35 | systemctl start docker 36 | curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io && systemctl restart docker 37 | } 38 | 39 | case $1 in 40 | install ) 41 | Remove_Old_Version 42 | Install_Dokcer 43 | 44 | ;; 45 | remove ) 46 | Remove_Docker 47 | 48 | ;; 49 | config ) 50 | Config_Docker_mirrors 51 | 52 | ;; 53 | * ) 54 | echo "Please type install,remove or config!" 55 | ;; 56 | esac 57 | -------------------------------------------------------------------------------- /mirror_project/config/nginx6-wget-list: -------------------------------------------------------------------------------- 1 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-1.14.1-1.el6.ngx.x86_64.rpm 2 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-debuginfo-1.14.1-1.el6.ngx.x86_64.rpm 3 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-geoip-1.14.1-1.el6.ngx.x86_64.rpm 4 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-geoip-debuginfo-1.14.1-1.el6.ngx.x86_64.rpm 5 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-image-filter-1.14.1-1.el6.ngx.x86_64.rpm 6 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-image-filter-debuginfo-1.14.1-1.el6.ngx.x86_64.rpm 7 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-njs-1.14.1.0.2.5-1.el6.ngx.x86_64.rpm 8 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-njs-debuginfo-1.14.1.0.2.5-1.el6.ngx.x86_64.rpm 9 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-perl-1.14.1-1.el6.ngx.x86_64.rpm 10 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-perl-debuginfo-1.14.1-1.el6.ngx.x86_64.rpm 11 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-xslt-1.14.1-1.el6.ngx.x86_64.rpm 12 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-module-xslt-debuginfo-1.14.1-1.el6.ngx.x86_64.rpm 13 | http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-nr-agent-2.0.0-12.el6.ngx.noarch.rpm -------------------------------------------------------------------------------- /mirror_project/config/CurlConfigFile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function main(){ 4 | _wget 5 | _rsync 6 | } 7 | 8 | function _wget(){ 9 | # glibc 10 | cd config 11 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/gilbc-2.15-wget-list 12 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/nginx6-wget-list 13 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/glibc2.17_for_6-wget-list 14 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/nginx7-wget-list 15 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/pinpoint-wget-list 16 | cd - 17 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/stack.sh 18 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/static-repo.sh 19 | } 20 | 21 | function _rsync(){ 22 | cd config 23 | touch centos6.list 24 | touch centos7.list 25 | touch mysql.list 26 | touch zabbix-for-centos6.list 27 | touch zabbix-for-centos7.list 28 | touch docker.list 29 | touch glpi.list 30 | touch epel6.list 31 | touch mariadb.list 32 | touch epel7.list 33 | touch mongodb3.6.list 34 | touch remi.list 35 | echo "rsync include file is done!" 36 | cd - 37 | } 38 | 39 | 40 | main 41 | 42 | -------------------------------------------------------------------------------- /mirror_project/config/nginx7-wget-list: -------------------------------------------------------------------------------- 1 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.1-1.el7_4.ngx.x86_64.rpm 2 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-debuginfo-1.14.1-1.el7_4.ngx.x86_64.rpm 3 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-geoip-1.14.1-1.el7_4.ngx.x86_64.rpm 4 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-geoip-debuginfo-1.14.1-1.el7_4.ngx.x86_64.rpm 5 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-image-filter-1.14.1-1.el7_4.ngx.x86_64.rpm 6 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-image-filter-debuginfo-1.14.1-1.el7_4.ngx.x86_64.rpm 7 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-njs-1.14.1.0.2.5-1.el7_4.ngx.x86_64.rpm 8 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-njs-debuginfo-1.14.1.0.2.5-1.el7_4.ngx.x86_64.rpm 9 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-perl-1.14.1-1.el7_4.ngx.x86_64.rpm 10 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-perl-debuginfo-1.14.1-1.el7_4.ngx.x86_64.rpm 11 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-xslt-1.14.1-1.el7_4.ngx.x86_64.rpm 12 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-module-xslt-debuginfo-1.14.1-1.el7_4.ngx.x86_64.rpm 13 | http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-nr-agent-2.0.0-9.el7.ngx.noarch.rpm 14 | -------------------------------------------------------------------------------- /mirror_project/config/glibc2.17_for_6-wget-list: -------------------------------------------------------------------------------- 1 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.src.rpm 2 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.x86_64.rpm 3 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-common-2.17-55.el6.x86_64.rpm 4 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-debuginfo-2.17-55.el6.x86_64.rpm 5 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-debuginfo-common-2.17-55.el6.x86_64.rpm 6 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-devel-2.17-55.el6.x86_64.rpm 7 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-headers-2.17-55.el6.x86_64.rpm 8 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-static-2.17-55.el6.x86_64.rpm 9 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-utils-2.17-55.el6.x86_64.rpm 10 | https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/nscd-2.17-55.el6.x86_64.rpm 11 | 12 | -------------------------------------------------------------------------------- /install-docker/CentOS/docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/profile 4 | 5 | function Check_System(){ 6 | yum install epel-release -y 7 | } 8 | 9 | 10 | function Remove_Old_Version(){ 11 | sudo yum remove docker \ 12 | docker-client \ 13 | docker-client-latest \ 14 | docker-common \ 15 | docker-latest \ 16 | docker-latest-logrotate \ 17 | docker-logrotate \ 18 | docker-selinux \ 19 | docker-engine-selinux \ 20 | docker-engine -y 21 | } 22 | 23 | function Install_Dokcer(){ 24 | sudo yum install -y yum-utils \ 25 | device-mapper-persistent-data \ 26 | lvm2 27 | if [ -f /etc/yum.repos.d/docker.repo ]; then 28 | echo "You Docker repos is Ok!" 29 | else 30 | cat > /etc/yum.repos.d/docker.repo << EOF 31 | [docker-ce] 32 | name = docker-ce 33 | baseurl = http://mirrors.ustc.edu.cn/docker-ce/linux/centos/7/x86_64/stable 34 | enable = 1 35 | gpgcheck = 0 36 | 37 | EOF 38 | fi 39 | yum makecache 40 | yum install docker-ce -y 41 | 42 | } 43 | 44 | 45 | 46 | function Remove_Docker(){ 47 | yum remove docker -y 48 | } 49 | 50 | function Config_Docker_mirrors(){ 51 | systemctl start docker 52 | curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io && systemctl restart docker 53 | } 54 | 55 | case $1 in 56 | install ) 57 | Check_System 58 | Remove_Old_Version 59 | Install_Dokcer 60 | 61 | ;; 62 | remove ) 63 | Remove_Docker 64 | 65 | ;; 66 | config ) 67 | Config_Docker_mirrors 68 | 69 | ;; 70 | * ) 71 | echo "Please type install,remove or config!" 72 | ;; 73 | esac 74 | -------------------------------------------------------------------------------- /voidlinux/void-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ROOT=/mnt 3 | DEV=${DEV:-/dev/vda} 4 | BOOTDEV=${DEV}1 5 | LVMDEV=${DEV}2 6 | ROOTDEV=/dev/Main/Root 7 | HOST=${HOST:-void-linux} 8 | REPO=${REPO:-http://repo.voidlinux.com/current} 9 | EXTRAS=${EXTRAS:-"rsync vim tmux socklog-void sv-helper"} 10 | interactive=$1 11 | 12 | echo 'Create Partitions, 1 is small (250M), 2 is the rest and LVM (type 8e)' 13 | sfdisk $DEV << EOF 14 | 1M,250M,L 15 | ,,8e 16 | EOF 17 | sfdisk -l $DEV 18 | if [ -n "$interactive" ];then 19 | echo -n "Disks look ok? " 20 | read foo 21 | if [ -n "$foo" ];then 22 | echo "Moving On" 23 | else 24 | echo "Well, Fix em!" 25 | fdisk $DEV 26 | fi 27 | fi 28 | 29 | xbps-install -Sy lvm2 30 | 31 | pvcreate $LVMDEV 32 | vgcreate -Ay Main $LVMDEV 33 | lvcreate -L5G -n Root Main 34 | 35 | mkfs.ext4 $ROOTDEV 36 | mkfs.ext2 $BOOTDEV 37 | mount $ROOTDEV $ROOT 38 | mkdir -p $ROOT/boot 39 | mount $BOOTDEV $ROOT/boot 40 | 41 | mkdir $ROOT/dev $ROOT/proc $ROOT/sys 42 | mount --rbind /dev $ROOT/dev 43 | mount --rbind /proc $ROOT/proc 44 | mount --rbind /sys $ROOT/sys 45 | 46 | 47 | echo YES|xbps-install -r $ROOT -R $REPO -Sy base-voidstrap lvm2 48 | 49 | vduuid=$(ls -l /dev/disk/by-uuid/|grep $(basename $BOOTDEV)|awk '{print $9}') 50 | echo "UUID=$vduuid /boot ext2 defaults 0 1" >> $ROOT/etc/fstab 51 | echo "$ROOTDEV / ext4 defaults 0 1" >> $ROOT/etc/fstab 52 | 53 | cp /etc/resolv.conf $ROOT/etc/ 54 | cp /etc/ssh/moduli $ROOT/etc/ssh/ 55 | cp /etc/ssh/ssh_host_* $ROOT/etc/ssh/ 56 | printf $HOST > $ROOT/etc/hostname 57 | if [ -n "$interactive" ];then 58 | echo -n "Choose a root password: " 59 | read -s RPASSWD 60 | echo 61 | fi 62 | RPASSWD=${RPASSWD:-none} 63 | 64 | cat >$ROOT/tmp/bootstrap.sh < /boot/grub/grub.cfg 72 | grub-install $DEV 73 | ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/ 74 | ln -s /etc/sv/sshd /etc/runit/runsvdir/default/ 75 | EOCHROOT 76 | 77 | chroot $ROOT /bin/sh /tmp/bootstrap.sh 78 | 79 | umount -a 80 | umount /mnt/dev/pts 81 | umount /mnt/sys 82 | umount /mnt/proc 83 | umount /mnt/dev 84 | umount /mnt 85 | mount 86 | -------------------------------------------------------------------------------- /xen/xe-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## functions 4 | function _check_directory(){ 5 | if [ -d $1 ];then 6 | echo "$1 is ok!" 7 | else mkdir -p $1 8 | fi 9 | } 10 | 11 | ## check env 12 | ## Time 13 | DAY=`date +%Y-%m-%d` 14 | ## Backup dir 15 | BACKUP=/backup 16 | ## kernel version 17 | KERNEL=$(uname -r) 18 | MODULES=/lib/modules/ 19 | ## backup modules 20 | MODE_NAME=/tmp/mod-name 21 | function info(){ 22 | echo "please type backup modules name" 23 | read "TMP" 24 | echo $TMP > $MODE_NAME 25 | modinfo $TMP >/tmp/mod-info-old 26 | } 27 | ### backup dir 28 | 29 | function check(){ 30 | _check_directory $BACKUP/$DAY-old/ 31 | _check_directory $BACKUP/$DAY-new/ 32 | } 33 | 34 | ### backup modules.dep ! 35 | function backup_modules(){ 36 | # cp $MODULES$KERNEL/modules.dep $BACKUP/$DAY-old/modules.dep 37 | # cp $MOD_TMP $BACKUP/$DAY-old/ 38 | cp -rf $MODULES$KERNEL /$BACKUP/$DAY-old 39 | echo "Backup old modules is ok!" 40 | # cp -rf $MODULES$KERNEL $BACKUP/$DAY-old 41 | # ls -R $BACKUP/$DAY-old 42 | 43 | } 44 | 45 | ## update modules 46 | 47 | function update(){ 48 | echo 'update start now !' 49 | rmmod $(cat $MODE_NAME) 50 | echo "please type update mode files " 51 | read "UPDATE_TMP" 52 | xe update-upload file-name=$UPDATE_TMP 53 | echo "The UUID of the update is returned when the upload completes,Please input" 54 | read "UUID_TMP" 55 | xe update-apply uuid=$UUID_TMP 56 | echo "now update is ok!" 57 | modinfo $(cat $MODE_NAME) > /tmp/mod-info-new 58 | # cat /tmp/mod-info-new 59 | # cp $MODULES$KERNEL/modules.dep $BACKUP/$DAY-new/modules.dep 60 | # cp $MOD_NEW $BACKUP/$DAY-new/ 61 | cp -rf $MODULES$KERNEL $BACKUP/$DAY-new 62 | ls -R $BACKUP/$DAY-new 63 | echo "backup files is ok!" 64 | } 65 | ## Rollback modules 66 | 67 | function rollback(){ 68 | echo "rollback now" 69 | echo "Please type you want rollback path" 70 | read "TMP" 71 | cp -r $BACKUP/$DAY-old/$KERNEL/modules.dep $MODULES$KERNEL 72 | rm -rf $(cat /tmp/mod-info-new |grep filename |awk '{print $2}') 73 | depmod 74 | # rmmod $MODE_NAME 75 | echo "now is resize" 76 | } 77 | 78 | # vs 79 | # diff 80 | ## menu 81 | case $1 in 82 | 83 | info ) 84 | info 85 | ;; 86 | backup ) 87 | check 88 | # info 89 | backup_modules 90 | ;; 91 | update ) 92 | update 93 | ;; 94 | rollback ) 95 | rollback 96 | ;; 97 | *) 98 | echo "backup !" 99 | ;; 100 | esac 101 | 102 | -------------------------------------------------------------------------------- /kvm/virt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # by chaos 4 | # date Mon Dec 3 19:13:37 CST 2018 5 | if [ "$(whoami | id -u)" == "0" ] 6 | then 7 | echo "run user is root!"; 8 | else 9 | echo "Please use root run this script!" 10 | exit 9 11 | fi 12 | 13 | function _check_dir_file_exist() 14 | { 15 | if [ -e $1 ]; then 16 | echo "Check $1 ok." 17 | return 0 18 | else 19 | echo "Check $1 Not Found!!!" 20 | return 1 21 | fi 22 | } 23 | 24 | 25 | 26 | 27 | _check_dir_file_exist host 28 | 29 | # env 30 | HOSTLIST=`cat host` 31 | TP_NAME=chaos 32 | DISK_DIR=/data/kvm/disk 33 | SNAPSHOT=init 34 | # main 35 | 36 | 37 | function _create_vm(){ 38 | for host in ${HOSTLIST[@]}; do 39 | sudo virt-clone -o $TP_NAME -n ${host} -f $DISK_DIR/${host}.qcow2 40 | done 41 | } 42 | 43 | 44 | 45 | function _start_vm(){ 46 | for host in ${HOSTLIST[@]};do 47 | sudo virsh start ${host} 48 | done 49 | } 50 | 51 | function _shutdown_vm(){ 52 | for host in ${HOSTLIST[@]};do 53 | sudo virsh shutdown ${host} 54 | done 55 | } 56 | 57 | function _remove_vm(){ 58 | for host in ${HOSTLIST[@]};do 59 | sudo virsh destroy ${host} 60 | done 61 | for host in ${HOSTLIST[@]};do 62 | sudo virsh undefine ${host} 63 | done 64 | for host in ${HOSTLIST[@]};do 65 | sudo rm -rf $DISK_DIR/${host}.qcow2 66 | done 67 | } 68 | 69 | function _resize_vm(){ 70 | for host in ${HOSTLIST[@]}; do 71 | sudo virsh snapshot-revert --domain ${host} $SNAPSHOT 72 | done 73 | } 74 | 75 | function _create_snapshot(){ 76 | for host in ${HOSTLIST[@]}; do 77 | sudo virsh snapshot-create-as --name $SNAPSHOT ${host} 78 | done 79 | } 80 | 81 | function _remove_snapshot(){ 82 | for host in ${HOSTLIST[@]}; do 83 | sudo virsh snapshot-delete ${host} $SNAPSHOT 84 | done 85 | } 86 | 87 | function _vm_info(){ 88 | for host in ${HOSTLIST[@]}; do 89 | sudo virsh dominfo ${host} 90 | done 91 | 92 | } 93 | 94 | function _vm_ip_show_dhcp(){ 95 | for host in ${HOSTLIST[@]}; do 96 | sudo virsh domifaddr ${host} 97 | done 98 | } 99 | case $1 in 100 | start ) 101 | _start_vm 102 | ;; 103 | remove ) 104 | _remove_vm 105 | ;; 106 | resize ) 107 | _resize_vm 108 | ;; 109 | create ) 110 | _create_vm 111 | ;; 112 | vminfo ) 113 | _vm_info 114 | ;; 115 | vmip ) 116 | _vm_ip_show_dhcp 117 | ;; 118 | create_snapshot ) 119 | _create_snapshot 120 | ;; 121 | remove_snapshot ) 122 | _remove_snapshot 123 | ;; 124 | shutdown ) 125 | _shutdown_vm 126 | ;; 127 | * ) 128 | echo "Please type start,remove,resize,create,vminfo,vmip,create_snapshot,remove_snapshot !" 129 | ;; 130 | esac 131 | -------------------------------------------------------------------------------- /mirror_project/stack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## CentOS7 base 4 | function _rsync_CentOS7(){ 5 | #base 6 | _rsync_mirrors $Config_DIR/centos7.list $rsync_tuna/centos/7/os/x86_64/ $CentOS7/os 7 | _update_repos $CentOS7/os/ 8 | # updates 9 | _rsync_mirrors $Config_DIR/centos7.list $rsync_tuna/centos/7/updates/x86_64/ $CentOS7/updates 10 | _update_repos $CentOS7/updates/ 11 | # extras 12 | _rsync_mirrors $Config_DIR/centos7.list $rsync_tuna/centos/7/extras/x86_64/ $CentOS7/extras 13 | _update_repos $CentOS7/extras/ 14 | } 15 | 16 | ## CentOS6 base 17 | function _rsync_CentOS6(){ 18 | # base 19 | _rsync_mirrors $Config_DIR/centos6.list $rsync_tuna/centos/6/os/x86_64 $CentOS6/os 20 | _update_repos $CentOS6/os 21 | # updates 22 | _rsync_mirrors $Config_DIR/centos6.list $rsync_tuna/centos/6/updates/x86_64 $CentOS6/updates 23 | _update_repos $CentOS6/updates 24 | # extras 25 | _rsync_mirrors $Config_DIR/centos6.list $rsync_tuna/centos/6/extras/x86_64 $CentOS6/extras 26 | _update_repos $CentOS6/extras 27 | } 28 | 29 | ## EPEL6 30 | function _rsync_EPEL6(){ 31 | # rsync mirros 32 | _rsync_mirrors $Config_DIR/epel6.list $rsync_tuna/epel/6/x86_64/ $EPEL6 33 | # update repodate 34 | _update_repos $EPEL6 35 | } 36 | 37 | ## EPEL7 38 | function _rsync_EPEL7(){ 39 | _rsync_mirrors $Config_DIR/epel7.list $rsync_tuna/epel/7/x86_64/ $EPEL7 40 | _update_repos $EPEL7 41 | } 42 | 43 | ## Mariadb10.3 for CentOS7 44 | 45 | function _rsync_mariadb7(){ 46 | _rsync_mirrors $Config_DIR/mariadb.list $rsync_tuna/mariadb/yum/10.3/centos/7.4/x86_64/ $Mariadb7 47 | _update_repos $Mariadb7 48 | 49 | } 50 | 51 | ## Mariadb10.3 for CentOS6 52 | function _rsync_mariadb6(){ 53 | _rsync_mirrors $Config_DIR/mariadb.list $rsync_tuna/mariadb/yum/10.3/centos/6/x86_64/ $Mariadb6 54 | _update_repos $Mariadb6 55 | 56 | } 57 | 58 | 59 | function _zabbix_6(){ 60 | # base 61 | _rsync_mirrors $Config_DIR/zabbix-for-centos6.list $rsync_tuna/zabbix/zabbix/3.4/rhel/6/x86_64/ $ZABBIX6/x86_64/ 62 | _update_repos $ZABBIX6/x86_64/ 63 | # non-supported 64 | _rsync_mirrors $Config_DIR/zabbix-for-centos6.list $rsync_tuna/zabbix/non-supported/rhel/6/x86_64/ $ZABBIX6/non-supported 65 | _update_repos $ZABBIX6/non-supported/x86_64/ 66 | } 67 | 68 | 69 | function _zabbix_7(){ 70 | # base 71 | _rsync_mirrors $Config_DIR/zabbix-for-centos7.list $rsync_tuna/zabbix/zabbix/3.4/rhel/7/x86_64/ $ZABBIX7/x86_64/ 72 | _update_repos $ZABBIX7/x86_64/ 73 | # non-supported 74 | _rsync_mirrors $Config_DIR/zabbix-for-centos7.list $rsync_tuna/zabbix/non-supported/rhel/7/x86_64/ $ZABBIX7/non-supported 75 | _update_repos $ZABBIX7/non-supported/x86_64/ 76 | } 77 | 78 | 79 | function _wget_glibc(){ 80 | _wget_incloud_file $Config_DIR/gilbc-2.15-wget-list $GLIBC 81 | _update_repos $GLIBC 82 | } 83 | 84 | function _mongodb_3.6_6(){ 85 | _rsync_mirrors $Config_DIR/mongodb3.6.list $rsync_tuna/mongodb/yum/el6-3.6/RPMS/ $MONGODB6 86 | _update_repos $MONGODB6 87 | } 88 | 89 | function _mongodb_3.6_7(){ 90 | _rsync_mirrors $Config_DIR/mongodb3.6.list $rsync_tuna/mongodb/yum/el7-3.6/RPMS/ $MONGODB7 91 | _update_repos $MONGODB7 92 | } 93 | 94 | 95 | function _nginx_centos6(){ 96 | _wget_incloud_file $Config_DIR/nginx6-wget-list $Nginx6 97 | _update_repos $Nginx6 98 | } 99 | 100 | function _nginx_centos7(){ 101 | _wget_incloud_file $Config_DIR/nginx7-wget-list $Nginx7 102 | _update_repos $Nginx7 103 | } 104 | 105 | 106 | function _pinpoint(){ 107 | _wget_incloud_file $Config_DIR/pinpoint-wget-list $pinpoint 108 | _update_repos $pinpoint 109 | } 110 | 111 | function _openstack_r(){ 112 | _rsync_mirrors $Config_DIR/openstack.list $rsync_tuna/centos/7.6.1810/cloud/x86_64/openstack-rocky/ $Rocky 113 | _update_repos $Rocky 114 | } 115 | 116 | 117 | function _docker_ce(){ 118 | _rsync_mirrors $Config_DIR/docker.list $rsync_tuna/docker/yum/repo/centos7/Packages/ $DOCKER 119 | _update_repos $DOCKER 120 | } 121 | -------------------------------------------------------------------------------- /mirror_project/static-repo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | function links_for_mirrors(){ 6 | if [ -L /var/www/html/mirrors ];then 7 | echo "mirrors links is ok!" 8 | else 9 | ln -sf $DATA_DIR /var/www/html 10 | echo "links now if ok" 11 | fi 12 | } 13 | 14 | CENTOS_VERSION_BY_RPM=`rpm -q --queryformat '%{VERSION}' centos-release` 15 | 16 | function _mirrors_server(){ 17 | if [ $CENTOS_VERSION_BY_RPM -eq 6 ];then 18 | _mirrors_server_6 19 | elif [[ $CENTOS_VERSION_BY_RPM -eq 7 ]]; then 20 | _mirrors_server_7 21 | fi 22 | } 23 | 24 | function _mirrors_server_7(){ 25 | _firewalld_httpd 26 | 27 | } 28 | 29 | function _mirrors_server_6(){ 30 | _no_iptables_httpd 31 | } 32 | 33 | function _no_iptables_httpd(){ 34 | service httpd start 35 | chkconfig httpd on 36 | } 37 | 38 | function _firewalld_httpd(){ 39 | firewall-cmd --permanent --add-service=http 40 | firewall-cmd --permanent --add-service=https 41 | firewall-cmd --reload 42 | _check_command_and_yum_install httpd 43 | sleep 3 44 | chcon -R -t httpd_sys_content_t $DATA_DIR 45 | systemctl enable httpd 46 | systemctl start httpd 47 | } 48 | 49 | 50 | IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d '/') 51 | 52 | 53 | function _chage_add_repos(){ 54 | cp ./add.sh $DATA_DIR/repo/add.sh 55 | sed -i "s/10.0.0.10/${IP}/g" $DATA_DIR/repo/add.sh 56 | } 57 | function _create_repos_file(){ 58 | cat > $REPO/centos-7.repo << EOF 59 | [base] 60 | name = base 61 | baseurl = http://$IP/$WEB/centos/7/os 62 | enable = 1 63 | gpgcheck = 0 64 | 65 | [update] 66 | name = update 67 | baseurl = http://$IP/$WEB/centos/7/updates 68 | enable = 1 69 | gpgcheck = 0 70 | 71 | 72 | [extras] 73 | name = extras 74 | baseurl = http://$IP/$WEB/centos/7/extras 75 | enable = 1 76 | gpgcheck = 0 77 | 78 | EOF 79 | 80 | cat > $REPO/centos-6.repo << EOF 81 | [base] 82 | name = base 83 | baseurl = http://$IP/$WEB/centos/6/os 84 | enable = 1 85 | gpgcheck = 0 86 | 87 | [update] 88 | name = update 89 | baseurl = http://$IP/$WEB/centos/6/updates 90 | enable = 1 91 | gpgcheck = 0 92 | 93 | 94 | [extras] 95 | name = extras 96 | baseurl = http://$IP/$WEB/centos/6/extras 97 | enable = 1 98 | gpgcheck = 0 99 | EOF 100 | 101 | 102 | # EPEL 103 | cat > $REPO/epel-7.repo << EOF 104 | [epel] 105 | name = epel7 106 | baseurl = http://$IP/$WEB/epel/7 107 | enable = 1 108 | gpgcheck = 0 109 | 110 | EOF 111 | 112 | cat > $REPO/epel-6.repo << EOF 113 | [epel] 114 | name = epel6 115 | baseurl = http://$IP/$WEB/epel/6 116 | enable = 1 117 | gpgcheck = 0 118 | EOF 119 | 120 | cat > $REPO/mongodb-6.repo << EOF 121 | [mongodb] 122 | name = mongodb6 123 | baseurl = http://$IP/$WEB/mongodb/6 124 | enable = 1 125 | gpgcheck = 0 126 | EOF 127 | cat > $REPO/mongodb-7.repo << EOF 128 | [mongodb] 129 | name = mongodb7 130 | baseurl = http://$IP/$WEB/mongodb/7 131 | enable = 1 132 | gpgcheck = 0 133 | EOF 134 | 135 | cat > $REPO/mariadb-7.repo << EOF 136 | [mariadb] 137 | name = mariadb7 138 | baseurl = http://$IP/$WEB/mariadb/7 139 | enable = 1 140 | gpgcheck = 0 141 | EOF 142 | cat > $REPO/mariadb-6.repo << EOF 143 | [mariadb] 144 | name = mariadb6 145 | baseurl = http://$IP/$WEB/mariadb/6 146 | enable = 1 147 | gpgcheck = 0 148 | EOF 149 | 150 | cat > $REPO/nginx-6.repo << EOF 151 | [nginx] 152 | name = nginx6 153 | baseurl = http://$IP/$WEB/nginx/6 154 | enable = 1 155 | gpgcheck = 0 156 | EOF 157 | 158 | cat > $REPO/nginx-7.repo << EOF 159 | [nginx] 160 | name = nginx7 161 | baseurl = http://$IP/$WEB/nginx/7 162 | enable = 1 163 | gpgcheck = 0 164 | EOF 165 | 166 | 167 | cat > $REPO/zabbix-6.repo << EOF 168 | [zabbix] 169 | name = zabbix6 170 | baseurl = http://$IP/$WEB/zabbix/6/x86_64 171 | enable = 1 172 | gpgcheck = 0 173 | 174 | [zabbix-non-supported] 175 | name = non-supported 176 | baseurl = http://$IP/$WEB/zabbix/6/non-supported/x86_64/ 177 | enable = 1 178 | gpgcheck = 0 179 | EOF 180 | 181 | cat > $REPO/zabbix-7.repo << EOF 182 | 183 | [zabbix] 184 | name = zabbix7 185 | baseurl = http://$IP/$WEB/zabbix/7/x86_64 186 | enable = 1 187 | gpgcheck = 0 188 | 189 | [zabbix-non-supported] 190 | name = non-supported 191 | baseurl = http://$IP/$WEB/zabbix/7/non-supported/x86_64/ 192 | enable = 1 193 | gpgcheck = 0 194 | EOF 195 | 196 | cat > $REPO/glibc.repo << EOF 197 | [glibc] 198 | name = glibc 199 | baseurl = http://$IP/$WEB/glibc/6 200 | enable = 1 201 | gpgcheck = 0 202 | EOF 203 | 204 | cat > $REPO/jdk.repo << EOF 205 | [jdk] 206 | name = jdk 207 | baseurl = http://$IP/$WEB/jdk 208 | enable = 1 209 | gpgcheck = 0 210 | EOF 211 | 212 | cat > $REPO/elk.repo << EOF 213 | [elk] 214 | name = elk 215 | baseurl = http://$IP/$WEB/elk 216 | enable = 1 217 | gpgcheck = 0 218 | EOF 219 | 220 | cat > $REPO/rocky.repo << EOF 221 | 222 | [rocky] 223 | name = rocky 224 | baseurl = http://$IP/$WEB/centos/7/rocky 225 | enable = 1 226 | gpgcheck = 0 227 | 228 | EOF 229 | 230 | 231 | cat > $REPO/docker.repo << EOF 232 | 233 | [docker] 234 | name = docker-ce 235 | baseurl = http://$IP/$WEB/docker/ 236 | enable = 1 237 | gpgcheck = 0 238 | 239 | EOF 240 | 241 | 242 | } 243 | -------------------------------------------------------------------------------- /mirror_project/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 3 | - Mirrors Script 4 | author: 5 | - by chaos 6 | --- 7 | 8 | # 版本 9 | 10 | Version: 0.9 11 | 12 | # 项目说明 13 | mirrors_project是为了安全考虑在局域网内部建立一个镜像站的项目,它包含了一下功能。 14 | 15 | - 更新同步 16 | - 生成repodata文件 17 | - 一件配置yum源 18 | 19 | 20 | # 下载 21 | 22 | 需要安装git 23 | 24 | CentOS 25 | ```sh 26 | sudo yum install git -y 27 | ``` 28 | 29 | 下载mirrors脚本 30 | 31 | 32 | ```sh 33 | git clone https://github.com/slmoby/script 34 | ``` 35 | 36 | > 需要的软件列表 37 | 38 | - rsync 39 | 40 | - createrepo 41 | 42 | - httpd 43 | 44 | - wget 45 | 46 | # 环境预设 47 | 48 | 49 | 50 | 默认变量 51 | 52 | | 变量名称 | 位置 | 定义 | 53 | | ---------- | ------------------------------------ | ------------------------ | 54 | | Config_DIR | ./config | 所需要用到的配置文件目录 | 55 | | DATA_DIR | /data/mirrors | 镜像站的存放位置 | 56 | | rsync_tuna | rsync://mirrors.tuna.tsinghua.edu.cn | 同步的镜像源位置 | 57 | | REPO | $DATA_DIR/repo | 生成的repo位置 | 58 | 59 | 你可以自定义修改`DATA_DIR`的位置来存放整个镜像站 60 | 61 | DATA_DIR变量位于`mirrors.sh` 62 | 63 | 一般来说只需要修改`DATA_DIR`即可 64 | 65 | 66 | 67 | 在`mirrors.sh` 中使用了`_check_command_and_yum_install`这个函数去安装需要的软件包这个函数位于 `mirrors.sh`这个主文件中,如果你使用的是非redhat系发行版你可以手动解决软件依赖`rsync,createrepo`来去解决这个问题 68 | 69 | # 库文件函数方法 70 | 71 | 这里只介绍需要用到的函数 72 | 73 | 74 | | 函数名称 | 参数 | 使用方法 | 75 | | ------------------------------ | ----- | --------------------------------------- | 76 | | _wget_url | 1 | _wget_url url | 77 | | _check_dir_file_exist | 1 | _check_dir_file_exist files | 78 | | _rsync_mirrors | 1,2,3 | _rsync_mirrors file.list rsync_url path | 79 | | _source_file_exist | 1 | _source_file_exist files | 80 | | _check_command_and_yum_install | 1 | _check_command_and_yum_install command | 81 | | _update_repos | 1 | _update_repos path | 82 | | _wget_incloud_file | 1,2 | _wget_incloud_file wget-list-file path | 83 | | | | | 84 | | | | | 85 | 86 | 87 | # 使用 88 | 89 | > 环境检查 90 | 91 | 初次运行你可以按照你的环境来决定你的镜像目录修改`DATA_DIR`变量 92 | 93 | 检查环境 94 | 95 | ```sh 96 | cd script/mirror_project 97 | ./mirros.sh check 98 | ``` 99 | 100 | 运行过程中会去检查环境并且创建目录 101 | 102 | > 同步第一个镜像 103 | 104 | 在这里我增加了几个按钮,这个文件位于`include/env.sh`,你也可以通过 `./mirros.sh list `来查看默认支持哪些镜像,或者是直接同步目前所有的镜像,同步时间非常的长,同时也会消耗很大一部分的带宽请留意:) 105 | 106 | ``` 107 | ./mirrors.sh all 108 | ``` 109 | 110 | 创建一个repo文件 111 | 112 | 更新镜像站完毕之后你可以在服务端生成一些配置文件来使局域网内的机器更加容易使用,这里内置了一个参数`createrepos`来去生成所有的repo文件 113 | 114 | ``` 115 | ./mirros.sh creatrepos 116 | ``` 117 | 118 | > 增加一个镜像源 119 | 120 | 因为内置库的缘故你可以非常简单的添加一个镜像,例子Docker的镜像站点 121 | 122 | 首先在`docker.sh` 中添加你的镜像站点存放位置,和web站点访问位置 123 | 124 | ```bash 125 | DOCKER-CE=$DATA_DIR/docker 126 | WEB_DOCKER=$MIRRORS_WEB/docker 127 | ``` 128 | 129 | 再在`include/stack.sh`中添加以下内容 130 | 131 | ```bash 132 | function _rsync_docker_for_centos7(){ 133 | _rsync_mirrors $Config_DIR/docker.list $rsync_tuna/docker-ce/linux/centos/7/x86_64/stable/ $DOCKER 134 | _update_repos $DOCKER 135 | 136 | } 137 | ``` 138 | 139 | 添加按钮`mirrors.sh` 140 | 141 | ```sh 142 | case $1 in 143 | docker ) 144 | _rsync_docker_for_centos7 145 | esac 146 | ``` 147 | 148 | 运行 149 | 150 | ``` 151 | ./mirros.sh docker 152 | ``` 153 | 154 | > 增加repo文件 155 | 156 | ​ 在`include/static-repo.sh`文件中增加rpeo文件,在这个文件中我定义了一个函数体`_create_repos_file` 直接在里面添加如下 157 | 158 | ```bash 159 | 160 | cat > $REPO/docker-ce-7.repo << EOF 161 | [docker-ce] 162 | name = docker-ce 163 | baseurl = http://$IP/$WEB/$DOCKER 164 | enable = 1 165 | gpgcheck = 0 166 | EOF 167 | 168 | ``` 169 | 170 | 更新repos文件 171 | 172 | ```sh 173 | ./mirros.sh creatrepos 174 | ``` 175 | 176 | 177 | # 局域网中的机器使用源 178 | 179 | > 发布 180 | 181 | 这里可以使用httpd服务器发布,`mirrors.sh`预制了一个安装httpd的功能 182 | 183 | ``` 184 | ./mirros.sh httpd 185 | ``` 186 | 187 | 即可安装并运行httpd,如果你的防火墙和selinux是开启的状态你可以运行 188 | 189 | ``` 190 | ./mirrors.sh httpd_firewalld 191 | ``` 192 | 193 | 发布目前yum源的repo静态文件至web服务器 194 | 195 | ``` 196 | ./mirrors.sh creatrepos 197 | ``` 198 | 199 | > 使用 200 | 201 | > 查看帮助 202 | 203 | Tips: $SERVER替换为你的服务器地址 204 | 205 | ```bash 206 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s help 207 | ``` 208 | 209 | 210 | > 一键配置所有源 211 | 212 | ```bash 213 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s all 214 | ``` 215 | 216 | > Base 源配置 217 | 218 | Tips: base源包括了 CentOSx.x的源和epel.x的源 219 | 220 | ```bash 221 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s init_base 222 | ``` 223 | 224 | > Zabbix 源配置 225 | 226 | ```bash 227 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s zabbix 228 | ``` 229 | 230 | > Remi 源配置 231 | 232 | ```bash 233 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s remi 234 | ``` 235 | 236 | > mongodb 源配置 237 | 238 | ```bash 239 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s mongodb 240 | ``` 241 | 242 | > MariaDB 源配置 243 | 244 | ```bash 245 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s mariadb 246 | ``` 247 | 248 | > Nginx 源配置 249 | 250 | ```bash 251 | curl -fsSL http://$SERVER/mirrors/repo/add.sh | bash -s nginx 252 | ``` 253 | 254 | -------------------------------------------------------------------------------- /mirror_project/add.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: chaos 4 | 5 | # server 6 | 7 | SERVER=10.0.0.10 8 | # Set error color 9 | 10 | Color_Text() 11 | { 12 | echo -e " \e[0;$2m$1\e[0m" 13 | } 14 | 15 | Echo_Red() 16 | { 17 | echo -e $( Color_Text "$1" "31") 18 | } 19 | 20 | # Check if user is root 21 | 22 | if [ $(id -u) != "0" ]; then 23 | Echo_Red "Error: You are not root." 24 | exit 1 25 | fi 26 | _check_directory(){ 27 | if [ -d $1 ];then 28 | echo "$1 is ok!" 29 | else 30 | mkdir -p $1 31 | fi 32 | } 33 | 34 | # Get CentOS version info: 5/6/7 35 | 36 | CENTOS_VERSION_BY_RPM=`rpm -q --queryformat '%{VERSION}' centos-release` 37 | CENTOS_VERSION_BY_RELEASE=`cat /etc/redhat-release | grep -o '[0-9]\.[0-9]'` 38 | 39 | # Repo files backup 40 | 41 | Repo_Backup() 42 | { 43 | _check_directory /root/backup 44 | mv /etc/yum.repos.d/* /root/backup 45 | } 46 | 47 | # Repo files install 48 | #sh -c "$(curl -fsSL http://192.168.10.45/mirrors/repo/add.sh)" 49 | BASE_REPO() 50 | { 51 | BASE_REPO_URL="http://$SERVER/mirrors/repo/centos-"${CENTOS_VERSION_BY_RPM}".repo" 52 | EPEL_REPO_URL="http://$SERVER/mirrors/repo/epel-"${CENTOS_VERSION_BY_RPM}".repo" 53 | curl -sS -o /etc/yum.repos.d/CentOS-Base.repo $BASE_REPO_URL 54 | curl -sS -o /etc/yum.repos.d/epel.repo $EPEL_REPO_URL 55 | } 56 | 57 | ZABBIX(){ 58 | ZABBIX_REPO_URL="http://$SERVER/mirrors/repo/zabbix-"${CENTOS_VERSION_BY_RPM}".repo" 59 | curl -sS -o /etc/yum.repos.d/zabbix.repo $ZABBIX_REPO_URL 60 | } 61 | 62 | NGINX(){ 63 | NGINX_REPO_URL="http://$SERVER/mirrors/repo/nginx-"${CENTOS_VERSION_BY_RPM}".repo" 64 | curl -sS -o /etc/yum.repos.d/nginx.repo $NGINX_REPO_URL 65 | 66 | } 67 | 68 | MONGODB(){ 69 | MONGODB_REPO_URL="http://$SERVER/mirrors/repo/mongodb-"${CENTOS_VERSION_BY_RPM}".repo" 70 | curl -sS -o /etc/yum.repos.d/mongodb.repo $MONGODB_REPO_URL 71 | 72 | } 73 | 74 | MARIADB(){ 75 | MARIADB_REPO_URL="http://$SERVER/mirrors/repo/mariadb-"${CENTOS_VERSION_BY_RPM}".repo" 76 | curl -sS -o /etc/yum.repos.d/mariadb.repo $MARIADB_REPO_URL 77 | } 78 | 79 | REMI(){ 80 | REMI56_REPO_URL="http://$SERVER/mirrors/repo/remi56-"${CENTOS_VERSION_BY_RPM}".repo" 81 | REMI72_REPO_URL="http://$SERVER/mirrors/repo/remi72-"${CENTOS_VERSION_BY_RPM}".repo" 82 | curl -sS -o /etc/yum.repos.d/remi56.repo $REMI56_REPO_URL 83 | curl -sS -o /etc/yum.repos.d/remi72.repo $REMI72_REPO_URL 84 | } 85 | 86 | JDK(){ 87 | JDK_URL="http://$SERVER/mirrors/repo/jdk.repo" 88 | curl -sS -o /etc/yum.repos.d/jdk.repo $JDK_URL 89 | } 90 | 91 | ELK(){ 92 | ELK_URL="http://$SERVER/mirrors/repo/elk.repo" 93 | curl -sS -o /etc/yum.repos.d/elk.repo $ELK_URL 94 | } 95 | 96 | GLIBC(){ 97 | GLIBC_URL="http://$SERVER/mirrors/repo/glibc.repo" 98 | curl -sS -o /etc/yum.repos.d/glibc.repo $GLIBC_URL 99 | } 100 | _HELP(){ 101 | 102 | clear 103 | echo "+---------------------------------------------------------------------------------------+" 104 | echo "| Number images_command do " 105 | echo "+---------------------------------------------------------------------------------------+" 106 | echo "| 1 all backup repos_files then add mirrors all repos_files " 107 | echo "+---------------------------------------------------------------------------------------+" 108 | echo "| 2 init_base backup repos_files then add epel and CentOS6&7 repos_files " 109 | echo "+---------------------------------------------------------------------------------------+" 110 | echo "| 3 nginx add nginx repos_files" 111 | echo "+---------------------------------------------------------------------------------------+" 112 | echo "| 4 mongodb add mongodb repos_files" 113 | echo "+---------------------------------------------------------------------------------------+" 114 | echo "| 5 mariadb add mariadb repos_files" 115 | echo "+---------------------------------------------------------------------------------------+" 116 | echo "| 6 remi add remi56&remi72 repos_files" 117 | echo "+---------------------------------------------------------------------------------------+" 118 | echo "| 7 zabbix add zabbix repos_files" 119 | echo "+---------------------------------------------------------------------------------------+" 120 | echo "| 8 jdk add jdk repos_files" 121 | echo "+---------------------------------------------------------------------------------------+" 122 | echo "| 9 elk add elk repos_files" 123 | echo "+---------------------------------------------------------------------------------------+" 124 | echo "| 10 glibc add glibc for centos6 repos_files" 125 | echo "+---------------------------------------------------------------------------------------+" 126 | 127 | } 128 | 129 | case $1 in 130 | all ) 131 | Repo_Backup 132 | BASE_REPO 133 | ZABBIX 134 | MONGODB 135 | MARIADB 136 | NGINX 137 | REMI 138 | JDK 139 | ELK 140 | ;; 141 | init_base ) 142 | Repo_Backup 143 | BASE_REPO 144 | ;; 145 | zabbix ) 146 | ZABBIX 147 | ;; 148 | mongodb ) 149 | MONGODB 150 | ;; 151 | mariadb ) 152 | MARIADB 153 | ;; 154 | nginx ) 155 | NGINX 156 | ;; 157 | remi ) 158 | REMI 159 | ;; 160 | jdk ) 161 | JDK 162 | ;; 163 | elk ) 164 | ELK 165 | ;; 166 | glibc ) 167 | GLIBC 168 | ;; 169 | help ) 170 | _HELP 171 | ;; 172 | 173 | * ) 174 | Echo_Red "Please type help or repos_name!" 175 | ;; 176 | esac 177 | -------------------------------------------------------------------------------- /Gentoo-Install/Config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/profile 4 | function _check_directory(){ 5 | if [ -d $1 ];then 6 | echo "$1 is ok!" 7 | else mkdir -p $1 8 | fi 9 | } 10 | function _exit() 11 | { 12 | exit 9; 13 | } 14 | 15 | function _rm_files() 16 | { 17 | if [ -e $1 ]; then 18 | rm $1 19 | echo "Check $1 ok." 20 | return 0 21 | else 22 | echo "$1 not Found!!!" 23 | return 0 24 | fi 25 | } 26 | 27 | 28 | CPU=$(grep 'model name' /proc/cpuinfo |wc -l) 29 | ##更新 30 | function update(){ 31 | emerge-webrsync 32 | emerge --sync 33 | eselect profile list 34 | read -p "输入你想使用的配置 使用systemd需选上带有systemd字样的(gnome桌面请选上systemd).如果你想使用gnome或者kde桌面则选上对应的(只有选择5,6,7将自动安装基础桌面),如果你想使用其他桌面或者wm则选择desktop(openRC用)或systemd(systemd用)即可" PROFILE 35 | eselect profile set $PROFILE 36 | read -p "回车开始更新系统(可能要花一段时间,可以去看部电影)" 37 | emerge -uvDN --with-bdeps=y @world 38 | } 39 | 40 | ##时区 41 | function _date(){ 42 | echo "Asia/Shanghai" > /etc/timezone 43 | emerge --config sys-libs/timezone-data 44 | echo "en_US.UTF-8 UTF-8 45 | zh_CN.UTF-8 UTF-8" >> /etc/locale.gen 46 | locale-gen 47 | eselect locale list 48 | read -p "你想使用哪个语言 " TMP 49 | eselect locale set $TMP 50 | 51 | } 52 | 53 | function _mount(){ 54 | wget https://raw.githubusercontent.com/YangMame/Gentoo-Installer/master/genfstab 55 | chmod +x genfstab 56 | mv genfstab /usr/bin/ 57 | genfstab / -U > /etc/fstab 58 | } 59 | 60 | 61 | ##内核 62 | 63 | function kernel(){ 64 | read -p "使用哪个内核?ck-sources(推荐)或gentoo-sources输入y使用ck回车将使用gentoo-sources " TMP 65 | if [ "$TMP" == y ];then 66 | echo sys-kernel/ck-sources ~amd64 >> /etc/portage/package.accept_keywords 67 | emerge --autounmask-write genkernel 68 | etc-update --automode -3 69 | emerge ck-sources genkernel 70 | else 71 | emerge gentoo-sources genkernel 72 | fi 73 | 74 | ##安装文件系统工具 75 | if [ $1 == btrfs ];then 76 | emerge sys-fs/btrfs-progs 77 | elif [ $1 == xfs ];then 78 | emerge sys-fs/xfsprogs 79 | elif [ $1 == jfs ];then 80 | emerge sys-fs/jfsutils 81 | fi 82 | 83 | ##编译安装内核 84 | 85 | cd /usr/src/linux 86 | 87 | TMP=4 88 | while (($TMP!=1&&$TMP!=2&&$TMP!=3));do 89 | read -p "你想如何编译内核 90 | [1] 从网络上下载自己的内核配置 91 | [2] 使用genkernel all (如果你不会配置内核 建议选择这个) 92 | [3] 现场开始编译(建议参照金步国的文档配置:http://www.jinbuguo.com/kernel/longterm-linux-kernel-options.html) 93 | : " TMP 94 | if [ "$TMP" == 1 ];then 95 | tmp=n 96 | while [ "$tmp" == n ];do 97 | read -p "输入下载地址:" LINK 98 | wget -v $LINK -O .config 99 | make menuconfig 100 | read -p "回车开始编译安装内核(输入n重新下载)" tmp 101 | done 102 | make -j$CPU && make modules_install ##根据你CPU修改-j8 推荐核数x2 103 | make install 104 | genkernel --install initramfs 105 | elif [ "$TMP" == 2 ];then 106 | read -p "如果你使用的不是ext文件系统,则接下来需要进入内核配置中的file system选中你使用的文件系统(不是m是*选中)然后保存退出继续,否则直接保存退出开始编译" 107 | genkernel --menuconfig all 108 | elif [ "$TMP" == 3 ];then 109 | rm -f .config 110 | tmp=n 111 | while [ "$tmp" == n ];do 112 | make menuconfig 113 | read -p "回车开始编译安装内核(输入n重新进入配置)" tmp 114 | done 115 | make -j$CPU && make modules_install 116 | make install 117 | genkernel --install initramfs 118 | else echo 请输入正确数字 119 | fi 120 | done 121 | 122 | emerge --autounmask-write sys-kernel/linux-firmware 123 | etc-update --automode -3 124 | emerge sys-kernel/linux-firmware 125 | 126 | } 127 | 128 | # NetworkManager 129 | function _NetworkManager(){ 130 | read -p "安装NetworkManager " 131 | emerge --autounmask-write networkmanager 132 | etc-update --automode -3 133 | emerge networkmanager 134 | read -p "输入你的主机名: " TMP 135 | echo hostname=\"$TMP\" > /etc/conf.d/hostname 136 | } 137 | # tools 138 | function _tools(){ 139 | emerge app-admin/sysklogd sys-process/cronie sudo layman 140 | sed -i 's/\# \%wheel ALL=(ALL) ALL/\%wheel ALL=(ALL) ALL/g' /etc/sudoers 141 | crontab /etc/crontab 142 | echo "更改root密码 " 143 | passwd 144 | } 145 | 146 | 147 | function _grub(){ 148 | ##GRUB 149 | read -p "是否是UEFI启动?输入y或回车为legacy安装grub " TMP 150 | if [ "$TMP" == y ];then 151 | echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf 152 | emerge grub 153 | grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Gentoo 154 | else 155 | emerge grub 156 | fdisk -l 157 | read -p "输入你想安装Grub的磁盘 " GRUB 158 | grub-install --target=i386-pc $GRUB 159 | fi 160 | 161 | if [ $2 == systemd ];then 162 | sed -i 's/\# GRUB_CMDLINE_LINUX=\"init=\/usr\/lib\/systemd\/systemd\"/GRUB_CMDLINE_LINUX=\"init=\/usr\/lib\/systemd\/systemd\"/g' /etc/default/grub 163 | ln -sf /proc/self/mounts /etc/mtab 164 | systemd-machine-id-setup 165 | systemctl enable NetworkManager 166 | else 167 | rc-update add NetworkManager default 168 | fi 169 | 170 | grub-mkconfig -o /boot/grub/grub.cfg 171 | 172 | } 173 | 174 | function _add_user(){ 175 | ##添加用户 176 | read -p "输入你想创建的用户名(仅限小写字母,不推荐使用符号) :" USER 177 | useradd -m -G users,wheel,audio,cdrom,floppy,portage,usb,video $USER 178 | echo "设置用户密码" 179 | passwd $USER 180 | } 181 | 182 | function _install_desktop(){ 183 | ##安装桌面环境 184 | if [ "$PROFILE" == 5 ];then 185 | emerge gnome-shell gdm gnome-termianl 186 | gpasswd -a $USER gdm 187 | systemctl enable gdm 188 | elif [ "$PROFILE" == 6 ];then 189 | emerge --autounmask-write kde-plasma/plasma-meta sddm konsole plasma-pa plasma-nm 190 | etc-update --automode -3 191 | emerge kde-plasma/plasma-meta sddm konsole plasma-pa plasma-nm 192 | sed -i 's/DISPLAYMANAGER=\"xdm\"/DISPLAYMANAGER=\"sddm\"/g' /etc/conf.d/xdm 193 | usermod -a -G video sddm 194 | gpasswd -a $USER sddm 195 | sddm --example-config > /etc/sddm.conf 196 | rc-update add xdm default 197 | elif [ "$PROFILE" == 7 ];then 198 | emerge --autounmask-write kde-plasma/plasma-meta sddm konsole plasma-pa plasma-nm 199 | etc-update --automode -3 200 | emerge kde-plasma/plasma-meta sddm konsole plasma-pa plasma-nm 201 | systemctl enable sddm 202 | usermod -a -G video sddm 203 | gpasswd -a $USER sddm 204 | sddm --example-config > /etc/sddm.conf 205 | fi 206 | } 207 | 208 | function _two_videos(){ 209 | ##Bumblebee双显卡配置 210 | if [ $3 == 3 ];then 211 | echo "=sys-power/bbswitch-9999 ** 212 | =x11-misc/bumblebee-9999 ** 213 | =x11-misc/primus-0.2 ~amd64" >> /etc/portage/package.accept_keywords 214 | emerge --autounmask-write bbswitch primus bumblebee 215 | etc-update --automode -3 216 | emerge bbswitch primus bumblebee 217 | sed -i 's/Bridge=auto/Bridge=primus/g' /etc/bumblebee/bumblebee.conf 218 | sed -i 's/PMMethod=auto/PMMethod=bbswitch/g' /etc/bumblebee/bumblebee.conf 219 | sed -i '5,7d' /etc/init.d/bumblebee 220 | if [ $2 == systemd ];then 221 | systemctl enable bumblebeed 222 | else 223 | rc-update add bumblebee default 224 | fi 225 | gpasswd -a $USER bumblebee 226 | fi 227 | } 228 | 229 | 230 | function _end(){ 231 | read -p "回车进入系统运行命令,如果没有选择自动安装桌面的profile请在此步骤按照wiki安装桌面(配置完之后exit即可退出)" 232 | bash 233 | echo "谢谢使用 有用的话请赏个star" 234 | } 235 | 236 | function main(){ 237 | update 238 | _date 239 | _mount 240 | kernel 241 | _NetworkManager 242 | _tools 243 | _grub 244 | _add_user 245 | _install_desktop 246 | _two_videos 247 | _end 248 | } 249 | 250 | 251 | main 252 | -------------------------------------------------------------------------------- /Gentoo-Install/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # env 3 | MIRROR=mirrors.ustc.edu.cn 4 | GENTOO_MIRROR=https://$MIRROR/gentoo 5 | STAGE_MIRROR=$GENTOO_MIRROR/releases/amd64/autobuilds 6 | PORTAGE_MIRROR=rsync://rsync.$MIRROR/gentoo-portage 7 | # lib 8 | function _check_directory(){ 9 | if [ -d $1 ];then 10 | echo "$1 is ok!" 11 | else mkdir -p $1 12 | fi 13 | } 14 | function _exit() 15 | { 16 | exit 9; 17 | } 18 | 19 | function _rm_files() 20 | { 21 | if [ -e $1 ]; then 22 | rm $1 23 | echo "Check $1 ok." 24 | return 0 25 | else 26 | echo "$1 not Found!!!" 27 | return 0 28 | fi 29 | } 30 | 31 | 32 | 33 | CPU=$(grep 'model name' /proc/cpuinfo |wc -l) 34 | 35 | _check_directory /mnt/gentoo 36 | 37 | 38 | color(){ 39 | case $1 in 40 | red) 41 | echo -e "\033[31m$2\033[0m" 42 | ;; 43 | green) 44 | echo -e "\033[32m$2\033[0m" 45 | ;; 46 | esac 47 | } 48 | partition(){ 49 | if (echo $1 | grep '/' > /dev/null 2>&1);then 50 | other=$1 51 | else 52 | other=/$1 53 | fi 54 | 55 | fdisk -l 56 | color green "Input the partition (/dev/sdaX" 57 | read OTHER 58 | color green "Format it ? y)yes ENTER)no" 59 | read tmp 60 | 61 | if [ "$other" == "/boot" ];then 62 | boot=$OTHER 63 | fi 64 | 65 | if [ "$tmp" == y ];then 66 | umount $OTHER > /dev/null 2>&1 67 | color green "Input the filesystem's num to format it" 68 | select type in 'ext2' "ext3" "ext4" "btrfs" "xfs" "jfs" "fat" "swap";do 69 | case $type in 70 | "ext2") 71 | mkfs.ext2 $OTHER 72 | break 73 | ;; 74 | "ext3") 75 | mkfs.ext3 $OTHER 76 | break 77 | ;; 78 | "ext4") 79 | mkfs.ext4 $OTHER 80 | break 81 | ;; 82 | "btrfs") 83 | mkfs.btrfs $OTHER -f 84 | break 85 | ;; 86 | "xfs") 87 | mkfs.xfs $OTHER -f 88 | break 89 | ;; 90 | "jfs") 91 | mkfs.jfs $OTHER 92 | break 93 | ;; 94 | "fat") 95 | mkfs.fat -F32 $OTHER 96 | break 97 | ;; 98 | "swap") 99 | swapoff $OTHER > /dev/null 2>&1 100 | mkswap $OTHER -f 101 | break 102 | ;; 103 | *) 104 | color red "Error ! Please input the num again" 105 | ;; 106 | esac 107 | done 108 | fi 109 | 110 | if [ "$other" == "/swap" ];then 111 | swapon $OTHER 112 | else 113 | umount $OTHER > /dev/null 2>&1 114 | mkdir /mnt/gentoo$other 115 | mount $OTHER /mnt/gentoo$other 116 | fi 117 | } 118 | prepare(){ 119 | fdisk -l 120 | color green "Do you want to adjust the partition ? y)yes ENTER)no" 121 | read tmp 122 | if [ "$tmp" == y ];then 123 | color green "Input the disk (/dev/sdX" 124 | read TMP 125 | cfdisk $TMP 126 | fi 127 | color green "Input the ROOT(/) mount point:" 128 | read ROOT 129 | color green "Format it ? y)yes ENTER)no" 130 | read tmp 131 | if [ "$tmp" == y ];then 132 | umount $ROOT > /dev/null 2>&1 133 | color green "Input the filesystem's num to format it" 134 | select type in "ext4" "btrfs" "xfs" "jfs";do 135 | umount $ROOT > /dev/null 2>&1 136 | if [ "$type" == "btrfs" ];then 137 | mkfs.$type $ROOT -f 138 | elif [ "$type" == "xfs" ];then 139 | mkfs.$type $ROOT -f 140 | else 141 | mkfs.$type $ROOT 142 | fi 143 | break 144 | done 145 | fi 146 | mount $ROOT /mnt/gentoo 147 | color green "Do you have another mount point ? if so please input it, such as : /boot /home and swap or just ENTER to skip" 148 | read other 149 | while [ "$other" != '' ];do 150 | partition $other 151 | color green "Still have another mount point ? input it or just ENTER" 152 | read other 153 | done 154 | } 155 | _install_file(){ 156 | ##安装文件 157 | read -p "输入y使用openRC 回车使用systemd(如果你使用gnome桌面请务必选择systemd) " INIT 158 | cd /mnt/gentoo 159 | _rm_files index.html 160 | wget -q $STAGE_MIRROR/current-stage3-amd64/ 161 | LATEST=$(grep -o stage3-amd64-....................... index.html | head -1) 162 | if [ "$INIT" == y ];then 163 | INIT=openrc 164 | i 165 | if [ -f $LATEST ];then 166 | echo "file is ok!" 167 | tar xf $LATEST --xattrs --numeric-owner 168 | else 169 | echo "download file now!" 170 | wget -c $STAGE_MIRROR/current-stage3-amd64/$LATEST 171 | tar xf $LATEST --xattrs --numeric-owner 172 | fi 173 | 174 | else 175 | INIT=systemd 176 | # LATEST=$(wget -q $STAGE_MIRROR/current-stage3-amd64-systemd/ && grep -o stage3-amd64-systemd-.........tar.bz2 index.html | head -1) 177 | # wget -c $STAGE_MIRROR/current-stage3-amd64-systemd/$LATEST 178 | # echo 解压中... 179 | # tar xf $LATEST --xattrs --numeric-owner 180 | echo systemd 181 | fi 182 | 183 | # rm $LATEST 184 | 185 | if [ "$BOOT" == y ];then 186 | umount $boot 187 | mount -v $boot /mnt/gentoo/boot 188 | fi 189 | } 190 | 191 | 192 | 193 | config_make(){ 194 | 195 | cat > /mnt/gentoo/etc/portage/make.conf << EOF 196 | # GCC 197 | CHOST="x86_64-pc-linux-gnu" 198 | CFLAGS="-march=native -O2 -pipe" 199 | CXXFLAGS="${CFLAGS}" 200 | MAKEOPTS="-j$CPU" 201 | 202 | # PORTAGE 203 | PORTDIR="/usr/portage" 204 | DISTDIR="${PORTDIR}/distfiles" 205 | PKGDIR="${PORTDIR}/packages" 206 | GENTOO_MIRRORS="http://mirrors.tuna.tsinghua.edu.cn/gentoo/" 207 | 208 | # USE 209 | DEV="git" 210 | FUCK="-systemd -nautilus" 211 | ELSE="python client acl bzip2" 212 | SYSTEM_ARCH="amd64" 213 | USE="${DEV} ${FUCK} ${ELSE} ${SYSTEM_ARCH}" 214 | 215 | # LICENSED 216 | ACCEPT_KEYWORDS="amd64" 217 | ACCEPT_LICENSE="*" 218 | 219 | # LANGUAGE 220 | L10N="en-US zh-CN en zh" 221 | LINGUAS="en_US zh_CN en zh" 222 | 223 | # ELSE 224 | LLVM_TARGETS="X86" 225 | EOF 226 | } 227 | 228 | _video(){ 229 | ##Video Cards 230 | VIDEO=6 231 | while (($VIDEO!=1&&$VIDEO!=2&&$VIDEO!=3&&$VIDEO!=4&&$VIDEO!=5));do 232 | echo "输入对应的显卡配置 233 | [1] Intel 234 | [2] Nvidia 235 | [3] Intel/Nvidia 236 | [4] AMD/ATI 237 | [5] Intel/AMD" 238 | read VIDEO 239 | if [ "$VIDEO" == 1 ];then 240 | echo VIDEO_CARDS=\"intel i965\" >> /mnt/gentoo/etc/portage/make.conf 241 | elif [ "$VIDEO" == 2 ];then 242 | echo VIDEO_CARDS=\"nvidia\" >> /mnt/gentoo/etc/portage/make.conf 243 | elif [ "$VIDEO" == 3 ];then 244 | echo VIDEO_CARDS=\"intel i965 nvidia\" >> /mnt/gentoo/etc/portage/make.conf 245 | elif [ "$VIDEO" == 4 ];then 246 | echo VIDEO_CARDS=\"radeon\" >> /mnt/gentoo/etc/portage/make.conf 247 | elif [ "$VIDEO" == 5 ];then 248 | echo VIDEO_CARDS=\"intel i965 radeon\" >> /mnt/gentoo/etc/portage/make.conf 249 | else echo 请输入正确数字 250 | fi 251 | done 252 | } 253 | 254 | _mirrors(){ 255 | _check_directory /mnt/gentoo/etc/portage/repos.conf 256 | cat > /mnt/gentoo/etc/portage/repos.conf/gentoo.conf << EOF 257 | 258 | [DEFAULT] 259 | main-repo = gentoo 260 | 261 | [gentoo] 262 | location = /usr/portage 263 | sync-type = rsync 264 | sync-uri = rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage/ 265 | #sync-uri = rsync://rsync.mirrors.ustc.edu.cn/gentoo-portage/ 266 | auto-sync = yes 267 | sync-rsync-verify-jobs = 1 268 | sync-rsync-verify-metamanifest = yes 269 | sync-rsync-verify-max-age = 24 270 | sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc 271 | sync-openpgp-key-refresh-retry-count = 40 272 | sync-openpgp-key-refresh-retry-overall-timeout = 1200 273 | sync-openpgp-key-refresh-retry-delay-exp-base = 2 274 | sync-openpgp-key-refresh-retry-delay-max = 60 275 | sync-openpgp-key-refresh-retry-delay-mult = 4 276 | 277 | EOF 278 | 279 | } 280 | 281 | 282 | 283 | _chroot(){ 284 | mount -t proc /proc /mnt/gentoo/proc 285 | mount --rbind /sys /mnt/gentoo/sys 286 | mount --make-rslave /mnt/gentoo/sys 287 | mount --rbind /dev /mnt/gentoo/dev 288 | mount --make-rslave /mnt/gentoo/dev 289 | rm -f /mnt/gentoo/etc/resolv.conf 290 | cp /etc/resolv.conf /mnt/gentoo/etc/ 291 | # cd /mnt/gentoo/root/ 292 | # wget https://raw.githubusercontent.com/slmoby/script/master/Gentoo-Install/Config.sh 293 | # chmod +x Config.sh 294 | _rm_files /mnt/gentoo/root/Config.sh 295 | cp /root/Config.sh /mnt/gentoo/root 296 | chmod +x /mnt/gentoo/root/Config.sh 297 | chroot /mnt/gentoo /root/Config.sh 298 | } 299 | 300 | # $FILESYSTEM $INIT $VIDEO 301 | 302 | main(){ 303 | partition 304 | prepare 305 | _install_file 306 | config_make 307 | _video 308 | _mirrors 309 | _chroot 310 | 311 | } 312 | main 313 | 314 | -------------------------------------------------------------------------------- /mirror_project/php.sh: -------------------------------------------------------------------------------- 1 | #============================================================= 2 | #============================================================= 3 | # ================ PHP for CentOS6 =========================== 4 | #============================================================= 5 | #============================================================= 6 | ## REMI for CentOS6 7 | function _rsync_remi_6(){ 8 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/remi/x86_64/ $REMI6/x86_64/ 9 | _update_repos $REMI6/x86_64/ 10 | } 11 | 12 | ## REMI PHP Test 13 | ## CentOS6 14 | function _rsync_remi_6_test(){ 15 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/test/x86_64 $REMI6/test 16 | _update_repos $REMI6/test 17 | } 18 | 19 | ## REMIE PHP 56 20 | ## CentOS6 Only sync x86_64 basearch 21 | function _rsync_remi_6_56(){ 22 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/php56/x86_64/ $REMI6/php56/ 23 | _update_repos $REMI6/php56/ 24 | } 25 | ## REMI PHP 56 debuginfo 26 | function _rsync_remi6_php56_debuginfo(){ 27 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/debug-php56/x86_64 $REMI6/debug-php56 28 | _update_repos $REMI6/debug-php56 29 | } 30 | 31 | ## REMI 56 test 32 | ## CentOS6 Only rsync x86_64 basearch 33 | function _rsync_remi6_php56_test(){ 34 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/test56/x86_64 $REMI6/test56 35 | _update_repos $REMI6/test56 36 | } 37 | ## REMI 56 test info 38 | ## CentOS6 Only sync x86_64 basearch 39 | function _rsync_remi6_php56_test_info(){ 40 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/debug-test56/x86_64 $REMI6/debug-test56 41 | _update_repos $REMI6/debug-test56 42 | } 43 | 44 | 45 | ## REMI PHP 72 46 | ## CentOS6 47 | function _rsync_remi_6_72(){ 48 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/remi72/x86_64/ $REMI6/php72 49 | _update_repos $REMI6/php72 50 | } 51 | ## REMI 72 debuginfo 52 | ## CentOS6 Only rsync x86_64 basearch 53 | function _rsync_remi6_php72_debuginfo(){ 54 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/debug-php72/x86_64 $REMI6/debug-php72 55 | _update_repos $REMI/debug-php72 56 | } 57 | ## REMI 72 test 58 | ## CentOS6 Only rsync x86_64 basearch 59 | function _rsync_remi6_php72_test(){ 60 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/test72/x86_64 $REMI6/test72 61 | _update_repos $REMI6/test72 62 | } 63 | ## REMI 72 test info 64 | ## CentOS6 Only sync x86_64 basearch 65 | function _rsync_remi6_php72_test_info(){ 66 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/6/debug-test72/x86_64 $REMI6/debug-test72 67 | _update_repos $REMI6/debug-test72 68 | } 69 | 70 | 71 | #============================================================= 72 | #============================================================= 73 | # ================ PHP for CentOS7 =========================== 74 | #============================================================= 75 | #============================================================= 76 | 77 | 78 | ## REMI PHP Test 79 | ## CentOS7 Only Rsync x86_64 80 | 81 | ## REMI for CentOS7 82 | function _rysnc_remi_7(){ 83 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/remi/x86_64 $REMI7/x86_64 84 | _update_repos $REMI7/x86_64 85 | } 86 | 87 | 88 | function _rsync_remi_7_test(){ 89 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/test/x86_64 $REMI7/test 90 | _update_repos $REMI7/test 91 | } 92 | 93 | 94 | ## REMI PHP 56 For CentOS7 95 | ## Only sync basearch x86_64 96 | function _rsync_remi_56_7(){ 97 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/php56/x86_64/ $REMI7/56 98 | _update_repos $REMI7/56/ 99 | } 100 | ## REMI PHP56 for CentOS7 Test 101 | ## Only sync basearch 102 | function _rsync_remi_56_7_test(){ 103 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/test56/x86_64 $REMI7/test56 104 | _update_repos $REMI7/test56 105 | } 106 | 107 | ## REMI PHP56 info 108 | ## Only sync basearch 109 | function _rsync_remi_56_7_info(){ 110 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/debug-php56/x86_64 $REMI7/debug-php56 111 | _update_repos $REMI7/debug-php56 112 | } 113 | ## REMI PHP56 TestInfo 114 | ## Only sync basearch 115 | function _rsync_remi_56_7_testinfo(){ 116 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/debug-test56/x86_64/ $REMI7/debug-test56 117 | _update_repos $REMI7/debug-test56 118 | } 119 | ## REMI PHP 72 120 | function _rsync_remi_72_7(){ 121 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/php72/x86_64/ $REMI7/72 122 | _update_repos $REMI7/72 123 | } 124 | 125 | function _rsync_remi_72_7_test(){ 126 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/test72/x86_64 $REMI7/test72 127 | _update_repos $REMI7/test72 128 | } 129 | 130 | ## REMI PHP72 info 131 | ## Only sync basearch 132 | function _rsync_remi_72_7_info(){ 133 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/debug-php72/x86_64 $REMI7/debug-php72 134 | _update_repos $REMI7/debug-php72 135 | } 136 | ## REMI PHP72 TestInfo 137 | ## Only sync basearch 138 | function _rsync_remi_72_7_testinfo(){ 139 | _rsync_mirrors $Config_DIR/remi.list $rsync_tuna/remi/enterprise/7/debug-test72/x86_64/ $REMI7/debug-test72 140 | _update_repos $REMI7/debug-test72 141 | } 142 | 143 | ############### 144 | ###### man #### 145 | ############### 146 | 147 | 148 | function _check_dir(){ 149 | _check_directory $REMI6/x86_64/ 150 | _check_directory $REMI6/test 151 | _check_directory $REMI6/php56/ 152 | _check_directory $REMI6/debug-php56 153 | _check_directory $REMI6/test56 154 | _check_directory $REMI6/debug-test56 155 | _check_directory $REMI6/php72 156 | _check_directory $REMI/debug-php72 157 | _check_directory $REMI6/test72 158 | _check_directory $REMI6/debug-test72 159 | _check_directory $REMI7/x86_64 160 | _check_directory $REMI7/test 161 | _check_directory $REMI7/56/ 162 | _check_directory $REMI7/test56 163 | _check_directory $REMI7/debug-php56 164 | _check_directory $REMI7/debug-test56 165 | _check_directory $REMI7/72 166 | _check_directory $REMI7/test72 167 | _check_directory $REMI7/debug-php72 168 | _check_directory $REMI7/debug-test72 169 | } 170 | 171 | function repo_file(){ 172 | cat > $REPO/remi-6.repo << EOF 173 | [remi] 174 | name = remi6 175 | baseurl = http://$IP/$WEB/remi/6/x86_64 176 | enable = 1 177 | gpgcheck = 0 178 | 179 | [remi-test] 180 | name = remi6 Test 181 | baseurl = http://$IP/$WEB/remi/6/test 182 | enable = 1 183 | gpgcheck = 0 184 | 185 | 186 | EOF 187 | cat > $REPO/remi56-6.repo << EOF 188 | [remi56] 189 | name = remi56 190 | baseurl = http://$IP/$WEB/remi/6/php56 191 | enable = 1 192 | gpgcheck = 0 193 | 194 | 195 | [remi56-debug] 196 | name = remi56 debug 197 | baseurl = http://$IP/$WEB/remi/6/debug-php56 198 | enable = 1 199 | gpgcheck = 0 200 | 201 | [remi56-test] 202 | name = remi56 test 203 | baseurl = http://$IP/$WEB/remi/6/test56 204 | enable = 1 205 | gpgcheck = 0 206 | 207 | [remi56-debug-test] 208 | name = remi56 debug test 209 | baseurl = http://$IP/$WEB/remi/6/debug-test56 210 | enable = 1 211 | gpgcheck = 0 212 | 213 | 214 | EOF 215 | 216 | cat > $REPO/remi72-6.repo << EOF 217 | [remi72] 218 | name = remi72 219 | baseurl = http://$IP/$WEB/remi/6/72/ 220 | gpgcheck = 0 221 | 222 | [remi72-debug] 223 | name = remi56 debug 224 | baseurl = http://$IP/$WEB/remi/6/debug-php72 225 | enable = 1 226 | gpgcheck = 0 227 | 228 | [remi72-test] 229 | name = remi72 test 230 | baseurl = http://$IP/$WEB/remi/6/test72 231 | enable = 1 232 | gpgcheck = 0 233 | 234 | [remi72-debug-test] 235 | name = remi72 debug test 236 | baseurl = http://$IP/$WEB/remi/6/debug-test72 237 | enable = 1 238 | gpgcheck = 0 239 | 240 | EOF 241 | 242 | cat > $REPO/remi-7.repo << EOF 243 | 244 | [remi] 245 | name = remi7 246 | baseurl = http://$IP/$WEB/remi/7/x86_64 247 | enable = 1 248 | gpgcheck = 0 249 | 250 | [remi-test] 251 | name = remi7 test 252 | baseurl = http://$IP/$WEB/remi/7/test 253 | enable = 1 254 | gpgcheck = 0 255 | 256 | EOF 257 | cat > $REPO/remi56-7.repo << EOF 258 | 259 | 260 | [remi56] 261 | name = remi56 262 | baseurl = http://$IP/$WEB/remi/7/php56 263 | enable = 1 264 | gpgcheck = 0 265 | 266 | 267 | [remi56-debug] 268 | name = remi56 debug 269 | baseurl = http://$IP/$WEB/remi/7/debug-php56 270 | enable = 1 271 | gpgcheck = 0 272 | 273 | [remi56-test] 274 | name = remi56 test 275 | baseurl = http://$IP/$WEB/remi/7/test56 276 | enable = 1 277 | gpgcheck = 0 278 | 279 | [remi56-debug-test] 280 | name = remi56 debug test 281 | baseurl = http://$IP/$WEB/remi/7/debug-test56 282 | enable = 1 283 | gpgcheck = 0 284 | EOF 285 | 286 | cat > $REPO/remi72-7.repo << EOF 287 | [remi72] 288 | name = remi72 289 | baseurl = http://$IP/$WEB/remi/7/72/ 290 | gpgcheck = 0 291 | 292 | [remi72-debug] 293 | name = remi56 debug 294 | baseurl = http://$IP/$WEB/remi/7/debug-php72 295 | enable = 1 296 | gpgcheck = 0 297 | 298 | [remi72-test] 299 | name = remi72 test 300 | baseurl = http://$IP/$WEB/remi/7/test72 301 | enable = 1 302 | gpgcheck = 0 303 | 304 | [remi72-debug-test] 305 | name = remi72 debug test 306 | baseurl = http://$IP/$WEB/remi/7/debug-test72 307 | enable = 1 308 | gpgcheck = 0 309 | EOF 310 | 311 | } 312 | function PHP(){ 313 | _check_dir 314 | _rsync_remi_6 315 | _rsync_remi_6_test 316 | _rsync_remi_6_56 317 | _rsync_remi6_php56_debuginfo 318 | _rsync_remi6_php56_test 319 | _rsync_remi6_php56_test_info 320 | _rsync_remi_6_72 321 | _rsync_remi6_php72_debuginfo 322 | _rsync_remi6_php72_test 323 | _rsync_remi6_php72_test_info 324 | _rysnc_remi_7 325 | _rsync_remi_7_test 326 | _rsync_remi_56_7 327 | _rsync_remi_56_7_test 328 | _rsync_remi_56_7_info 329 | _rsync_remi_56_7_testinfo 330 | _rsync_remi_72_7 331 | _rsync_remi_72_7_test 332 | _rsync_remi_72_7_info 333 | _rsync_remi_72_7_testinfo 334 | repo_file 335 | } 336 | -------------------------------------------------------------------------------- /mirror_project/mirros.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ########### function start ########## 3 | ##################################### 4 | ##################################### 5 | function _exit() 6 | { 7 | exit 9; 8 | } 9 | 10 | function _wget_url() 11 | { 12 | wget -c $1 > /dev/null 2>&1 13 | } 14 | 15 | function _check_dir_file_exist() 16 | { 17 | if [ -e $1 ]; then 18 | echo "Check $1 ok." 19 | return 0 20 | else 21 | echo "Check $1 Not Found!!!" 22 | return 1 23 | fi 24 | } 25 | 26 | function _rsync_mirrors() 27 | { 28 | rsync -avz --exclude-from=$1 $2 $3 29 | } 30 | 31 | 32 | function _source_file_exist() 33 | { 34 | if [ -e $1 ]; then 35 | echo "Check $1 ok." 36 | source $1 37 | return 0 38 | else 39 | echo "Check $1 Not Found!!!" 40 | return 1 41 | fi 42 | } 43 | 44 | 45 | function _check_command_and_yum_install(){ 46 | type $1 >/dev/null 2>&1 || { echo >&2 "I require $1 but it's not installed. Aborting."; yum install $1 -y; } 47 | } 48 | 49 | function _check_process() 50 | { 51 | pgrep $1 > /dev/null 52 | } 53 | 54 | function _blackcolor { 55 | echo -e "\033[32m$1\033[0m" 56 | } 57 | function _redcolor { 58 | echo -e "\033[31m$1\033[0m" 59 | } 60 | function _greencolor { 61 | echo -e "\033[32m$1\033[0m" 62 | } 63 | function _bluecolor { 64 | echo -e "\033[34m$1\033[0m" 65 | } 66 | function _purplecolor { 67 | echo -e "\033[35m$1\033[0m" 68 | } 69 | function _skybluecolor { 70 | echo -e "\033[36m$1\033[0m" 71 | } 72 | 73 | 74 | function _update_repos(){ 75 | if [ -d $1/repodate ]; then 76 | createrepo --update $1 77 | else 78 | createrepo $1 79 | fi 80 | 81 | } 82 | 83 | function _wget_incloud_file(){ 84 | wget --input-file=$1 --continue --directory-prefix=$2 85 | } 86 | 87 | function _check_directory(){ 88 | if [ -d $1 ];then 89 | echo "$1 is ok!" 90 | else mkdir -p $1 91 | fi 92 | } 93 | 94 | ######################### 95 | ### funciton end######### 96 | ######################### 97 | 98 | ######################### 99 | ####### Incloud files#### 100 | ######################### 101 | 102 | _source_file_exist stack.sh 103 | _source_file_exist static-repo.sh 104 | _source_file_exist php.sh 105 | 106 | ######################### 107 | ####### Incloud end###### 108 | ######################### 109 | 110 | 111 | 112 | 113 | ####################### 114 | ####### env config #### 115 | ####################### 116 | # env config 117 | Config_DIR=./config 118 | DATA_DIR=/data/mirrors 119 | #DATA_DIR=/Users/chaos/Desktop/tmp 120 | #EPEL 121 | EPEL6=$DATA_DIR/epel/6 122 | EPEL7=$DATA_DIR/epel/7 123 | # CentOS 124 | CentOS7=$DATA_DIR/centos/7 125 | CentOS6=$DATA_DIR/centos/6 126 | # Cloud 127 | Rocky=$CentOS7/cloud 128 | # Mongodb 129 | MONGODB6=$DATA_DIR/mongodb/6 130 | MONGODB7=$DATA_DIR/mongodb/7 131 | # Mariadb 132 | Mariadb7=$DATA_DIR/mariadb/7 133 | Mariadb6=$DATA_DIR/mariadb/6 134 | # Nginx 135 | Nginx6=$DATA_DIR/nginx/6 136 | Nginx7=$DATA_DIR/nginx/7 137 | # REMI 138 | REMI6=$DATA_DIR/remi/6 139 | REMI7=$DATA_DIR/remi/7 140 | # zabbix 141 | ZABBIX6=$DATA_DIR/zabbix/6 142 | ZABBIX7=$DATA_DIR/zabbix/7 143 | # Glibc 144 | GLIBC=$DATA_DIR/glibc/6 145 | 146 | # pinpoint 147 | pinpoint=$DATA_DIR/pinpoint 148 | # Repos 149 | REPO=$DATA_DIR/repo 150 | # Glpi 151 | GLPI_91=$DATA_DIR/glpi/6/91 152 | GLPI_93=$DATA_DIR/glpi/6/93 153 | # DOCKER 154 | DOCKER=$DATA_DIR/docker 155 | #### ------------ 156 | #### ------------ 157 | #### ------------ 158 | #### ---WEB------ 159 | WEB=mirrors 160 | 161 | ## END 162 | 163 | function Check_directory(){ 164 | _check_directory $DATE_DIR 165 | _check_directory $CentOS7/os/x86_64 166 | _check_directory $CentOS7/updates/x86_64/ 167 | _check_directory $CentOS7/extras/x86_64/ 168 | _check_directory $CentOS6/os/x86_64 169 | _check_directory $CentOS6/updates/x86_64 170 | _check_directory $CentOS6/extras/x86_64 171 | _check_directory $EPEL6/x86_64/ 172 | _check_directory $EPEL7/x86_64 173 | _check_directory $Mariadb7/x86_64 174 | _check_directory $Mariadb6/x86_64 175 | _check_directory $ZABBIX6/x86_64/ 176 | _check_directory $ZABBIX6/non-supported/x86_64/ 177 | _check_directory $ZABBIX7/x86_64/ 178 | _check_directory $ZABBIX7/non-supported/x86_64/ 179 | _check_directory $GLIBC 180 | _check_directory $MONGODB6 181 | _check_directory $MONGODB7 182 | _check_directory $Nginx6 183 | _check_directory $Nginx7 184 | _check_directory $REPO 185 | _check_directory $GLPI_91 186 | _check_directory $GLPI_93 187 | _check_directory $pinpoint 188 | _check_directory $Rocky 189 | _check_directory $DOCKER 190 | } 191 | 192 | # rsync_url 193 | rsync_tuna=rsync://mirrors.tuna.tsinghua.edu.cn 194 | function _check_path(){ 195 | _check_command_and_yum_install rsync 196 | _check_command_and_yum_install createrepo 197 | _check_command_and_yum_install wget 198 | } 199 | 200 | ###### env config end######### 201 | ############################### 202 | 203 | ############ RUN ############# 204 | ############################## 205 | #!/bin/bash 206 | 207 | function List(){ 208 | clear 209 | echo "+---------------------------------------------------------------------------------------+" 210 | echo "| Number images_command Website Local_Path " 211 | echo "+---------------------------------------------------------------------------------------+" 212 | echo "| 1 epel6 $rsync_tuna $EPEL6 " 213 | echo "+---------------------------------------------------------------------------------------+" 214 | echo "| 2 epel7 $rsync_tuna $EPEL7" 215 | echo "+---------------------------------------------------------------------------------------+" 216 | echo "| 3 centos7 $rsync_tuna $CentOS7" 217 | echo "+---------------------------------------------------------------------------------------+" 218 | echo "| 4 centos6 $rsync_tuna $CentOS6" 219 | echo "+---------------------------------------------------------------------------------------+" 220 | echo "| 5 mariadb $rsync_tuna $DATA_DIR/mariadb" 221 | echo "+---------------------------------------------------------------------------------------+" 222 | echo "| 6 remi $rsync_tuna $DATA_DIR/remi" 223 | echo "+---------------------------------------------------------------------------------------+" 224 | echo "| 7 mongodb $rsync_tuna $MONGODB6" 225 | echo "+---------------------------------------------------------------------------------------+" 226 | echo "| 8 zabbix6 $rsync_tuna $ZABBIX6" 227 | echo "+---------------------------------------------------------------------------------------+" 228 | echo "| 9 zabbix7 $rsync_tuna $ZABBIX7" 229 | echo "+---------------------------------------------------------------------------------------+" 230 | echo "| Wget " 231 | echo "+---------------------------------------------------------------------------------------+" 232 | echo "| 10 glibc $REDSLEVE $GLIBC" 233 | echo "+---------------------------------------------------------------------------------------+" 234 | echo "| 11 nginx $USTC $Nginx " 235 | echo "+---------------------------------------------------------------------------------------+" 236 | } 237 | 238 | function RUN(){ 239 | clear 240 | echo "+------------------------------------------------------------------------+" 241 | echo "| Rsync Script " 242 | echo "+------------------------------------------------------------------------+" 243 | echo "| This script is only allowed to execute on the CentOS system" 244 | echo "+------------------------------------------------------------------------+" 245 | echo "| Rsync base packages mirrors " 246 | echo "+------------------------------------------------------------------------+" 247 | echo "| For more information please visit docs " 248 | echo "+------------------------------------------------------------------------+" 249 | echo "| If you are running for the first time, check your environment with the check option." 250 | echo "| You can use the list to see which images can be synchronized." 251 | echo "+------------------------------------------------------------------------+" 252 | echo "|Use the corresponding image name to sync, or use all to sync all" 253 | echo "+------------------------------------------------------------------------+" 254 | } 255 | 256 | ############################### 257 | ########### RUN END ########### 258 | ############################### 259 | 260 | 261 | 262 | ############################# 263 | ####### Config file########## 264 | ############################# 265 | function _check_config(){ 266 | if [ -d config ];then 267 | echo "config direcrory is ok" 268 | else 269 | mkdir -pv config 270 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/config/CurlConfigFile && bash -x CurlConfigFile 271 | fi 272 | } 273 | 274 | function _check_add(){ 275 | if [ -f add.sh ];then 276 | echo "add.sh is done" 277 | else 278 | curl -LO https://raw.githubusercontent.com/slmoby/script/master/mirror_project/add.sh 279 | fi 280 | } 281 | 282 | ### Download file end 283 | ####################### 284 | ##### Menu ############ 285 | ####################### 286 | ####################### 287 | case $1 in 288 | status ) 289 | ;; 290 | check ) 291 | _check_path 292 | _check_config 293 | Check_directory 294 | _check_add 295 | ;; 296 | list ) 297 | List 298 | ;; 299 | centos7) 300 | _rsync_CentOS7 301 | ;; 302 | centos6) 303 | _rsync_CentOS6 304 | ;; 305 | epel6 ) 306 | _rsync_EPEL6 307 | ;; 308 | epel7 ) 309 | _rsync_EPEL7 310 | ;; 311 | mariadb ) 312 | _rsync_mariadb7 313 | _rsync_mariadb6 314 | ;; 315 | 316 | zabbix6 ) 317 | _zabbix_6 318 | ;; 319 | zabbix7) 320 | _zabbix_7 321 | ;; 322 | glibc ) 323 | _wget_glibc 324 | ;; 325 | mongodb) 326 | _mongodb_3.6_6 327 | _mongodb_3.6_7 328 | ;; 329 | nginx ) 330 | _nginx_centos6 331 | _nginx_centos7 332 | ;; 333 | createrepos ) 334 | _create_repos_file 335 | _chage_add_repos 336 | ;; 337 | server ) 338 | _mirrors_server 339 | links_for_mirrors 340 | ;; 341 | httpd_firewalld ) 342 | _firewalld_httpd 343 | ;; 344 | remi ) 345 | PHP 346 | ;; 347 | rocky ) 348 | _openstack_r 349 | ;; 350 | docker ) 351 | _docker_ce 352 | ;; 353 | all ) 354 | docker 355 | nginx 356 | glibc 357 | mongodb 358 | centos6 359 | centos7 360 | epel7 361 | epel6 362 | zabbix7 363 | zabbix6 364 | mariadb 365 | ;; 366 | * ) 367 | RUN 368 | ;; 369 | esac 370 | --------------------------------------------------------------------------------