Add input port option

This commit is contained in:
Teddysun 2015-07-30 22:38:34 +08:00
parent 33f07a2567
commit 0807c6cf34
4 changed files with 139 additions and 55 deletions

View File

@ -11,11 +11,9 @@ export PATH
clear
echo ""
echo "#############################################################"
echo "# One click Install Shadowsocks(go)"
echo "# Intro: http://teddysun.com/392.html"
echo "#"
echo "# Author: Teddysun <i@teddysun.com>"
echo "#"
echo "# One click Install Shadowsocks-go server #"
echo "# Intro: http://teddysun.com/392.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "#############################################################"
echo ""
@ -84,11 +82,34 @@ function pre_install(){
# Set shadowsocks-go config password
echo "Please input password for shadowsocks-go:"
read -p "(Default password: teddysun.com):" shadowsockspwd
if [ "$shadowsockspwd" = "" ]; then
shadowsockspwd="teddysun.com"
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
echo ""
echo "---------------------------"
echo "password = $shadowsockspwd"
echo "---------------------------"
echo ""
# Set shadowsocks-go config port
while true
do
echo -e "Please input port for shadowsocks-go [1024-65535]:"
read -p "(Default port: 8989):" shadowsocksport
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
expr $shadowsocksport + 0 &>/dev/null
if [ $? -eq 0 ]; then
if [ $shadowsocksport -ge 1024 ] && [ $shadowsocksport -le 65535 ]; then
echo ""
echo "---------------------------"
echo "port = $shadowsocksport"
echo "---------------------------"
echo ""
break
else
echo "Input error! Please input correct numbers."
fi
else
echo "Input error! Please input correct numbers."
fi
echo "password:$shadowsockspwd"
echo "####################################"
done
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
@ -173,7 +194,7 @@ function config_shadowsocks(){
cat > /etc/shadowsocks/config.json<<-EOF
{
"server":"0.0.0.0",
"server_port":8989,
"server_port":${shadowsocksport},
"local_port":1080,
"password":"${shadowsockspwd}",
"method":"aes-256-cfb",
@ -187,13 +208,13 @@ function iptables_set(){
echo "iptables start setting..."
/sbin/service iptables status 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
/etc/init.d/iptables status | grep '8989' | grep 'ACCEPT' >/dev/null 2>&1
/etc/init.d/iptables status | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
if [ $? -ne 0 ]; then
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8989 -j ACCEPT
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart
else
echo "port 8989 has been set up."
echo "port ${shadowsocksport} has been set up."
fi
else
echo "iptables looks like shutdown, please manually set it if necessary."
@ -232,7 +253,7 @@ function install_go(){
echo ""
echo "Congratulations, shadowsocks-go install completed!"
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
echo -e "Your Server Port: \033[41;37m 8989 \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"

View File

@ -11,11 +11,9 @@ export PATH
clear
echo ""
echo "#############################################################"
echo "# Install Shadowsocks(libev) for Debian or Ubuntu (32bit/64bit)"
echo "# Intro: http://teddysun.com/358.html"
echo "#"
echo "# Author: Teddysun <i@teddysun.com>"
echo "#"
echo "# Install Shadowsocks-libev server for Debian or Ubuntu #"
echo "# Intro: http://teddysun.com/358.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "#############################################################"
echo ""
@ -50,11 +48,34 @@ function pre_install(){
#Set shadowsocks-libev config password
echo "Please input password for shadowsocks-libev:"
read -p "(Default password: teddysun.com):" shadowsockspwd
if [ "$shadowsockspwd" = "" ]; then
shadowsockspwd="teddysun.com"
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
echo ""
echo "---------------------------"
echo "password = $shadowsockspwd"
echo "---------------------------"
echo ""
#Set shadowsocks-libev config port
while true
do
echo -e "Please input port for shadowsocks-libev [1024-65535]:"
read -p "(Default port: 8989):" shadowsocksport
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
expr $shadowsocksport + 0 &>/dev/null
if [ $? -eq 0 ]; then
if [ $shadowsocksport -ge 1024 ] && [ $shadowsocksport -le 65535 ]; then
echo ""
echo "---------------------------"
echo "port = $shadowsocksport"
echo "---------------------------"
echo ""
break
else
echo "Input error! Please input correct numbers."
fi
else
echo "Input error! Please input correct numbers."
fi
echo "password:$shadowsockspwd"
echo "####################################"
done
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
@ -116,7 +137,7 @@ function config_shadowsocks(){
cat > /etc/shadowsocks-libev/config.json<<-EOF
{
"server":"0.0.0.0",
"server_port":8989,
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
@ -163,7 +184,7 @@ function install_libev(){
echo ""
echo "Congratulations, shadowsocks-libev install completed!"
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
echo -e "Your Server Port: \033[41;37m 8989 \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Local IP: \033[41;37m 127.0.0.1 \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"

View File

@ -10,11 +10,9 @@ export PATH
clear
echo "#############################################################"
echo "# Install Shadowsocks(libev) for CentOS 6 or 7 (32bit/64bit)"
echo "# Intro: http://teddysun.com/357.html"
echo "#"
echo "# Author: Teddysun <i@teddysun.com>"
echo "#"
echo "# Install Shadowsocks-libev server for CentOS 6 or 7 #"
echo "# Intro: http://teddysun.com/357.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "#############################################################"
echo ""
@ -65,11 +63,34 @@ function pre_install(){
#Set shadowsocks-libev config password
echo "Please input password for shadowsocks-libev:"
read -p "(Default password: teddysun.com):" shadowsockspwd
if [ "$shadowsockspwd" = "" ]; then
shadowsockspwd="teddysun.com"
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
echo ""
echo "---------------------------"
echo "password = $shadowsockspwd"
echo "---------------------------"
echo ""
#Set shadowsocks-libev config port
while true
do
echo -e "Please input port for shadowsocks-libev [1024-65535]:"
read -p "(Default port: 8989):" shadowsocksport
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
expr $shadowsocksport + 0 &>/dev/null
if [ $? -eq 0 ]; then
if [ $shadowsocksport -ge 1024 ] && [ $shadowsocksport -le 65535 ]; then
echo ""
echo "---------------------------"
echo "port = $shadowsocksport"
echo "---------------------------"
echo ""
break
else
echo "Input error! Please input correct numbers."
fi
else
echo "Input error! Please input correct numbers."
fi
echo "password:$shadowsockspwd"
echo "####################################"
done
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
@ -131,7 +152,7 @@ function config_shadowsocks(){
cat > /etc/shadowsocks-libev/config.json<<-EOF
{
"server":"0.0.0.0",
"server_port":8989,
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
@ -146,13 +167,13 @@ function iptables_set(){
echo "iptables start setting..."
/sbin/service iptables status 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
/etc/init.d/iptables status | grep '8989' | grep 'ACCEPT' >/dev/null 2>&1
/etc/init.d/iptables status | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
if [ $? -ne 0 ]; then
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8989 -j ACCEPT
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart
else
echo "port 8989 has been set up."
echo "port ${shadowsocksport} has been set up."
fi
else
echo "iptables looks like shutdown, please manually set it if necessary."
@ -196,7 +217,7 @@ function install(){
echo ""
echo "Congratulations, shadowsocks-libev install completed!"
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
echo -e "Your Server Port: \033[41;37m 8989 \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Local IP: \033[41;37m 127.0.0.1 \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"

View File

@ -11,11 +11,9 @@ export PATH
clear
echo ""
echo "#############################################################"
echo "# One click Install Shadowsocks(Python)"
echo "# Intro: http://teddysun.com/342.html"
echo "#"
echo "# Author: Teddysun <i@teddysun.com>"
echo "#"
echo "# One click Install Shadowsocks-python server #"
echo "# Intro: http://teddysun.com/342.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "#############################################################"
echo ""
@ -77,14 +75,37 @@ function pre_install(){
echo "Not support CentOS 5.x, please change to CentOS 6,7 or Debian or Ubuntu and try again."
exit 1
fi
#Set shadowsocks config password
echo "Please input password for shadowsocks:"
# Set shadowsocks config password
echo "Please input password for shadowsocks-python:"
read -p "(Default password: teddysun.com):" shadowsockspwd
if [ "$shadowsockspwd" = "" ]; then
shadowsockspwd="teddysun.com"
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
echo ""
echo "---------------------------"
echo "password = $shadowsockspwd"
echo "---------------------------"
echo ""
# Set shadowsocks config port
while true
do
echo -e "Please input port for shadowsocks-python [1024-65535]:"
read -p "(Default port: 8989):" shadowsocksport
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
expr $shadowsocksport + 0 &>/dev/null
if [ $? -eq 0 ]; then
if [ $shadowsocksport -ge 1024 ] && [ $shadowsocksport -le 65535 ]; then
echo ""
echo "---------------------------"
echo "port = $shadowsocksport"
echo "---------------------------"
echo ""
break
else
echo "Input error! Please input correct numbers."
fi
else
echo "Input error! Please input correct numbers."
fi
echo "password:$shadowsockspwd"
echo "####################################"
done
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
@ -143,7 +164,7 @@ function config_shadowsocks(){
cat > /etc/shadowsocks.json<<-EOF
{
"server":"0.0.0.0",
"server_port":8989,
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
@ -159,13 +180,13 @@ function iptables_set(){
echo "iptables start setting..."
/sbin/service iptables status 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
/etc/init.d/iptables status | grep '8989' | grep 'ACCEPT' >/dev/null 2>&1
/etc/init.d/iptables status | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
if [ $? -ne 0 ]; then
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8989 -j ACCEPT
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart
else
echo "port 8989 has been set up."
echo "port ${shadowsocksport} has been set up."
fi
else
echo "iptables looks like shutdown, please manually set it if necessary."
@ -206,7 +227,7 @@ function install_ss(){
echo ""
echo "Congratulations, shadowsocks install completed!"
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
echo -e "Your Server Port: \033[41;37m 8989 \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
echo -e "Your Local IP: \033[41;37m 127.0.0.1 \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"