Add IPv6 support if IPv6 is exist
This commit is contained in:
parent
a9c0a5dea0
commit
e3c1c63fd6
|
|
@ -22,10 +22,10 @@ rootness(){
|
|||
|
||||
# Disable selinux
|
||||
disable_selinux(){
|
||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||
setenforce 0
|
||||
fi
|
||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||
setenforce 0
|
||||
fi
|
||||
}
|
||||
|
||||
get_ip(){
|
||||
|
|
@ -36,13 +36,7 @@ get_ip(){
|
|||
}
|
||||
|
||||
get_latest_version(){
|
||||
check_installed "curl"
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "curl command not found, try to install it"
|
||||
apt-get -y update
|
||||
apt-get -y --no-install-recommends install curl
|
||||
fi
|
||||
ver=$(curl -s https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
ver=$(wget -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
[ -z ${ver} ] && echo "Error: Get shadowsocks-libev latest version failed" && exit 1
|
||||
shadowsocks_libev_ver="shadowsocks-libev-$(echo ${ver} | sed -e 's/^[a-zA-Z]//g')"
|
||||
download_link="https://github.com/shadowsocks/shadowsocks-libev/archive/${ver}.tar.gz"
|
||||
|
|
@ -208,12 +202,17 @@ download_files(){
|
|||
|
||||
# Config shadowsocks
|
||||
config_shadowsocks(){
|
||||
local server_value="\"0.0.0.0\""
|
||||
if get_ipv6; then
|
||||
server_value="[\"[::0]\",\"0.0.0.0\"]"
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/shadowsocks-libev ]; then
|
||||
mkdir -p /etc/shadowsocks-libev
|
||||
fi
|
||||
cat > /etc/shadowsocks-libev/config.json<<-EOF
|
||||
{
|
||||
"server":"0.0.0.0",
|
||||
"server":${server_value},
|
||||
"server_port":${shadowsocksport},
|
||||
"local_address":"127.0.0.1",
|
||||
"local_port":1080,
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ rootness(){
|
|||
|
||||
# Disable selinux
|
||||
disable_selinux(){
|
||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||
setenforce 0
|
||||
fi
|
||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||
setenforce 0
|
||||
fi
|
||||
}
|
||||
|
||||
get_ip(){
|
||||
|
|
@ -35,13 +35,17 @@ get_ip(){
|
|||
[ ! -z ${IP} ] && echo ${IP} || echo
|
||||
}
|
||||
|
||||
get_latest_version(){
|
||||
check_installed "curl"
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "curl command not found, try to install it"
|
||||
yum -y install curl
|
||||
get_ipv6(){
|
||||
local ipv6=$(wget -qO- -t1 -T2 ipv6.icanhazip.com)
|
||||
if [ -z ${ipv6} ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
ver=$(curl -s https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
}
|
||||
|
||||
get_latest_version(){
|
||||
ver=$(wget -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
[ -z ${ver} ] && echo "Error: Get shadowsocks-libev latest version failed" && exit 1
|
||||
shadowsocks_libev_ver="shadowsocks-libev-$(echo ${ver} | sed -e 's/^[a-zA-Z]//g')"
|
||||
download_link="https://github.com/shadowsocks/shadowsocks-libev/archive/${ver}.tar.gz"
|
||||
|
|
@ -211,7 +215,7 @@ pre_install(){
|
|||
echo "Press any key to start...or press Ctrl+C to cancel"
|
||||
char=`get_char`
|
||||
#Install necessary dependencies
|
||||
yum install -y unzip autoconf automake make zlib-devel curl-devel libtool libevent xmlto asciidoc pcre pcre-devel openssl-devel gcc perl perl-devel cpio expat-devel gettext-devel
|
||||
yum install -y unzip autoconf automake make zlib-devel libtool libevent xmlto asciidoc pcre pcre-devel openssl-devel gcc perl perl-devel cpio expat-devel gettext-devel
|
||||
echo
|
||||
cd ${cur_dir}
|
||||
}
|
||||
|
|
@ -236,12 +240,17 @@ download_files(){
|
|||
|
||||
# Config shadowsocks
|
||||
config_shadowsocks(){
|
||||
local server_value="\"0.0.0.0\""
|
||||
if get_ipv6; then
|
||||
server_value="[\"[::0]\",\"0.0.0.0\"]"
|
||||
fi
|
||||
|
||||
if [ ! -d /etc/shadowsocks-libev ]; then
|
||||
mkdir -p /etc/shadowsocks-libev
|
||||
fi
|
||||
cat > /etc/shadowsocks-libev/config.json<<-EOF
|
||||
{
|
||||
"server":"0.0.0.0",
|
||||
"server":${server_value},
|
||||
"server_port":${shadowsocksport},
|
||||
"local_address":"127.0.0.1",
|
||||
"local_port":1080,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user