For example make vlc start and play a video full screen on boot. After working this out here it is:
-
hi, is there an easy way to migrate this to unix stack ? – Hayden Thring Apr 02 '18 at 08:16
-
oh well, i will just copy paste – Hayden Thring Apr 02 '18 at 20:29
-
https://unix.stackexchange.com/questions/435127/autostart-restart-435128#435128 – Hayden Thring Apr 02 '18 at 20:31
1 Answers
You first need the following 2 packages if not already:
apt-get install daemontools daemontools-run
This will install and get running the needed "monitors", Then you need to create the "shortcut" to your program to start/restart automatically:
mkdir /home/user/vlc-daemon /home/user/vlc-daemon/log /home/user/vlc-daemon/log/main
gedit /home/user/vlc-daemon/run
put in this file and save it:
#!/bin/sh
echo starting vlc-d
export DISPLAY=:0 #needed for X program
exec setuidgid user /usr/bin/vlc -f /home/user/Downloads/myvideo.avi
This starts vlc program in fullscreen playing myvideo.avi as user "user" , adapt as needed.
Then, for logging: (add and save)
gedit /home/user/vlc-daemon/log/run
#!/bin/sh
exec setuidgid user multilog t ./main
Make them executable:
chmod 755 /home/user/vlc-daemon/run /home/user vlc-daemon/log/run
Now to install & activate service:
update-service --add /home/user/vlc-daemon
Now your program should be running, and start/restart automatically. for more documentation see: http://cr.yp.to/daemontools.html
If not check log/main folder, and that you can also run /home/user/vlc-daemon/run manually from cli , also the following command can show some errors:
ps -aux | grep readproctitle

- 147
- 16