S
S
SHAKIRA2021-01-12 11:02:37
linux
SHAKIRA, 2021-01-12 11:02:37

How to add my script to Raspbian autoload?

Good morning everyone! I have a script, and I wrote a sh script for it.

If I start it manually, then everything works, but if I write it to rc.local, it does not start on reboot.

Script content

#!/bin/bash
/home/pi/zmp/zmp-linux-arm7 --host 192.168.88.99 --best "http://immo.date/ero.m3u"

It works great.

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

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi

/home/pi/zmp/zmp.sh  &
exit 0


Poke the teapot with your nose what's wrong. Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Aleksandrov, 2021-01-12
@jamakasi666

First put zmp in opt as recommended.
Next, learn systemd.
Create file /etc/systemd/system/zmp-tv.service
With content:

[Unit]
Description=ZMediaProxy tv
After=network.target

[Service]
Type=simple
NonBlocking=true
WorkingDirectory=/opt
ExecStart=/opt/zmp-linux-arm7 --host "192.168.88.99" --best http://immo.date/ero.m3u
ExecStop=/usr/bin/killall -w zmp-linux-arm7
Restart=on-failure
RestartSec=10s
TimeoutSec=120s

[Install]
WantedBy=multi-user.target

Then update
systemctl daemon-reload
Add autostart
systemctl enable zmp-tv.service
Run
systemctl start zmp-tv.service
View
systemctl status zmp-tv.service
View journalctl logs
-eu zmp-tv.service

A
AVKor, 2021-01-12
@AVKor

Here: immo.date cannot be reached at the time of launch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question