• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

repo

Create Local Repo in Rocky Linux 8

January 30, 2022

How to create a local repo in Rocky Linux 8.

Install nginx. Enable service.

dnf install nginx
systemctl enable nginx --now
systemctl status nginx

dnf install nginx systemctl enable nginx --now systemctl status nginx

Create repo.

dnf repolist
dnf install createrepo yum-utils
mkdir /usr/share/nginx/html/repos
mkdir -p /usr/share/nginx/html/repos/{baseos,appstream}

dnf repolist dnf install createrepo yum-utils mkdir /usr/share/nginx/html/repos mkdir -p /usr/share/nginx/html/repos/{baseos,appstream}

Sync repos.

dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata
dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata
createrepo /usr/share/nginx/html/repos/baseos/
createrepo /usr/share/nginx/html/repos/appstream/

dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata createrepo /usr/share/nginx/html/repos/baseos/ createrepo /usr/share/nginx/html/repos/appstream/

Create cron to sync repos daily. Create file called /etc/cron.daily/update-localrepos

#!/bin/bash
/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata
/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata
/usr/bin/createrepo /usr/share/nginx/html/repos/baseos/
/usr/bin/createrepo /usr/share/nginx/html/repos/appstream/

#!/bin/bash /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata /usr/bin/createrepo /usr/share/nginx/html/repos/baseos/ /usr/bin/createrepo /usr/share/nginx/html/repos/appstream/

Create a file called /etc/nginx/conf.d/repos.conf.

server {
        listen   80;
        server_name  reposerver.example.com;
        root   /usr/share/nginx/html/repos;
	index index.html; 
	location / {
                autoindex on;
        }
}

server { listen 80; server_name reposerver.example.com; root /usr/share/nginx/html/repos; index index.html; location / { autoindex on; } }

Restart nginx.

systemctl restart nginx

systemctl restart nginx

Configure firewall and SELinux.

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload
getenforce
chcon -Rt httpd_sys_content_t /usr/share/nginx/html/repos/

firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --reload getenforce chcon -Rt httpd_sys_content_t /usr/share/nginx/html/repos/

Move existing repos to /tmp.

