Skip to content

Boot Auto-start Configuration

Setting up Auto-start Service

Create a Startup Script

Using any text editor, create a new startup script in the /etc/init.d directory. Let's name it your_script_name. Here's a reference example of the script content:

#!/bin/bash

### BEGIN INIT INFO
# Provides:          your_service_name
# Required-Start:    $all
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start your_service_name at boot time
# Description:       Enable service provided by your_service_name
### END INIT INFO

/path/to/your/program &

exit 0

Set Executable Permission for the Startup Script

sudo chmod +x /etc/init.d/your_script_name

Add the Script to System Startup Items Using update-rc.d Command

sudo update-rc.d your_script_name defaults

Enable Auto-start Using systemctl Command

sudo systemctl enable your_script_name

Restart the Development Board to Verify if the Auto-start Service is Running Properly

root@ubuntu:~# systemctl status your_script_name.service 
 your_script_name.service - LSB: Start your_service_name at boot time
    Loaded: loaded (/etc/init.d/your_script_name; generated)
    Active: active (exited) since Wed 2023-04-19 15:01:12 CST; 57s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 2768 ExecStart=/etc/init.d/your_script_name start (code=exited, status=0/SUCCESS)

Adding to rc.local Service

rc.local is a system service used to automatically execute scripts or commands during system startup. This service is automatically called during system boot and executes user-specified scripts or commands after system startup to perform custom configurations or operations.

In earlier Linux distributions, rc.local was the last service to run by default during the system startup process. With the popularization of systemd, rc.local is considered a legacy system service.

This can be achieved by adding startup commands at the end of the sudo vim /etc/rc.local file, for example:

#!/bin/bash -e
#
# rc.local
#re
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Insert what you need

exit 0

OriginMan Boot Auto-start Reserved Interface

In the root directory, there is a shell script called start.sh, which is built-in to automatically run the contents of start.sh whenever the OriginMan power switch is turned on. Users can build upon this for other development needs.

Attention

Do not place code that blocks threads in it, otherwise it will get stuck at a certain node or program and cannot execute the next section of content.

Image1