Skip to content

Instantly share code, notes, and snippets.

@alainpham
Created October 1, 2019 08:20
Show Gist options
  • Select an option

  • Save alainpham/bfb06c2761293929e24ddc1b2938bdc3 to your computer and use it in GitHub Desktop.

Select an option

Save alainpham/bfb06c2761293929e24ddc1b2938bdc3 to your computer and use it in GitHub Desktop.
RepoSync
#!/bin/bash
DATE_SYNCHRO="RHEL7"
subscription-manager repos --enable="rhel-7-server-rpms" \
--enable="rhel-7-server-extras-rpms" \
--enable="rhel-7-server-ose-3.11-rpms" \
--enable="rhel-7-server-ansible-2.6-rpms"
REPO_LIST="rhel-7-server-rpms rhel-7-server-extras-rpms rhel-7-server-ose-3.11-rpms rhel-7-server-ansible-2.6-rpms"
REPO_FOLDER="/rpmrepo/$DATE_SYNCHRO"
REPO_CONF="$REPO_FOLDER/local.repo"
REPO_URL="http://192.168.122.1:9595/$DATE_SYNCHRO"
mkdir -p $REPO_FOLDER
/bin/rm -f $REPO_CONF
cat >>$REPO_CONF<< EOF
# curl $REPO_URL/local.repo -o /etc/yum.repos.d/local.repo
EOF
for REPO in $REPO_LIST
do
echo "Sync of $REPO"
reposync -l -n -d --repoid=$REPO --download_path=$REPO_FOLDER
mkdir -p $REPO_FOLDER/$REPO
cd $REPO_FOLDER/$REPO
createrepo .
# cat >$REPO_FOLDER/$REPO.repo<< EOF
#[$REPO]
#name=$REPO
#baseurl=$REPO_URL/$REPO/
#enabled=1
#gpgcheck=0
#EOF
cat >>$REPO_CONF<< EOF
[$REPO]
name=$REPO
baseurl=$REPO_URL/$REPO/
enabled=1
gpgcheck=0
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment