There are many ways to boot from Debian, and personally feel that editing the/etc/rc.local configuration is the simplest and most effective.
The code is as follows |
Copy Code |
sudo vi/etc/rc.local Add the Software startup command before exit 0. Such as: /usr/local/bin/sslocal-c/etc/shadowsocks.json |
Save the file and reboot the system to take effect
If someone is going to add the service, we can refer to the following method
Add a self-starter service
1. New Script file
Add a script file under/ETC/INIT.D
The code is as follows |
Copy Code |
sudo vi/etc/init.d/aria2c Input content: #!/bin/sh ### BEGIN INIT INFO # PROVIDES:ARIA2 # Required-start: $network $local _fs $remote _fs # Required-stop:: $network $local _fs $remote _fs # Should-start: $all # Should-stop: $all # Default-start:2 3 4 5 # default-stop:0 1 6 # Short-description:aria2-download Manager # Description:aria2-download Manager ### End INIT INFO Name=aria2c User=pi aria2c=/usr/bin/$NAME pidfile=/var/run/$NAME. PID conf=/home/$USER/.aria2/aria2.conf args= "--conf-path=${conf}" Test-f $ARIA 2C | | Exit 0 . /lib/lsb/init-functions Case "$" in Start) log_daemon_msg "Starting aria2c" "ARIA2C" Start-stop-daemon-s-q-b-m-p $PIDFILE-C $USER-a $ARIA 2C-$ARGS Log_end_msg $? ;; Stop) log_daemon_msg "stopping aria2c" "ARIA2C" Start-stop-daemon-k-q-p $PIDFILE Log_end_msg $? ;; Restart|reload|force-reload) Log_daemon_msg "Restarting aria2c" "ARIA2C" Start-stop-daemon-k-R 5-q-P $PIDFILE Start-stop-daemon-s-q-b-m-p $PIDFILE-C $USER-a $ARIA 2C-$ARGS Log_end_msg $? ;; Status Status_of_proc-p $PIDFILE $ARIA 2C aria2c && Exit 0 | | Exit $? ;; *) log_action_msg "Usage:/etc/init.d/aria2c {start|stop|restart|reload|force-reload|status}" Exit 2 ;; Esac Exit 0 |
The above script ### BEGIN init info-### End INIT info is the metadata information that the startup script needs to define and does not define an error
Enable scripting to use the Start-stop-daemon command with the following parameters:
-S,--start start service
-K,--stop stop service
-Q,--quiet silent boot, no output log
-B,--background background boot
-M,--make-pidfile create PID file
-P,--pidfile specifies the PID file
-C,--chuid specify startup user
-A,--startas pathname process path
-R,--retry Timeout|schedule retry count
You need to modify user name to your own
The configuration file is located in the/home/$USER/.aria2/aria2.conf
More parameter meanings can be viewed through the man Start-stop-daemon
code is as follows |
copy code |
Modify Script permissions sudo chmod +x/etc/init.d/aria2c Test script sudo/etc/init.d/aria2c start sudo/etc/init.d/aria2c status sudo/e tc/init.d/aria2c Stop sudo/etc/init.d/aria2c status sudo/etc/init.d/aria2c restart 2. Use the Insserv setting to start automatically Add service sudo insserv/etc/init.d/aria2c #添加服务 sudo insserv-r/etc/init.d/aria2c #删除服务 Restart test sudo reboot sudo/etc/init.d/aria2c status |