????

Your IP : 3.145.51.233


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

#!/bin/bash
# migrate from normal channel to hybrid channel
#
# Functions

HYBRID_VERSION="3.10.0"
log=/var/log/normal-to-hybrid.log

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

if [ "$(uname -m)" != "x86_64" ]; then
    echo "Hybrid channel is available only for x86_64 machines, cannot switch to the hybrid channel"
    exit 1
fi

if [ ! -x /usr/sbin/cln-channel ] ; then
    echo "/usr/sbin/cln-channel not found, please update rhn-client-tools"
    exit 1
fi

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

if [ ! -f /etc/sysconfig/kernel.pre-hybrid ] ; then
    echo "Backing up /etc/sysconfig/kernel" | tee -a $log
    cp /etc/sysconfig/kernel /etc/sysconfig/kernel.pre-hybrid
fi

echo "Parsing /etc/sysconfig/kernel" | tee -a $log
sed -i  's|DEFAULTKERNEL=kernel.*|DEFAULTKERNEL=kernel|g' /etc/sysconfig/kernel

if [ ! -f /etc/sysconfig/kernel-version.pre-hybrid ] ; then
	echo "Save current kernel version" | tee -a $log
	uname -r  | sed 's/.x86_64$//' > /etc/sysconfig/kernel-version.pre-hybrid
fi

if [ ! -f /etc/sysconfig/acpid-version.pre-hybrid ] ; then
	echo "Save current acpid version" | tee -a $log
	rpm -q acpid > /etc/sysconfig/acpid-version.pre-hybrid
fi

rpm -qa kernel | grep -q "$HYBRID_VERSION"
if [ "$?" -ne "0" ] ; then
	echo "Remove kernel-firmware..." | tee -a $log
	yum -y remove kernel-firmware 2>&1 | tee -a $log
	echo "Upgrading kernel and other stuff..." | tee -a $log
	yum --disableexcludes=all -y install kernel kernel-headers 2>&1 | tee -a $log
	check_exit_code 0
fi

if [ ! -f /etc/yum.repos.d/cloudlinux-hybrid-testing.repo ] ; then
echo "Add hybrid-testing repositories..." | tee -a $log
cat > /etc/yum.repos.d/cloudlinux-hybrid-testing.repo << EOF
#hybrid-testing
[cloudlinux-hybrid-testing]
name=CloudLinux-\$releasever - Hybrid Testing
baseurl=http://repo.cloudlinux.com/cloudlinux/\$releasever\h/updates-testing/\$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CloudLinux
EOF
check_exit_code 0
fi

if [ "$(acpid -v)" \< "acpid-2" ]; then
	echo "Upgrading acpid..." | tee -a $log
	yum --enablerepo=cloudlinux-hybrid-testing -y update acpid  2>&1 | tee -a $log
	check_exit_code 0
fi
echo "Migration to hybrid channel completed" | tee -a $log