Skip to content

Instantly share code, notes, and snippets.

@imyelo
Last active April 21, 2019 21:18
Show Gist options
  • Save imyelo/2f7102907c763fc6213a5ed040b82170 to your computer and use it in GitHub Desktop.
Save imyelo/2f7102907c763fc6213a5ed040b82170 to your computer and use it in GitHub Desktop.
setup shadowsocks server
#!/bin/sh
## # Howto
## 1. write /etc/shadowsocks.json
## 2. exec the setup.sh
##
## ```sh
## curl https://gist.githubusercontent.com/imyelo/2f7102907c763fc6213a5ed040b82170/raw/setup.sh | sh
## ```
##
apt install -y python-pip python-setuptools
pip install --upgrade pip
pip install shadowsocks
## get shadowsocks.sh
curl https://gist.githubusercontent.com/imyelo/2f7102907c763fc6213a5ed040b82170/raw/shadowsocks.sh > /etc/init.d/shadowsocks
chmod +x /etc/init.d/shadowsocks
update-rc.d shadowsocks defaults
#!/bin/sh
### BEGIN INIT INFO
# Provides: shadowsocks
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start shadowsocks
# Description: start shadowsocks
### END INIT INFO
## fork from http://blog.xavierskip.com/2015-02-02-shadowsocks-init/
start(){
ssserver -c /etc/shadowsocks.json -d start
}
stop(){
ssserver -c /etc/shadowsocks.json -d stop
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
stop
start
;;
*)
echo "Usage: $0 {start|reload|stop}"
exit 1
;;
esac
@imyelo
Copy link
Author

imyelo commented Apr 21, 2019

Troubleshooting

  1. cannot import name main

    Trouble: Get error while pip install shadowsocks:

    Traceback (most recent call last):
      File "/usr/bin/pip", line 9, in <module>
        from pip import main
    ImportError: cannot import name main
    

    Fix up:

    1. Modify /usr/bin/pip:

      - from pip import main
      + from pip import __main__
        if __name__ == '__main__':
      -     sys.exit(main())
      +    sys.exit(__main__._main())
    2. That's it! Try again then.

    See https://stackoverflow.com/a/49900741 for details.

  2. undefined symbol: EVP_CIPHER_CTX_cleanup

    Trouble: Get error while ssserver -c /etc/shadowsocks.json -d start

    AttributeError: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
    

    Fix up:

    1. vi /usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py
    2. Type :%s/cleanup/reset/g -> enter (replacing EVP_CIPHER_CTX_cleanup to EVP_CIPHER_CTX_reset)
    3. :wq -> enter. (save file)

    See https://blog.csdn.net/blackfrog_unique/article/details/60320737 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment