138 lines
5.7 KiB
Bash
Executable file
138 lines
5.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
echo "Start: $(date)"
|
|
REPOS_RACINE=/var/www/html/repos
|
|
YUM_CONF=/etc/yum-mirror.repo.d
|
|
|
|
if [ -e /var/run/update_mirror ]; then
|
|
echo "Update mirror is already running"
|
|
exit 1
|
|
else
|
|
echo "$$" > /var/run/update_mirror
|
|
fi
|
|
|
|
if [ ! $(which reposync 2>/dev/null) ]; then
|
|
yum install -y yum-utils createrepo
|
|
fi
|
|
if [ ! $(which lftp 2>/dev/null) ]; then
|
|
yum install -y lftp
|
|
fi
|
|
|
|
#yum repolist --enablerepo=*
|
|
#reposync --downloadcomps --download-metadata --arch=$(uname -m) --repoid=tor --tempcache --download_path=/var/www/html/CentOS7/
|
|
|
|
#ARCH=armv6l
|
|
#for i in base updates; do
|
|
# reposync --config="${YUM_CONF}"/RedSleeve7-base.repo --arch=$ARCH --norepopath --repoid=$i --tempcache --delete --download_path="${REPOS_RACINE}"/$ARCH/${i/base/os}/Packages/
|
|
# createrepo "${REPOS_RACINE}"/$ARCH/${i/base/os}/
|
|
#done
|
|
|
|
|
|
|
|
###################################################################
|
|
# Springdale
|
|
#
|
|
|
|
#DIST=Springdale7
|
|
#ARCH=i686
|
|
#reposync --config="${YUM_CONF}"/springdale-7.repo --arch=$ARCH --norepopath --repoid=core --tempcache --delete --download_path="${REPOS_RACINE}"/"$DIST"/$ARCH/os/Packages/
|
|
#createrepo "${REPOS_RACINE}"/$ARCH/os/
|
|
#reposync --config="${YUM_CONF}"/springdale-7.repo --arch=$ARCH --norepopath --repoid=addons-core --tempcache --delete --download_path="${REPOS_RACINE}"/"$DIST"/$ARCH/Addons/Packages/
|
|
#createrepo "${REPOS_RACINE}"/$ARCH/Addons
|
|
#for REP in "${REPOS_RACINE}"/$ARCH/os/{LiveOS,images/pxeboot}; do
|
|
# if [ ! -d "$REP" ]; then
|
|
# mkdir -p "$REP"
|
|
# fi
|
|
#done
|
|
#wget -N http://springdale.math.ias.edu/data/springdale/7/i386/os/LiveOS/squashfs.img --directory-prefix="${REPOS_RACINE}"/"$DIST"/$ARCH/os/LiveOS/
|
|
#wget -N http://springdale.math.ias.edu/data/springdale/7/i386/os/images/boot.iso --directory-prefix="${REPOS_RACINE}"/"$DIST"/$ARCH/os/images/
|
|
#wget -N http://springdale.math.ias.edu/data/springdale/7/i386/os/images/pxeboot/{initrd.img,upgrade.img,vmlinuz} --directory-prefix="${REPOS_RACINE}"/"$DIST"/$ARCH/os/images/pxeboot/
|
|
#
|
|
#reposync --config="${YUM_CONF}"/springdale-7.repo --arch=$ARCH --norepopath --repoid=updates --tempcache --download_path="${REPOS_RACINE}"/"$DIST"/$ARCH/updates/os/Packages/
|
|
#createrepo "${REPOS_RACINE}"/$ARCH/updates/os/
|
|
#reposync --config="${YUM_CONF}"/springdale-7.repo --arch=$ARCH --norepopath --repoid=addons-updates --tempcache --download_path="${DIST}"/$ARCH/updates/Addons/Packages/
|
|
#createrepo "${REPOS_RACINE}"/$ARCH/updates/Addons
|
|
|
|
|
|
####################################################################
|
|
# CentOS
|
|
#
|
|
|
|
for ARCH in i686 x86_64 armv7hl armv5tel aarch64; do
|
|
ARCH=${ARCH/armv6l/armv5tel}
|
|
case $ARCH in
|
|
x86_64)
|
|
DIST=CentOS7;;
|
|
REPARCH=x86_64;;
|
|
i686)
|
|
DIST=CentOS7;;
|
|
REPARCH=${ARCH/i686/i386};;
|
|
aarch64)
|
|
DIST=CentOS7;;
|
|
REPARCH=aarch64;;
|
|
armv7hl)
|
|
DIST=CentOS7;;
|
|
REPARCH=armhfp;;
|
|
#REPARCH=armv7hl;;
|
|
armv5tel|armv6l)
|
|
DIST=RedSleeve7;;
|
|
REPARCH=armv5tel;;
|
|
esac
|
|
case $ARCH in
|
|
x86_64)
|
|
BASE_MIRROR=http://mirror.centos.org
|
|
MIRROR="${BASE_MIRROR}"/centos-7/7;;
|
|
i686|aarch64|armv7hl)
|
|
BASE_MIRROR=http://mirror.centos.org
|
|
MIRROR="${BASE_MIRROR}"/altarch/7;;
|
|
armv5tel|armv6l)
|
|
BASE_MIRROR=
|
|
MIRROR=;;
|
|
esac
|
|
case $ARCH in
|
|
x86_64|i686|aarch64)
|
|
# mise en place du boot réseaux
|
|
for REP in "${REPOS_RACINE}"/"$DIST"/$REPARCH/os/{LiveOS,images/pxeboot}; do
|
|
if [ ! -d "$REP" ]; then
|
|
mkdir -p "$REP"
|
|
fi
|
|
done
|
|
wget -N "$MIRROR"/os/$REPARCH/LiveOS/squashfs.img --directory-prefix="${REPOS_RACINE}"/"$DIST"/$REPARCH/os/LiveOS/
|
|
wget -N "$MIRROR"/os/$REPARCH/images/boot.iso --directory-prefix="${REPOS_RACINE}"/"$DIST"/$REPARCH/os/images/
|
|
wget -N "$MIRROR"/os/$REPARCH/images/pxeboot/{initrd.img,upgrade.img,vmlinuz} --directory-prefix="${REPOS_RACINE}"/"$DIST"/$REPARCH/os/images/pxeboot/
|
|
;;
|
|
armv7hl)
|
|
# récupération des images d'install
|
|
for FICHIER in $(curl -s "$MIRROR"/isos/$REPARCH/ | grep Minimal | egrep '<a href=.*\.(txt|xz)' | sed 's|.*">\(.*\)</a>.*|\1|'); do
|
|
wget -N "$MIRROR"/isos/$REPARCH/$FICHIER --directory-prefix="${REPOS_RACINE}"/"$DIST"/$ARCH/isos/
|
|
done
|
|
;;
|
|
armv5tel|armv6l)
|
|
LASTIMG="$(curl -s http://ftp.redsleeve.org/pub/el7-devel/el7/rootfs/ | grep raspi-redsleeve7 | sed 's|.*href="\(raspi-redsleeve7[^"]*\)".*|\1|' | grep img.xz$ | sort | tail -n1)"
|
|
wget -N http://ftp.redsleeve.org/pub/el7-devel/el7/rootfs/"$LASTIMG" --directory-prefix="${REPOS_RACINE}"/"$DIST"/$ARCH/isos/
|
|
;;
|
|
esac
|
|
|
|
for REPO in $(grep '^\[' "${YUM_CONF}"/$DIST-$ARCH.repo | sed 's/\[repo-\(.*\)\]/\1/' | fgrep -v '[main]'); do
|
|
if [ $(sed -n '/\[repo-'$REPO'\]/,/^$/ p' "${YUM_CONF}"/$DIST-$ARCH.repo | egrep -c 'enabled[\s]*=[\s]*0') -eq 0 ]; then
|
|
if [ ! -d "${REPOS_RACINE}"/"$DIST"/$REPARCH/${REPO/base/os} ]; then
|
|
mkdir "${REPOS_RACINE}"/"$DIST"/$REPARCH/${REPO/base/os}
|
|
fi
|
|
BASEURL="$(sed -n '/\[repo-'$REPO'\]/,/^$/ p' "${YUM_CONF}"/$DIST-$ARCH.repo | egrep ^baseurl= | cut -d= -f2)"
|
|
echo "Synchro du dépôt $REPO"
|
|
# --only-missing
|
|
#echo "open $BASEURL && mirror --continue --delete Packages ${REPOS_RACINE}/$DIST/$REPARCH/${REPO/base/os}/ && exit" | lftp
|
|
echo "open $BASEURL && mirror --parallel=20 --continue --delete . ${REPOS_RACINE}/$DIST/$REPARCH/${REPO/base/os}/ && exit" | lftp &
|
|
#reposync --config="${YUM_CONF}"/"$DIST"-"$ARCH".repo --arch=$ARCH --norepopath --repoid=repo-$REPO --tempcache --delete --download_path="${REPOS_RACINE}"/"$DIST"/$REPARCH/${REPO/base/os}/ --cachedir=/dev/shm/yum
|
|
#createrepo "${REPOS_RACINE}"/"$DIST"/$REPARCH/${REPO/base/os}/
|
|
fi
|
|
done
|
|
done
|
|
|
|
#for i in base updates epel; do
|
|
# reposync --config="${YUM_CONF}"/"$DIST"-"$ARCH"-"$REPO".repo --arch=$ARCH --repoid=repo-$i --tempcache --download_path="${REPOS_RACINE}"/"$DIST"/$ARCH/${i/base/os}/Packages/
|
|
# createrepo "${REPOS_RACINE}"/"$DIST"/$ARCH/${i/base/os}/
|
|
#done
|
|
|
|
rm -f /var/run/update_mirror
|
|
echo "End: $(date)"
|