Mini Shell

Direktori : /proc/thread-self/root/usr/sbin/
Upload File :
Current File : //proc/thread-self/root/usr/sbin/hybrid-to-normal

#!/usr/bin/bash
# migrate from hybrid channel to normal channel
#
log=/var/log/hybrid-to-normal.log

source /etc/normal-hybrid.conf

HYB_REPO_FILE_BASE="$(basename ${HYB_REPO_FILE})"
HYB_REPO_BETA_FILE_BASE="$(basename ${HYB_REPO_BETA_FILE})"
if [[ $HYB_REPO_FILE_BASE == *"*"* ]] || [[ $HYB_REPO_FILE_BASE == *"?"* ]] || [[ $HYB_REPO_FILE_BASE == *"["* ]] || [[ $HYB_REPO_FILE_BASE == *"]"* ]] ; then
        echo "Error: HYB_REPO_FILE contains wildcard characters"
	exit 1
fi
if [[ $HYB_REPO_BETA_FILE_BASE == *"*"* ]] || [[ $HYB_REPO_BETA_FILE_BASE == *"?"* ]] || [[ $HYB_REPO_BETA_FILE_BASE == *"["* ]] || [[ $HYB_REPO_BETA_FILE_BASE == *"]"* ]] ; then
        echo "Error: HYB_REPO_BETA_FILE contains wildcard characters"
	exit 1
fi

HYB_REPO_FILE_PATH="/etc/yum.repos.d/${HYB_REPO_FILE_BASE}"
HYB_REPO_BETA_FILE_PATH="/etc/yum.repos.d/${HYB_REPO_BETA_FILE_BASE}"

yum list installed kernel-*el${VERSION_NUM}h* &> /dev/null
kern=$?
yum list installed kmod-lve &> /dev/null
kmodlve=$?

if [ $kern -eq 1 -a $kmodlve -eq 1 ]; then
    echo "CloudLinux ${VERSION_NUM} Hybrid has been uninstalled already"
    exit 0
fi

if [ -f "${HYB_REPO_FILE_PATH}" ] || [ -f "${HYB_REPO_BETA_FILE_PATH}" ] ; then
	echo "Renaming CloudLinux ${VERSION_NUM} hybrid repositories..." | tee -a $log
	sed -i 's/enabled=1/enabled=0/g' "${HYB_REPO_FILE_PATH}"
	sed -i 's/enabled=1/enabled=0/g' "${HYB_REPO_BETA_FILE_PATH}"
	mv "${HYB_REPO_FILE_PATH}" "${HYB_REPO_FILE_PATH}".backup
	mv "${HYB_REPO_BETA_FILE_PATH}" "${HYB_REPO_BETA_FILE_PATH}".backup
	yum clean all 2>&1 | tee -a $log
fi

if [ $kern -eq 0 ]; then
	yum -y downgrade kernel-"$(cat /etc/sysconfig/kernel-version.pre-hybrid)" 2>&1 | tee -a $log
fi

rpm --nodeps -ev `rpm -qa kernel kernel-* kmod-lve | grep ${VERSION_NUM}h` 2>&1 | tee -a $log

yum list installed kmod-*el${VERSION_NUM}h* &> /dev/null
if [ $? -eq 0 ]; then
	yum -y downgrade kmod
fi

if [ ${VERSION_NUM} -eq 7 ]; then
	yum list installed dracut-*el7h* &> /dev/null
	if [ $? -eq 0 ]; then
		rpm --nodeps -ev dracut-squash 2>&1 | tee -a $log
		yum -y downgrade kexec-tools dracut dracut-network dracut-config-rescue
	fi
fi


Zerion Mini Shell 1.0