Article From:https://segmentfault.com/q/1010000011112818
Question:

One problem

GoogleSearching for relevant answers is usually about putting scripts./etc/init.dBelow:

I created such a script and put it in/etc/init.d/shadowsocks.shBelow:

#!/bin/sh
sslocal -s server-ip -p server-port -l 1080 -k password -t 600 -m aes-256-cfb

The permissions are set up:

$ chmod +x /etc/init.d/shadowsocks.sh

But when the boot is restarted, the 1080 port is not booted, and the script is not executed. What is the reason? What is the easiest way to execute this command when I have to turn on the machine?

Additional problems

If I put the above commands in/etc/profileBelow:

sslocal -s server-ip -p server-port -l 1080 -k password -t 600 -m aes-256-cfb

The system will remain stuck until it has been logged in. It has been torn for a long time.Ctrl+Alt+F1The command line is logged in to the above command/etc/profileThe following is removed to solve. Can a friend explain the reason?

Answer 0:

Since the startup script is read from the /etc/rcN.d/ folder, in general, this folder is a soft connection to the files in the /etc/init.d/ folder. But even if you write like this, it’s also a problem.So, because it’s not a backstage process

Answer 1:

Simple point, you can write directly to /etc/rc.local
If you want to put it in /etc/init.d, your script is not right. Even if it is right, you must use chkconfig to match it, and Baidu yourself.

Answer 2:

My own solution, in order to better manage the process, I used to do supervisord management, set up autorestart and supervisior services to boot from boot (should be set automatically when the apt-get installation) to achieve this goal

Answer 3:

With shadowsocks-libev, the script comes with SYSTEMd.

localA little change is done at the end.

Here is a sample for you.

[Unit]
Description=Shadowsocks-libev Default Server Service
Documentation=man:shadowsocks-libev(8)
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/default/shadowsocks-libev
LimitNOFILE=32768
ExecStart=/usr/bin/ss-local -c $CONFFILE $DAEMON_ARGS

[Install]
WantedBy=default.target

Leave a Reply

Your email address will not be published. Required fields are marked *