01 > ȸҰ

 
작성일 : 19-09-28 07:07
systemd service 등록하기
 글쓴이 : 이로직…
조회 : 8,376  

http://wiki.tiprocessors.com/index.php/AM335x_Flash_Image_Builder_User%27s_Guide

I . Lab Steps l

  1. Insert the SD card and boot your board using an NFS file system
  2. Login to the root file system using:
    user name: root
    password:
  3. Change directory to the standard initscript directory/etc/init.d
    cd /etc/init.d
  4. Open a file for editing calledhelloworld.shin the/etc/init.ddirectory.
    vi helloworld.sh
    NOTE:In all of these labs if you are not familiar with vi or would like to use a graphical editor like emacs you can also edit these files on the NFS share you have mounted. For example if using the SDK defaults you can edit the files in the/targetNFS/directory instead.
  5. Add the following lines to the helloworld.sh file
    #!/bin/sh
    echo ""
    echo "Hello from Sitara!!!"
    echo ""
  6. Give the init script executable permissions so that it can be run
    chmod +x helloworld.sh
  7. The init script has been created, but it has not been linked into the list of scripts to run on boot. To do so you will need to create a symlink to the script in the proper run level directory. The default run level is 5 so the symlink will be created there.
    cd /etc/rc5.d
    ln -s ../init.d/helloworld.sh S99helloworld
  8. You can now reboot your board using the following command
    init 6

II . systemd

vi /lib/systemd/system/myinit.service

[Unit]
Description=My init scripts

[Service]
ExecStart=/etc/init.d/myinitscript.sh
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

vi /etc/init.d/myinitscript.sh

#!/bin/sh
echo ""
echo "Hello from Sitara!!!"
echo ""