[UPDATE] - add epel

This commit is contained in:
Guillaume Astier 2021-12-10 13:23:31 +01:00
parent 418093e181
commit f088671e32
5 changed files with 79 additions and 10 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
./data

2
.env Normal file
View File

@ -0,0 +1,2 @@
CentOsVersion=7.9.2009
Run=sync.sh

View File

@ -1,6 +1,6 @@
FROM centos:7.9.2009
FROM centos:${CentOsVersion}
ENV container docker
RUN echo coucou
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
@ -11,9 +11,15 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
RUN yum install yum-utils createrepo vim -y
RUN yum install epel-release -y
COPY ./bin/sync.sh /bin/sync.sh
RUN chmod 755 /bin/sync.sh
COPY ./bin/empty.sh /bin/empty.sh
RUN chmod 755 /bin/empty.sh
#CMD ["/usr/sbin/init"]
CMD ["/bin/sync.sh"]
#CMD ["/bin/sync.sh"]
CMD ["/bin/${Run}"]

7
bin/empty.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
while true
do
sleep 1
done

View File

@ -1,10 +1,63 @@
#!/bin/bash
[[ ! -d /data/log ]] && mkdir /data/log
[[ ! -d /data/repo ]] && mkdir /data/repo
for Repo in $(yum repolist | grep x86_64 | awk -F'/' '{print $1}')
do
echo "$Repo"
reposync --gpgcheck -l --repoid=${Repo} --download_path=/data/repo/ | tee /data/log/${Repo}.log
done
Res() {
if [[ $1 -eq 0 ]]
then
echo "$(tput setaf 2)OK$(tput sgr0)"
else
echo "$(tput setaf 1)FAILED$(tput sgr0)"
fi
}
[[ $1 == "del" ]] && rm -Rf /data/repo /data/log
[[ ! -d /data/log ]] && mkdir -p /data/log
[[ ! -d /data/repo ]] && mkdir -p /data/repo
echo -n "Get OS BASE : "
mkdir /data/repo/tmp/
cd /data/repo/tmp/
wget -r -p -k http://mirror.centos.org/centos/7.9.2009/os/x86_64/ 2>&1 | tee /data/log/get_base.log &> /dev/null
Res $?
for var in $(find .| grep index.html) ;do rm -f $var;done
mkdir -p /data/repo/CentOS/7.9/os/
mv /data/repo/tmp/mirror.centos.org/centos/7.9.2009/os/x86_64/ /data/repo/CentOS/7.9/os/
rm -rf /data/repo/tmp/*
echo -n "Get OS updates : "
cd /data/repo/tmp/
wget -r -p -k http://mirror.centos.org/centos/7.9.2009/updates/x86_64/ 2>&1 | tee /data/log/get_updates.log &> /dev/null
Res $?
for var in $(find . | grep index.html) ;do rm -f $var;done
mkdir -p /data/repo/CentOS/7.9/updates
mv /data/repo/tmp/mirror.centos.org/centos/7.9.2009/updates/x86_64/ /data/repo/CentOS/7.9/updates/
rm -Rf /data/repo/tmp/
echo -n "Get epel : "
Repo=epel
reposync -l --newest-only --delete --downloadcomps --download-metadata --repoid=${Repo} --download_path=/data/repo/ 2>&1 | tee /data/log/get_${Repo}.log &> /dev/null
Res $?
for var in $(find /data/repo/epel/ -name *rpm) ; do mv $var /data/repo/epel/Packages/; done
echo -n "Create repo epel : "
cd /data/repo/epel
createrepo -v /data/repo/epel 2>&1 | tee /data/log/CreateRepo_${Repo}.log &> /dev/null
Res $?
echo -n "Move EPEL : "
mkdir -p /data/repo/EPEL/el7/x86_64/ &&
mv /data/repo/epel/* /data/repo/EPEL/el7/x86_64/ &&
rmdir /data/repo/epel/
Res $?