Skip to content

Instantly share code, notes, and snippets.

@AtomicVar
Last active November 9, 2018 15:12
Show Gist options
  • Save AtomicVar/1e45023da216d8bc9ab1bcc57f970d24 to your computer and use it in GitHub Desktop.
Save AtomicVar/1e45023da216d8bc9ab1bcc57f970d24 to your computer and use it in GitHub Desktop.
Shadowsocks Python (3.0.0) systemd service script
[Unit]
Description=Shadowsocks Python local client
[Service]
Type=forking
ExecStart=/path/to/sslocal -c /path/to/config.json -d start
ExecReload=/path/to/sslocal -c /path/to/config.json -d restart
ExecStop=/path/to/sslocal -c /path/to/config.json -d stop
[Install]
WantedBy=multi-user.target
@AtomicVar
Copy link
Author

AtomicVar commented Sep 4, 2018

Note

此脚本测试于:

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Manjaro 17.1.12

Shadowsocks版本为Python版(shadowsocks==3.0.0)

Steps

  1. 将此文件放入Ubuntu 16.04 的 /lib/systemd/system 目录下(其他系统类似)。
  2. 运行sudo systemctl daemon-reload 重新加载配置文件使之生效。
  3. 运行 sudo systemctl enable sslocal 使之开机启动。

FAQ

Service failed

若Shadowsocks被安装在了个人目录的site-packages下,则需要在系统的/usr/local/lib/python2.7/dist-packages下为Shadowsocks目录建立符号链接,否则系统以root来运行时将找不到对应版本。

@AtomicVar
Copy link
Author

Shadowsocks-libev 配置文件

[Unit]
Description=Shadowsocks-libev local client

[Service]
Type=forking
ExecStart=/path/to/ss-local -c /path/to/config.json -f /path/to/pidfile
ExecReload=/path/to/ss-local -c /path/to/config.json -f /path/to/pidfile
ExecStop=/path/to/ss-local -c /path/to/config.json -f /path/to/pidfile

[Install]
WantedBy=multi-user.target

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