Optimize install function

This commit is contained in:
Teddysun 2014-06-16 21:58:21 +08:00
parent 28d1f84246
commit 263b13a19f
2 changed files with 42 additions and 40 deletions

View File

@ -101,8 +101,7 @@ function config_shadowsocks(){
if [ ! -d /etc/shadowsocks ];then
mkdir /etc/shadowsocks
fi
touch /etc/shadowsocks/config.json
cat >>/etc/shadowsocks/config.json<<-EOF
cat > /etc/shadowsocks/config.json<<-EOF
{
"server":"${IP}",
"server_port":8989,
@ -118,12 +117,13 @@ EOF
# Install
function install(){
# Build and Install shadowsocks-libev
if [ ! -f /usr/local/bin/ss-server ];then
if [ -s /usr/local/bin/ss-server ];then
echo "shadowsocks-libev has been installed!"
exit 0
else
./configure
make && make install
fi
# Run shadowsocks-libev
if [ -s /usr/local/bin/ss-server ]; then
if [ $? -eq 0 ]; then
# Add run on system start up
cat /etc/rc.local | grep 'ss-server' > /dev/null 2>&1
if [ $? -ne 0 ]; then
@ -143,6 +143,7 @@ function install(){
echo "Shadowsocks-libev install failed! Please visit http://teddysun.com/358.html and contact."
exit 1
fi
fi
cd $cur_dir
# Delete shadowsocks-libev floder
rm -rf $cur_dir/shadowsocks-libev-master/

View File

@ -103,8 +103,7 @@ function config_shadowsocks(){
if [ ! -d /etc/shadowsocks ];then
mkdir /etc/shadowsocks
fi
touch /etc/shadowsocks/config.json
cat >>/etc/shadowsocks/config.json<<-EOF
cat > /etc/shadowsocks/config.json<<-EOF
{
"server":"${IP}",
"server_port":8989,
@ -134,12 +133,13 @@ function iptables_set(){
# Install
function install(){
# Build and Install shadowsocks-libev
if [ ! -f /usr/local/bin/ss-server ];then
if [ -s /usr/local/bin/ss-server ];then
echo "shadowsocks-libev has been installed!"
exit 0
else
./configure
make && make install
fi
# Run shadowsocks-libev
if [ -s /usr/local/bin/ss-server ]; then
if [ $? -eq 0 ]; then
cp -f $cur_dir/shadowsocks-libev-master/rpm/SOURCES/etc/init.d/shadowsocks /etc/init.d/
chmod +x /etc/init.d/shadowsocks
# Add run on system start up
@ -157,6 +157,7 @@ function install(){
echo "Shadowsocks-libev install failed! Please visit http://teddysun.com/357.html and contact."
exit 1
fi
fi
cd $cur_dir
# Delete shadowsocks-libev floder
rm -rf $cur_dir/shadowsocks-libev-master/