Skip to content

Instantly share code, notes, and snippets.

@nutrino
Last active September 11, 2024 09:28
Show Gist options
  • Select an option

  • Save nutrino/a5db54524bda763f113705ebc657b3db to your computer and use it in GitHub Desktop.

Select an option

Save nutrino/a5db54524bda763f113705ebc657b3db to your computer and use it in GitHub Desktop.
RHEL/CentOS 7 Offline Download & Install Script
#!/bin/bashn
if [ -z "$1" ]; then
echo "sudo yumdown.sh [packageName]"
exit 1
fi
if [ "$EUID" -ne 0 ]
then echo "Please run as root (sudo yumdown.sh [packageName])"
exit
fi
set -x #echo on
PKG=$1 # NAME OF THE PACKAGE TO INSTALL ON OFFLINE MACHINE
rm -rf /tmp/$PKG
#rm -rf /tmp/$PKG-installroot
mkdir /tmp/$PKG
#mkdir /tmp/$PKG-installroot
#yum install --downloadonly --installroot=/tmp/$PKG-installroot --releasever=7 --downloaddir=/tmp/$PKG $PKG
repotrack $PKG -p /tmp/$PKG
createrepo --database /tmp/$PKG
#rm -rf /tmp/$PKG-installroot
tar -cvzf $PKG.tar.gz /tmp/$PKG
rm -rf /tmp/$PKG
@nutrino
Copy link
Author

nutrino commented Apr 27, 2020

sudo yumoffline.sh [PackageName]


#!/bin/bash

if [ -z "$1" ]; then
   echo "sudo yumoffline.sh [packageName]"
   exit 1
fi

if [ "$EUID" -ne 0 ]
  then echo "Please run as root (sudo yumoffline.sh [packageName])"
  exit
fi

set -x #echo on

PKG=$1 # NAME OF THE PACKAGE
echo "[offline-$PKG]
name=CentOS-\$releasever - $PKG
baseurl=file:///tmp/$PKG
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" >  /etc/yum.repos.d/offline-$PKG.repo

rm -rf /tmp/$PKG

# install package offline:
tar -C / -xvzf $PKG.tar.gz
yum repolist all --disablerepo=\* --enablerepo=offline-$PKG
yum --disablerepo=\* --enablerepo=offline-$PKG install --nogpgcheck $PKG


@nutrino
Copy link
Author

nutrino commented May 18, 2020

Try "yum install [package guess name]" to find out which packages are used actually.

@nutrino
Copy link
Author

nutrino commented Nov 23, 2020

GCC Debug Support

[ONLINE]
./yumdown.sh binutils-dev
debuginfo-install --downloadonly --downloaddir=./download glibc libgcc libstdc++

[OFFLINE]
sudo ./yumoffline.sh binutils-dev
sudo yum --disablerepo=* localinstall *.rpm

@nutrino
Copy link
Author

nutrino commented May 11, 2021

IF yumdown.sh FAILS....

sudo yum clean all

ls /etc/yum.repos.d

@nutrino
Copy link
Author

nutrino commented Sep 9, 2021

sudo yum-config-manager --disable \*
sudo yum-config-manager --enable offline-libsmbclient
sudo yum-config-manager --enable offline-samba
sudo yum-config-manager --enable offline-samba-libs
sudo yum install samba

@nutrino
Copy link
Author

nutrino commented Sep 11, 2024

echo 7.9.2009 > /etc/yum/vars/releasever

/etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment