Startup script to wakeonlan fileserver
#1
Hi,

I'm trying to create a very simple startup script which should wake/startup my fileserver. I've created a file saved it in /etc/init.d and made it excecutable.
After that I made the script launched at startup.
The script works when launched manually. But it won't start my server when starting up xbmc. It will start my server when halting xbmc Huh

These are the steps..

PHP Code:
sudo -

Install wakeonlan package
PHP Code:
apt-get install wakeonlan 

Change to the startup script directory and start editing a new file:
PHP Code:
cd /etc/init.d
PHP Code:
nano wakeonlansrv 

Enter these lines and save file..
PHP Code:
#!/bin/bash
wakeonlan 00:00:00:00:00:00 

Set the permissions of the file:
PHP Code:
chmod +/etc/init.d/wakeonlansrv 

Make the script run on startup:
PHP Code:
update-rc.-n wakeonlansrv defaults 

Now we finish by running it, and making sure there are no errors.
PHP Code:
/etc/init.d/wakeonlansrv 

Reboot to test the script..
PHP Code:
reboot 

Testing the script starts the server and print this output:

root@dhcppc8:/etc/init.d# /etc/init.d/wakeonlansrv
Sending magic packet to 255.255.255.255:9 with 00:00:00:00:00:00
root@dhcppc8:/etc/init.d#

Is there a logfile (init.d) which will log any startup errors or do I mis something? please advise Smile
Reply
#2
according to the man page, -n for update-rc.d tells it to do nothing.

Check /etc/rc3.d and rc5.d for a link to your script. Also be sure it runs only after all the network stuff is setup. If you use defaults, it should be ok. Note that defaults will also cause the script to be run on shutdown also.

Have to ask, I assume you have 00:00:00:00:00:00 to simply to not reveal your mac?

I use etherwake and the following:

Code:
/etc/init.d/wakebackend:

#! /bin/bash
#
# Wake up mythTV backend using wakeonlan
#
echo "Waking Backend..."
/usr/bin/etherwake 00:aa:bb:cc:dd:ee
sleep 5
exit 0

then enable the script by:

chmod a+x wakebackend

cd /rcS.d

ln –s /etc/init.d/wakebackend S41wakebackend

There is also another option depending on what network card you have. I use a modified version of etherboot on a USB key. The PC first boots the USB key which sends the wakeup packet, then it boots normally into Linux. The Etherboot adds about 1-3 seconds to boot, but the advantage is that the server is woken up much sooner than with an init.d script. I actually use both, the init.d script as a backup.

If your interested I can post the modified etherboot code. But note that ethernet driver support is somewhat limited in etherboot.
Reply
#3
works like a charm!

Stupid using the -n parameter.
Thanks a lot.

I did use these commands by the way..
Make the script run on startup:
#update-rc.d wakeonlansrv defaults

remove script for reboot and halt runtime
#rm /etc/rc0.d/K20wakeonlansrv
#rm /etc/rc1.d/K20wakeonlansrv
#rm /etc/rc6.d/K20wakeonlansrv
Reply

Logout Mark Read Team Forum Stats Members Help
Startup script to wakeonlan fileserver0