PeteManchester / MediaPlayer

61 stars 20 forks source link

Guide needs updating for setting up as service on RPi4 reboot ? #92

Closed landronick closed 4 months ago

landronick commented 3 years ago

Hi, I'm hugely grateful to have found this player and it's installed fine on my RPi4 running Raspberry OS (Buster), but I cannot get it to run automatically at boot. The player runs fine from <sudo /home/pi/mediaplayer/run.sh> but insserv no longer seems available and despite putting that command in various places (rc.local, crontab, system.d/system) following guides elsewhere, it fails during/after boot. I'm sure this is just my own lack of knowledge about exactly how to do it, but perhaps an update in the installation guide for that running as a service section would help others like me?

PeteManchester commented 3 years ago

Thanks....

Sorry the docs are out of date..

Try following these instructions to use systemctl rather than innserv..

Using systemmd

If you are using Buster you can probably skip the first step that details installing systemmd, I would expect that Buster already has it installed.

If that doesn't work, let me know..

I will try and update the docs...

Hope you enjoy using MediaPlayer..

landronick commented 3 years ago

Hi, and thanks for the prompt response. I'd actually already found your Using systemd page and that's helped me make progress. I can confirm that Buster does come with systemd installed. I've still run into a couple of problems: every time I tested with 'systemctl start mediaplayer.service' I got asked for my password. I thought I could get round that by simply running the command with sudo, which seemed to work, and I tried sudo with 'systemctl enable mediaplayer.service' etc, but I then realised that MediaPlayer was not showing up in my controller (BubbleUPnP). The only way I can get it to do that is run the 'sudo /home/pi/mediaplayer/run.sh' command. It's not a big deal as I intend to just leave it running most of the time, but it would be nice to add those make-it-easier tweaks, as well as advance my understanding of linux! Edit: After running the 'run.sh' command, btw, I get a screed in the terminal which all looks fine, last line being: 'INFO: [HttpServer] Started.' But then I don't get the prompt back. I recently learned that typing 'disown' deals with that, but I'm sure there's a better way!

guussie commented 3 years ago

I hope your issue is resolved, but you can try this: (full text here: https://github.com/guussie/PiDS/wiki/06.-Building-the-software)

In Debian Jessie you will use systemd to autostart the mediaplayer service. You do this as follows:

cd cd mediaplayer/scripts/systemd sudo cp mediaplayer.service /etc/systemd/system/ sudo cp run_systemd.sh /home/pi/mediaplayer cd /home/pi/mediaplayer sudo chmod +x run_systemd.sh sudo vi run_systemd.sh :%s/^M//g (to enter ^M, type Ctrl-V, then Ctrl-M)

Save the file by typing:

:wq Edit mediaplayer.service:

sudo nano /etc/systemd/system/mediaplayer.service Make sure the contents looks like this:

[Unit] Description=MediaPlayer Requires=mpd.service After=mpd.service

[Service] Type=forking ExecStart=/home/pi/mediaplayer/run_systemd.sh

[Install] WantedBy=multi-user.target Ctrl-x, y, enter.

Enable the media player service

sudo systemctl enable mediaplayer.service sudo systemctl start mediaplayer.service Now edit the properties. Type:

cd .. sudo nano app.properties