mv /etc/yum.repos.d/*.repo /tmp/

mv /etc/yum.repos.d/*.repo /tmp/

Create a new repo called /etc/yum.repos.d/localrepo.repo

[localrepo-base]
name=RockyLinux Base
baseurl=http://reposerver.example.com/baseos/
gpgcheck=0
enabled=1
[localrepo-appstream]
name=RockyLinux Base
baseurl=http://reposerver.example.com/appstream/
gpgcheck=0
enabled=1

[localrepo-base] name=RockyLinux Base baseurl=http://reposerver.example.com/baseos/ gpgcheck=0 enabled=1 [localrepo-appstream] name=RockyLinux Base baseurl=http://reposerver.example.com/appstream/ gpgcheck=0 enabled=1

Clean cache and check repolist.

dnf clean all 
dnf repolist

dnf clean all dnf repolist

Edit /etc/hosts and add reposerver.example.com. Add it to other hosts.

echo "10.10.10.10        reposerver.example.com     reposerver" >> /etc/hosts

echo "10.10.10.10 reposerver.example.com reposerver" >> /etc/hosts

Finally, run yum install against the local repo. Installing lvm in this example.

yum install lvm2

yum install lvm2

Filed Under: Linux Tagged With: create, local, repo, rocky linux 8

Git Clone Multiple Accounts

November 28, 2021

How to clone repositories with multiple Github accounts.

git clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git

git clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git

Filed Under: Linux Tagged With: accounts, clone, git, multiple, repo

Create Local Yum Repo

November 7, 2021

Here’s how to create a local yum repo.

Install Apache.

sudo yum install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd

sudo yum install httpd sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd

Install the repo packages.

sudo yum install createrepo yum-utils

sudo yum install createrepo yum-utils

Create repo directories.

sudo mkdir /var/www/html/{baseos,extras,appstream,epel}

sudo mkdir /var/www/html/{baseos,extras,appstream,epel}

Sync the repos.

sudo yum reposync -p=/var/www/html --repoid=baseos --download-metadata
sudo yum reposync -p=/var/www/html --repoid=extras --download-metadata
sudo yum reposync -p=/var/www/html --repoid=appstream --download-metadata
sudo yum reposync -p=/var/www/html --repoid=epel --download-metadata

sudo yum reposync -p=/var/www/html --repoid=baseos --download-metadata sudo yum reposync -p=/var/www/html --repoid=extras --download-metadata sudo yum reposync -p=/var/www/html --repoid=appstream --download-metadata sudo yum reposync -p=/var/www/html --repoid=epel --download-metadata

Create a new repo.

sudo createrepo /var/www/html/

sudo createrepo /var/www/html/

Setup a local repo.

sudo nano /etc/yum.repos.d/local.repo

sudo nano /etc/yum.repos.d/local.repo

Contents of local.repo.

local-base]
name=Yum Local Base
baseurl=http://10.10.0.20:80/base
enabled=1
gpgcheck=0
[local-extras]
name=Yum Local Extras
baseurl=http://10.10.0.20:80/extras
enabled=1
gpgcheck=0
[local-appstream]
name=Yum Local Appstream
baseurl=http://10.10.0.20:80/appstream
enabled=1
gpgcheck=0
[local-epel]
name=Yum Local Epel
baseurl=http://10.10.0.20:80/epel
enabled=1
gpgcheck=0

local-base] name=Yum Local Base baseurl=http://10.10.0.20:80/base enabled=1 gpgcheck=0 [local-extras] name=Yum Local Extras baseurl=http://10.10.0.20:80/extras enabled=1 gpgcheck=0 [local-appstream] name=Yum Local Appstream baseurl=http://10.10.0.20:80/appstream enabled=1 gpgcheck=0 [local-epel] name=Yum Local Epel baseurl=http://10.10.0.20:80/epel enabled=1 gpgcheck=0

Confirm new repo is in the repolist.

sudo yum repolist

sudo yum repolist

Filed Under: Linux Tagged With: apache, create, repo, yum

Yum Repo Plugins

April 2, 2020

Here’s how to disable plugin in Yum repos.

# check which plugins are enabled
yum repolist
# disable plugins
yum update --disableplugin=product-id,subscription-manager
# check agin
yum repolist

# check which plugins are enabled yum repolist # disable plugins yum update --disableplugin=product-id,subscription-manager # check agin yum repolist

If that doesn’t work, check the individual config files of each plugin.

cd /etc/yum/pluginconf.d/
vim product-id.conf
vim subscription-manager.conf

cd /etc/yum/pluginconf.d/ vim product-id.conf vim subscription-manager.conf

Disable it.

[main]
enable=0

[main] enable=0

Filed Under: Linux Tagged With: plugins, redhat, repo, repolist, yum

Yum Add Repo Manually

August 5, 2019

Add a yum repo manually by adding a configuration file in /etc/yum.repo.d/ directory.

cd /etc/yum.repos.d/
vi newrepo

cd /etc/yum.repos.d/ vi newrepo

Add the following.

[newrepo]
name=New Repo for RHEL/ CentOS $releasever - $basearch
baseurl=http://newrepo.domain.com/centos/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://newrepo.domain.com/RPM-GPG-KEY.txt

[newrepo] name=New Repo for RHEL/ CentOS $releasever - $basearch baseurl=http://newrepo.domain.com/centos/$releasever/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://newrepo.domain.com/RPM-GPG-KEY.txt

You may need to import the key.

rpm --import http://newrepo.domain.com/RPM-GPG-KEY.txt

rpm --import http://newrepo.domain.com/RPM-GPG-KEY.txt

Finally, test the new repo by running the following.

yum update -y
yum install new-package

yum update -y yum install new-package

Filed Under: Cloud Tagged With: 3rd party, add, new, repo, yum

Yum Remove Repo

February 19, 2019

How to remove repos in Yum. Just delete the repo file in /etc/yum.repos.d.

rm /etc/yum.repos.d/repo-name.repo

rm /etc/yum.repos.d/repo-name.repo

Filed Under: Linux Tagged With: redhat, remove, repo, yum

Cloning A GCP Repo

August 3, 2018

Here are the steps on how to clone a Google Cloud Platform (GCP) repository. This is assuming you already installed Google Cloud SDK.

gcloud init
gcloud source repos clone name_of_repo --project=project_name
cd name_of_repo
git commit -a -m "your comment"
git push -u origin master

gcloud init gcloud source repos clone name_of_repo --project=project_name cd name_of_repo git commit -a -m "your comment" git push -u origin master

Filed Under: Cloud Tagged With: gcp, git, repo

  • Home
  • About
  • Archives

Copyright © 2023