Created
November 14, 2017 12:24
-
-
Save jsvisa/90cbb854a0ada7b0d5f7ed35b1fd69ca to your computer and use it in GitHub Desktop.
load-ipvs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Delweng Zheng <[email protected]> | |
if $(lsmod | grep -q "ip_vs"); then | |
exit 0 | |
fi | |
if [ -f /etc/redhat-release ]; then | |
RELEASE="centos" | |
elif cat /etc/issue | grep -Eqi "debian"; then | |
RELEASE="debian" | |
elif cat /etc/issue | grep -Eqi "ubuntu"; then | |
RELEASE="ubuntu" | |
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then | |
RELEASE="centos" | |
elif cat /proc/version | grep -Eqi "debian"; then | |
RELEASE="debian" | |
elif cat /proc/version | grep -Eqi "ubuntu"; then | |
RELEASE="ubuntu" | |
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then | |
RELEASE="centos" | |
fi | |
if [[ "${RELEASE}" == "centos" ]]; then | |
cat << EOF > /etc/sysconfig/modules/ipvs.modules | |
#!/bin/sh | |
##LOAD_IP_VS | |
modprobe ip_vs | |
modprobe ip_vs_wrr | |
modprobe ip_vs_rr | |
modprobe ip_vs_dh | |
modprobe ip_vs_sh | |
EOF | |
chmod +x /etc/sysconfig/modules/ipvs.modules | |
elif [[ "${RELEASE}" == "ubuntu" ]]; then | |
sed -i '/ip_vs/Id' /etc/modules | |
cat << EOF > /etc/modules | |
##LOAD_IP_VS | |
modprobe ip_vs | |
modprobe ip_vs_wrr | |
modprobe ip_vs_rr | |
modprobe ip_vs_dh | |
modprobe ip_vs_sh | |
EOF | |
else | |
echo "Not supported release: ${RELEASE}, by now only support centos|ubuntu" | |
exit 1 | |
fi | |
modprobe ip_vs | |
modprobe ip_vs_wrr | |
modprobe ip_vs_rr | |
modprobe ip_vs_dh | |
modprobe ip_vs_sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment