Edit how XBMC is booted?
#1
Hi guys

I installed Ubuntu Minimal command line on my new Zotac nettop. Then I used the "XBMC Complete Installer", from: http://sourceforge.net/projects/xci/
It worked perfectly! - With no linux experience I am now running XBMC on this small linux box - sweet.

I have all my videos stored on my Windows Home Server. I have now managed to send a WOL package to my server when my Zotac boots, using the information from this thread: http://forum.xbmc.org/showthread.php?tid=62283

I have set up a library rescan and cleanup whenever XBMC starts, so I would like to make sure that my server is up and running before launching XBMC. Therefore I tried putting a sleep command into the /etc/rc.local file just after sending the WOL package. This does however not seem to delay XBMC from being started.

My question is now, where have the "XBMC Complete Installer" script specified that XBMC should be started when booting? - It is not in the /etc/rc.local file, so there must be another script or chron job (or whatever it is called) that is starting XBMC. I was thinking that I could maybe edit that script, and put the WOL package command into that script instead of in the /etc/rc.local file. Then I could use a sleep command to delay starting XBMC. An even better solution would be if I could somehow have a loop that checks if my server is reachable after sending the WOL package, and before starting XBMC. That way I could make sure that my server is ready when XBMC rescans and cleans the library.

Can someone help me figure out a way to do this? - Hopefully give me some pointers and ideas as to how I can make this setup work.

Thanks A LOT in advance
Greetings
Spas
Reply
#2
Quote:My question is now, where have the "XBMC Complete Installer" script specified that XBMC should be started when booting?

Perhaps you should ask the author of the script that?
In xbmclive there is a runXBMC script but I am not an expert on exactly how it is executed.
Reply
#3
I don't know where the script is located, but you could have it ping your server, and abort if not up:

Code:
ping -c 10 $IP_of_your_server || exit 1

Can't test, but that should work. It will simply abort the startup sequence, so no guarantees at all. You could also tell it to abort and shut down:

Code:
ping -c 10 $IP_of_your_server || shutdown -h now

The script will probably be run as root, so it should work. If not, set up sudoers and adapt the line.
* MikroTik RB5009UG+S+IN :: ZyXEL GS1900-8HP v1 :: EAP615-Wall v1 :: Netgear GS108T v3 running OpenWrt 23.05
* LibreELEC 11:  HTPC Gigabyte Brix GB-BXA8-5545 with CEC adapter, Sony XR-64A84K :: Desktop AMD Ryzen 7 5800X / Sapphire Nitro+ Radeon 6700XT  / 27" Dell U2717D QHD
* Debian Bookworm x86_64: Celeron G1610, NFS/MariaDB/ZFS server
* Blog
Reply
#4
Sweet .:B:. ... thanks.

So "||" means that the ping command did not get a response?

Can I put that inside a loop with a sleep command? - and then make the loop run like 10 times or something, and if the server has not responded before then, abort the boot sequence.

Do you know how to make a loop like that?
Reply
#5
"||" is the OR function.


This little crude script will do the job of looping until the server has replied with 20 pings at an interval of 1 seconds (the standard for Linux ping) :


#!/bin/bash
COUNTER=20
until [ $COUNTER -lt 1 ]; do
if ping -c1 server_ip > /dev/null 2>&1 ; then
let COUNTER=-1
fi
done



be warned it will have to be killed to get it to stop if there's no ping reply Smile

I'm not much of a hacker when it comes to scripting so it could probably be made simpler or shorter,but it does the job Smile
Reply
#6
Hey cejstrup

Thanks a lot!

I follow some of the script, but not all of it Smile
Is the counter not being counted down since you say it has to be killed? - Could we change that? - and maybe insert a sleep when counting the counter down as well?

don't know how to add an else statement Smile

what does "> /dev/null 2>&1" mean?
Reply
#7
Spas Wrote:Hey cejstrup

Thanks a lot!

I follow some of the script, but not all of it Smile
Is the counter not being counted down since you say it has to be killed? - Could we change that? - and maybe insert a sleep when counting the counter down as well?

don't know how to add an else statement Smile

what does "> /dev/null 2>&1" mean?


The counter will not be counted down as long as there's no ping reply. If there is it will be counted down and after reaching 0 the script will end.


The > /dev/null 2>&1 means that STDERR is piped to STDOUT and both are piped to /dev/null . Basically means there will be no output of the command as it's all piped into /dev/null Smile
Reply
#8
cejstrup Wrote:The counter will not be counted down as long as there's no ping reply. If there is it will be counted down and after reaching 0 the script will end.


The > /dev/null 2>&1 means that STDERR is piped to STDOUT and both are piped to /dev/null . Basically means there will be no output of the command as it's all piped into /dev/null Smile
Ok - thanks for the explanation.
Instead of making the script run forever if the server does not respond to the ping, I was thinking of making an else statement. Some googling told me how that looks.

So would something like this make sense?

Code:
#!/bin/bash
COUNTER=20
until [ $COUNTER -lt 1 ]; do
if ping -c1 server_ip > /dev/null 2>&1 ; then
    exit 0
else
    sleep 10
    $COUNTER = $COUNTER - 1
fi
done

exit 1
Reply
#9
Almost,you have some syntax errors (and it seems I did as well) Smile

This should work :

#!/bin/bash
COUNTER=20
until [ $COUNTER -lt 1 ]; do
if ping -c1 server_ip > /dev/null 2>&1 ; then
exit 0
else
sleep 10
let COUNTER=COUNTER-1
fi
done

exit 1
Reply
#10
Awesome!

Thanks a lot for all your help mate - I will try it out Smile
Reply
#11
You could try changing xbmc to be one of the last things started.

## this will remove xbmc from the startup
sudo update-rc.d -f xbmc-live remove

## this will add xbmc as the last area to be started
sudo update-rc.d xbmc-live defaults 99

These may fix this situation although it only delay the startup of xbmc

Sorry didnt notice that your wakeup was in rc.local....this wouldnt help
Server: FreeNas 9 NAS: 6*3TB - Kodi Sql Database
Kodi Systems: Nvidia Shield Pro, G-Box Q (OpenElec), RikoMagic MK802 IV[
Skin: reFocus
Reply
#12
Ok had a rethink:

in your /etc/network/interfaces file:

add the below line at the end of the section of the interface eth0 i presume. This will send the wake on lan signal as soon as the network is up.

post-up /path/to/call/wakeonlan

with this and xbmc-bin at 99 you should be ok. Im sure there are better ways than this though.
Server: FreeNas 9 NAS: 6*3TB - Kodi Sql Database
Kodi Systems: Nvidia Shield Pro, G-Box Q (OpenElec), RikoMagic MK802 IV[
Skin: reFocus
Reply

Logout Mark Read Team Forum Stats Members Help
Edit how XBMC is booted?0