VLC won't start automatically at Ubuntu boot - streaming

I am trying to configure VLC to start streaming two streams automatically on boot with Upstart.
Here is my upstart script:
description "VLC streams"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]
exec /home/streamer/stream.sh
and stream.sh:
#!/bin/bash
cvlc -v "/home/administrator/Videos/Kastiel/kastiel.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.31:9200}' --sout-keep --loop &
cvlc -v "/home/administrator/Videos/Rozpravky/rozpravky.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.2:9200}' --sout-keep --random &
exit 0
However, after the computer boots, there is no stream and VLC process is not running. When I run stream.sh manually, it works with no problem.
Does anybody know what mistake am I doing?
I am using Ubuntu 12.10 and VLC 2.0.5.
Thank you in advance for any help.
Milan

Vlc doesn't support to be run as root due to security reasons.
You should use sudo -u user in script to change the user.
try as :
sudo -u username cvlc -v "/home/administrator/Videos/Kastiel/kastiel.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.31:9200}' --sout-keep --loop &

Related

Can Raspberry pi run 2 commands on startup with a delay in between them

I want to fire 2 commands on startup on my raspberry pi
The first one runs a node server starting script.
The second one should open chromium browser with a specific page.
The point is that I want to wait a couple of seconds to launch chromium so I'm sure that the webpage will be connected to the node server.
I tried so many things but I can't seem to fix a the delay.
Any suggestions?
This is what I have now in an LXDE session:
#lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#xscreensaver -no-splash
// This starts the node server
#/home/pi/autostart.sh
// This starts the browser
#/home/pi/async.sh
The async bash runs this:
#!/usr/bin/env bash
sleep 5
chromium-browser -kiosk http://localhost:3000
You start the node server and loop until the site comes online before launching the web-browser.
Replace "sleep 5" in async.sh by the following:
until $(curl --output /dev/null --silent --head --fail http://localhost:3000); do
printf '.'
sleep 1
done
source : How to create a loop in bash that is waiting for a webserver to respond?

Polybar launch.sh not running when Awesome wm is restarted

I've been setting up my Linux desktop, running Arch on Kernel 5.18.14, and have run into some issues when configuring Polybar to start when Awesome wm starts
This is my polybar launch script (/home/user/.config/polybar/launch.sh):
#!/bin/bash
killall -q polybar
while pgrep -x polybar >/dev/null; do sleep 1; done
for m in $(polybar --list-monitors | cut -d":" -f1); do
MONITOR=$m polybar duat &
done
My polybar bar is named duat in the config.ini
This is where I execute the script in my Awesome wm rc.lua
awful.spawn.with_shell("/home/user/.config/polybar/launch.sh")
awful.spawn.with_shell("feh --bg-fill ~/.config/awesome/backgrounds/background.png")
awful.spawn.with_shell("wal -R")
Any help is greatly appreciated. It should be noted that once I run the script manually, awesome wm seems to have no problem running the script when reloaded, but if polybar is completely inactive, it refuses to start.

Raspberry Pi MJPEG video stream - start application at reboot

I am making a MJPEG video stream using Raspberry Pi with dedicated Pi Camera. For this I am using jpeg libraries and the following web application found on Github. The use is pretty straightforward, you just type cd mjpg-streamer/mjpg-streamer-experimental and then ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so". However, I would like to make it run on every reboot, so that the camera is "maintenance free".
I researched that I need to put the path and the executable file in the /etc/rc.local. Nevertheless, when I put the path (mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so") to this executable file, it did not work at all. I tried to run the stream as one command in the Terminal, it did not work either. I also tried to set up a variable PATH in .bashrc in order to access it from /etc/rc.local, but it also did not want to work.
I suspect it might have something to do with command ./mjpg_streamerneeding some input for it to work (-o "output_http.so -w ./www" -i "input_raspicam.so")
Do you have any idea how to start it with every reboot?
Thanks for your time and help
i have solved similar issue for my rpi and jpeg streamer as following.
create a shell script in /home/pi
touch /home/pi/mjpg-streamer.sh
edit that shell script and add this content
#!/bin/bash
cd /home/pi/mjpg-streamer/mjpg-streamer-experimental/
LD_LIBRARY_PATH=.
./mjpg_strea‌​mer -o "output_http.so -w ./www" -i "input_raspicam.so"
make sure new shell script has execution rights
add that shell script to your /etc/rc.local

Raspberry Pi / Octopi USB Camera Setup: What does this mean and how do I use it?

I'm very new to Raspberry Pi, and have no prior notable experience with Linux so this is all new to me...
Octoprint is a 3D printer spooler that you can run on your raspberry pi. One of the features on Octoprint is the ability to setup a USB camera to view either still images or a stream of your print.
I am using the Octopi prepackaged Octoprint image.
Octoprint's github contains the following info referring to my USB camera. But I have no idea how to implement this.
Hama PC-Webcam "AC-150" on Raspberry Pi
./mjpg_streamer -o output_http.so -w ./www -i input_uvc.so -y -r 640x480 -f 10
https://github.com/foosel/OctoPrint/wiki/Webcams-known-to-work
I'm guessing this is an easy command that I enter via console, but I've winged few commands with no luck. Can someone shed some light on how I use this? Like I said I'm an absolute beginner with the pi...
Any help is greatly appreciated!
Try this:
camera_usb_options="-r VGA -f 10 -y"
sudo service octoprint stop
fuser /dev/video0
/dev/video0: **1871m**
$ ps axl | grep **1871** *Change this number by yours*
$ kill -9 **1871**
./mjpg_streamer -i "input_uvc.so $camera_usb_options" -o "output_http.so -w ./www"
sudo service octoprint start

Start shrew vpn client (iked & ikec) on start-up of OSMC on Raspberry 2

I would like to connect to a VPN on start-up of OSMC.
Environment:
installed OSMC on Raspberry 2
downloaded, compiled and installed shrew soft vpn on the device
As user 'osmc' with ssh
> sudo iked starts the daemon successfully
> ikec -r "test.vpn" -a starts the client, loads the config and connects successfully
rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo iked >> /home/osmc/iked.log 2>> /home/osmc/iked.error.log &
ikec -a -r "test.vpn" >> /home/osmc/ikec.log 2>> /home/osmc/ikec.error.log &
exit 0
after start of raspberry iked is as process visible with ps -e
but ikec is not running
osmc#osmc:~$ /etc/rc.local starts the script and connects to vpn successfully
Problem:
Why does the script not working correctly on start-up?
Thank you for your help!
I was also looking to do the same thing as you and ran into the same problem. I'm no linux expert, but I did figure out a workaround.
I created a script called ikec_after_reboot.sh and it looks like this...
$ cat ikec_after_reboot.sh
#!/bin/bash
echo "Starting ikec"
ikec -r test.vpn -a
I then installed cron.
sudo apt-get update
sudo apt-get install cron
Edit the cron job as root and run the ikec script 60 seconds after reboot.
sudo crontab -e
SHELL=/bin/bash
#reboot sleep 60 && /home/osmc/ikec_after_reboot.sh & >> /home/osmc/ikec.log 2>&1
Now edit your /etc/rc.local file and add the following.
sudo iked >> //home/osmc/iked.log 2>> /home/osmc/iked.error.log &
exit 0
Hopefully, this is helpful to you.