????

Your IP : 18.224.44.186


Current Path : /proc/324102/root/usr/sbin/
Upload File :
Current File : //proc/324102/root/usr/sbin/hybrid-to-normal

#!/bin/bash
# migrate from normal channel to hybrid channel
#
# Functions
HYBRID_VERSION="3.10.0"
log=/var/log/hybrid-to-normal.log

check_exit_code()   { if [ $? -ne $1 ]; then echo "Error performing last operation. Exiting."; exit 1; fi; }

/usr/sbin/rhn-channel -l | grep -q "hybrid"
if [ "$?" -eq "0" ] ; then
	echo "Switching to normal channel..." | tee -a $log
	/usr/sbin/cln-channel normal 2>&1 | tee -a $log
	check_exit_code 0
fi

if [ -f /etc/yum.repos.d/cloudlinux-hybrid-testing.repo ] ; then
	echo "Remove hybrid-testing repositries..." | tee -a $log
	rm /etc/yum.repos.d/cloudlinux-hybrid-testing.repo
	check_exit_code 0
fi

if [ "$(acpid -v)" \> "acpid-2" ]; then
	echo "Recovery acpid for normal version..." | tee -a $log
	yum -y downgrade $(cat /etc/sysconfig/acpid-version.pre-hybrid) 2>&1 | tee -a $log
	check_exit_code 0
fi

rpm --quiet -q linux-firmware
if [ "$?" -eq "0" ] ; then
	echo "Removing linux-firmware packages..." | tee -a $log
	yum -y remove linux-firmware 2>&1 | tee -a $log
	check_exit_code 0
fi

rpm --quiet -q kernel-firmware
if [ "$?" -ne "0" ] ; then
	echo "Recovering kernel-firmware and 'normal' kernel packages..." | tee -a $log
	yum --disableexcludes=all -y install kernel-firmware-$(cat /etc/sysconfig/kernel-version.pre-hybrid) 2>&1 | tee -a $log
	check_exit_code 0
        # install original kernel, because client might have removed it after hybridization
	yum --disableexcludes=all -y install kernel-$(cat /etc/sysconfig/kernel-version.pre-hybrid) 2>&1 | tee -a $log
	check_exit_code 0
fi

listpkg=$(rpm -qa kernel* kmod* | grep "$HYBRID_VERSION")
if [ "$?" -eq "0" ] ; then
	echo "Remove ${listpkg}..." | tee -a $log
	rpm --nodeps -e $listpkg
	check_exit_code 0
fi

if [ -f /etc/sysconfig/kernel-version.pre-hybrid ] ; then
	echo "Remove /etc/sysconfig/kernel-version.pre-hybrid..." | tee -a $log
	rm /etc/sysconfig/kernel-version.pre-hybrid
	check_exit_code 0
fi

. /etc/sysconfig/kernel

echo "Migration to normal channel completed" | tee -a "${log}"