[[linux_wiki:rhnreg_fix]]

Rhnreg Fix

General Information

Fix a system that is not registered to Spacewalk and can't be registered because it doesn't have the rhn-setup package and all of its dependencies.

Checklist

  • Distro(s): Enterprise Linux 6/7
  • Other: Spacewalk Server

The Script

fix_rhnreg.sh
#!/bin/bash
 
## Title: fix_rhnreg
## Description: Installs missing packages for rhnreg_ks
## Author: Bill Howe
## Date: 2015-12-30
## Recent Changes: Cleaned up echo formatting 
 
#### CUSTOMIZE HERE #####
#Spacewalk server fqdn
sw_server="my-spacewalk-server.local"
 
#### END OF CUSTOMIZE #####
 
echo "=== Install Missing Packages for rhnreg_ks ==="
echo "This script checks for the existence of rhnreg_ks."
echo "If it does not exist, it will download and install"
echo "missing pacakges from Spacewalk."
 
echo -e "\n=> Checking to see if rhnreg_ks exists..."
if [[ $(which rhnreg_ks) ]];then
	echo "=> rhnreg_ks exists, nothing needs fixing."
	exit 0
else
	echo "=> rhnreg_ks not found! Will attempt to fix."
fi
 
echo -e "\n=> Creating /tmp/rhnreg_rpms for download directory..."
mkdir /tmp/rhnreg_rpms
cd /tmp/rhnreg_rpms
 
echo -e "\n=> Downloading missing packages from Spacewalk..."
 
# Distro version check
major_version=$(awk -F: '{printf "%d", $5}' /etc/system-release-cpe)
 
case $major_version in
	6)
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/libgudev1-147-2.57.el6.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/m2crypto-0.20.2-9.el6.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/pygobject2-2.20.0-5.el6.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/pyOpenSSL-0.10-2.el6.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/python-dmidecode-3.10.13-3.el6_4.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/python-gudev-147.1-4.el6_0.1.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/python-hwdata-1.7.3-1.el6.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/rhn-check-2.2.7-1.el6.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/rhn-client-tools-2.2.7-1.el6.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/rhnlib-2.5.72-1.el6.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/rhnsd-5.0.14-1.el6.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/rhn-setup-2.2.7-1.el6.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el6/yum-rhn-plugin-2.2.7-1.el6.noarch.rpm
	;;	
 
	7)
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/libgudev1-208-11.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/m2crypto-0.21.1-15.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/pygobject2-2.28.6-11.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/pyOpenSSL-0.13.1-3.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/python-dmidecode-3.10.13-11.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/python-gudev-147.2-7.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/python-hwdata-1.7.3-4.el7.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/rhn-check-2.0.2-5.el7.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/rhn-client-tools-2.0.2-5.el7.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/rhnlib-2.5.65-2.el7.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/rhnsd-5.0.13-3.el7.x86_64.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/rhn-setup-2.0.2-5.el7.noarch.rpm
	wget --no-check-certificate https://${sw_server}/pub/rhn-setup-packages/el7/yum-rhn-plugin-2.0.1-4.el7.noarch.rpm
	;;
esac
 
echo -e "\n=> Installing missing packages..."
yum -y install ./*.rpm
 
# Go back to original directory
cd -
 
echo -e "\n=> Cleaning up RPMs..."
rm -rf /tmp/rhnreg_rpms
 
echo -e "\n=> Checking results..."
if [[ $(which rhnreg_ks) ]];then
        echo "=> rhnreg_ks now exists, issue should be fixed!"
        exit 0
else
	echo "=> rhnreg_ks does not exist, something must have gone wrong..."
	exit 1
fi

  • linux_wiki/rhnreg_fix.txt
  • Last modified: 2019/05/26 03:50
  • (external edit)