1

For example make vlc start and play a video full screen on boot. After working this out here it is:

Hayden Thring
  • 242
  • 1
  • 11

1 Answers1

1

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

Hayden Thring
  • 242
  • 1
  • 11
  • Although good security practice is _not_ to put system-level services in directories that unprivileged users have control over. Better practice would be to have a per-user instance of `svscan` running as the unprivileged user to start with; but that is more work and more complex than this. As is handling `DISPLAY` in a robust fashion. – JdeBP Apr 02 '18 at 20:49
  • Well that is the way debian supplies it (svscan)?, One change i think i do need to make is delay app initial startup until later if possible, to allow more time for wifi to come up. Should i edit it and put the daemon outside home ? – Hayden Thring Apr 02 '18 at 20:53
  • The thing to remember is that it is a toolset. You are not limited to just doing only a few things with it, and running an unprivileged `svscan` out of, say, `$HOME/.config/service` is after all just a matter of _another_ service to `setuidgid` and do so. – JdeBP Apr 02 '18 at 21:02