Debian system setup software boot self-boot method

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.