Mini Shell

Direktori : /usr/sbin/
Upload File :
Current File : //usr/sbin/normal-to-hybrid

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

source /etc/normal-hybrid.conf

log=/var/log/normal-to-hybrid.log
ENABLE_BETA_REPO="${ENABLE_BETA_REPO:-0}"
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}"

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

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

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

#
# CLX -> CLXh
#

echo "[cl${VERSION_NUM}h]
name=CloudLinux ${VERSION_NUM}h stable repo
baseurl=${CLXH_REPO}
enabled=1" > ${HYB_REPO_FILE_PATH} | tee -a $log

echo "[cl${VERSION_NUM}h_beta]
name=CloudLinux ${VERSION_NUM}h beta repo
baseurl=${CLXH_BETA_REPO}
enabled=${ENABLE_BETA_REPO}" > ${HYB_REPO_BETA_FILE_PATH} | tee -a $log

yum clean all 2>&1 | tee -a $log

echo "Installing CloudLinux ${VERSION_NUM} hybrid" | tee -a $log

if [ ${VERSION_NUM} -eq 7 -a $kmod -eq 1 ]; then
	yum -y update kmod 2>&1 | tee -a $log
fi

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

	yum -y install kernel kmod-lve 2>&1 | tee -a $log
fi

if [ $kmodlve -eq 1 ]; then
	yum -y install kmod-lve 2>&1 | tee -a $log
fi
if [ ${VERSION_NUM} -eq 7 ]; then
  yum -y install dracut-squash 2>&1 | tee -a $log
fi

Zerion Mini Shell 1.0