update comments
This commit is contained in:
parent
ebca863369
commit
c78fdd4680
62
haproxy.sh
62
haproxy.sh
|
|
@ -1,12 +1,15 @@
|
||||||
#! /bin/bash
|
#!/usr/bin/env bash
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
#
|
||||||
export PATH
|
# System Required: CentOS, Debian, Ubuntu
|
||||||
#=================================================================#
|
#
|
||||||
# System Required: CentOS, Debian, Ubuntu #
|
# Description: Install haproxy for Shadowsocks server
|
||||||
# Description: Install haproxy for Shadowsocks server #
|
#
|
||||||
# Author: Teddysun <i@teddysun.com> #
|
# Author: Teddysun <i@teddysun.com>
|
||||||
# Intro: https://shadowsocks.be/10.html #
|
#
|
||||||
#=================================================================#
|
# Intro: https://shadowsocks.be/10.html
|
||||||
|
#
|
||||||
|
|
||||||
|
[[ $EUID -ne 0 ]] && echo "Error: This script must be run as root!" && exit 1
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo
|
echo
|
||||||
|
|
@ -17,13 +20,6 @@ echo "# Author: Teddysun <i@teddysun.com> #"
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
rootness(){
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
echo "Error:This script must be run as root!" 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
checkos(){
|
checkos(){
|
||||||
if [[ -f /etc/redhat-release ]]; then
|
if [[ -f /etc/redhat-release ]]; then
|
||||||
OS=CentOS
|
OS=CentOS
|
||||||
|
|
@ -73,12 +69,22 @@ get_ip(){
|
||||||
[ ! -z ${IP} ] && echo ${IP} || echo
|
[ ! -z ${IP} ] && echo ${IP} || echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_char(){
|
||||||
|
SAVEDSTTY=`stty -g`
|
||||||
|
stty -echo
|
||||||
|
stty cbreak
|
||||||
|
dd if=/dev/tty bs=1 count=1 2> /dev/null
|
||||||
|
stty -raw
|
||||||
|
stty echo
|
||||||
|
stty $SAVEDSTTY
|
||||||
|
}
|
||||||
|
|
||||||
# Pre-installation settings
|
# Pre-installation settings
|
||||||
function pre_install(){
|
pre_install(){
|
||||||
# Set haproxy config port
|
# Set haproxy config port
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
echo -e "Please input port for haproxy & shadowsocks [1-65535]"
|
echo -e "Please enter a port for haproxy and Shadowsocks server [1-65535]"
|
||||||
read -p "(Default port: 8989):" haproxyport
|
read -p "(Default port: 8989):" haproxyport
|
||||||
[ -z "${haproxyport}" ] && haproxyport="8989"
|
[ -z "${haproxyport}" ] && haproxyport="8989"
|
||||||
expr ${haproxyport} + 0 &>/dev/null
|
expr ${haproxyport} + 0 &>/dev/null
|
||||||
|
|
@ -91,17 +97,17 @@ function pre_install(){
|
||||||
echo
|
echo
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "Input error! Please input correct number."
|
echo "Enter error! Please enter a correct number."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Input error! Please input correct number."
|
echo "Enter error! Please enter a correct number."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set haproxy config IPv4 address
|
# Set haproxy config IPv4 address
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
echo -e "Please input your shadowsocks IPv4 address for haproxy"
|
echo -e "Please enter your Shadowsocks server's IPv4 address for haproxy"
|
||||||
read -p "(IPv4 is):" haproxyip
|
read -p "(IPv4 is):" haproxyip
|
||||||
valid_ip ${haproxyip}
|
valid_ip ${haproxyip}
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
|
@ -112,19 +118,10 @@ function pre_install(){
|
||||||
echo
|
echo
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "Input error! Please input correct IPv4 address."
|
echo "Enter error! Please enter correct IPv4 address."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
get_char(){
|
|
||||||
SAVEDSTTY=`stty -g`
|
|
||||||
stty -echo
|
|
||||||
stty cbreak
|
|
||||||
dd if=/dev/tty bs=1 count=1 2> /dev/null
|
|
||||||
stty -raw
|
|
||||||
stty echo
|
|
||||||
stty $SAVEDSTTY
|
|
||||||
}
|
|
||||||
echo
|
echo
|
||||||
echo "Press any key to start...or Press Ctrl+C to cancel"
|
echo "Press any key to start...or Press Ctrl+C to cancel"
|
||||||
char=`get_char`
|
char=`get_char`
|
||||||
|
|
@ -226,11 +223,10 @@ install(){
|
||||||
# Install haproxy
|
# Install haproxy
|
||||||
install_haproxy(){
|
install_haproxy(){
|
||||||
checkos
|
checkos
|
||||||
rootness
|
|
||||||
disable_selinux
|
disable_selinux
|
||||||
pre_install
|
pre_install
|
||||||
install
|
install
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialization step
|
# Initialization step
|
||||||
install_haproxy 2>&1 | tee /root/haproxy_for_shadowsocks.log
|
install_haproxy 2>&1 | tee ~/haproxy_for_shadowsocks.log
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user