#/bin/bash
#通过ftp发布的yum服务器配置
#iso路径:/data/rhel-server-7.2-x86_64-dvd.iso
#yum服务器ip:192.168.110.10
#FTP路径:/var/ftp/yum/rhel7
#
if ! rpm -q vsftpd > /dev/null
then
echo "vsftpd service not found. You need to install and configure it before running this script."
exit 1
fi
if [ ! -d "/var/ftp/yum/rhel7" ]; then
echo "The directory /var/ftp/yum/rhel7 does not exist. Reconfigure your vsftpd service and try again."
exit 1
fi
repoFolder="/mnt/RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64"
mkdir -p $repoFolder
mkdir -p /var/ftp/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
mount -o loop /data/rhel-server-7.2-x86_64-dvd.iso $repoFolder
shopt -s dotglob
echo "Copying files from $repoFolder/ to /var/ftp/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/"
cp -R $repoFolder/* /var/ftp/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
chmod a+rx -R /var/ftp/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
umount $repoFolder
if ! service vsftpd status > /dev/null
then
service vsftpd start
fi
chcon -R -t public_content_t /var/ftp/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
#/bin/bash
#通过http发布的yum配置
#iso路径:/data/rhel-server-7.2-x86_64-dvd.iso
#yum服务器ip:192.168.110.10
#http路径:/var/www/html/yum/rhel7
if ! rpm -q httpd > /dev/null
then
echo "httpd service not found. You need to install and configure it before running this script."
exit 1
fi
if [ ! -d "/var/www/html/yum/rhel7" ]; then
echo "The httpd document root /var/www/html/yum/rhel7 does not exist. Reconfigure your httpd service and try again."
exit 1
fi
repoFolder="/mnt/RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64"
mkdir -p $repoFolder
mkdir -p /var/www/html/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
mount -o loop /data/rhel-server-7.2-x86_64-dvd.iso $repoFolder
shopt -s dotglob
echo "Copying files from $repoFolder/ to /var/www/html/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/"
cp -R $repoFolder/* /var/www/html/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
chmod a+rx -R /var/www/html/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
umount $repoFolder
if ! service httpd status > /dev/null
then
service httpd start
fi
chcon -R -t httpd_sys_content_t /var/www/html/yum/rhel7RHEL7/u2/RedHatEnterpriseLinuxServer/x86_64/
#/bin/bash
#yum本地配置
#iso路径:/data/rhel-server-7.2-x86_64-dvd.iso
#
#
#
currentTimestamp=`date +%y-%m-%d-%H:%M:%S`
yumRepo=/etc/yum.repos.d/localrepo_RHEL7-7.2-iso.repo
yumRepoBackup=${yumRepo}.${currentTimestamp}
repoFolder="/mnt/RHEL7/u2/iso"
mkdir -p $repoFolder
mount -o loop /data/rhel-server-7.2-x86_64-dvd.iso $repoFolder
if [ -f "$yumRepo" ]; then
echo "Backup $yumRepo to $yumRepoBackup"
cp $yumRepo $yumRepoBackup
fi
cat > $yumRepo << EOF
[local-repo-in-iso-by-yum-repo-config-helper]
name=Red Hat Enterprise Linux \$releasever - \$basearch (DVD)
baseurl=file://$repoFolder/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF
chmod a+x $yumRepo
yum clean all
标签:repoFolder,x86,配置,u2,发布,64,var,yum
From: https://blog.51cto.com/u_15703497/6245042