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

View File

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