LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-04-2009, 12:01 PM   #1
BassKozz
Member
 
Registered: Dec 2008
Distribution: Ubuntu 8.10
Posts: 35

Rep: Reputation: 15
WOL startup script?


My NAS powers off every-night to save electricity thanks to a little script I created (see: Advanced Shutdown Script - Powersaving).
But now every-morning, before I power on my desktop I need to boot up my NAS 1st , and I am lazy, so the energy exerted to push the power button on my NAS box can be better used else where

So I created a little script that will wake up my NAS box and mount the share(s):
Code:
#!/bin/sh
###
# 2/3/09
# wake-NAS.sh
# Wake-On-Lan wake NAS Script
###

echo "Begin: $(date)" >> /home/user/scripts/wake-NAS.log
wakeonlan AA:BB:CC:DD:EE:FF >> /home/user/scripts/wake-NAS.log
sleep 5m
mount -a >> /home/user/scripts/wake-NAS.log
echo "End  : $(date)" >> /home/user/scripts/wake-NAS.log
I am using Ubuntu,
So I put this script in /etc/init.d/ and ran 'update-rc.d wake-NAS.sh defaults' and rebooted, and it worked

However, there are two problems:
  1. It caused my bootup time to be +5minutes, due to the line "sleep 5m", I figured it would just run the script in the background on bootup and not holdup the boot, but that's not the case...
    Is there a way to get this to run in the background so it doesn't hold up my bootup times?
    Or maybe I could make the "mount -a" a separate script that runs after the machine is fully booted (i.e. in Ubuntu I could use System>Preferences>Sessions).
  2. It runs at shutdown as well, which is pointless, I don't want to wake my NAS when I am shutting down, nore do I want to mount my shares (mount -a)
Any idea's?
If anyone knows of a better way of going about this, I am all ears
 
Old 02-04-2009, 03:21 PM   #2
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
For issue 1

Code:
if [ $# -ne "0" ]; then
   put your script here

   exit
fi

exec $0 foo &
You might need to change your #!/bin/sh to #!/bin/bash for the if statement to work, I can't recall or be bothered to test.

For issue 2, look in the directories /etc/init.d/rc[1-5].d (or is in /etc/rc[1-5].d on Ubuntu, I forget) and you'll probably find symbolic links to your wake-NAS.sh script. One link will have a name starting with S and the other with K. Delete the one starting with K as that's the one that will be run on shutdown. It's something like that anyway, I don't have a Ubuntu install to check specifics on.

Last edited by arizonagroovejet; 02-04-2009 at 03:21 PM. Reason: forgot exec
 
  


Reply

Tags
wakeonlan, wol



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
startup script losintikfos Linux - Newbie 1 08-28-2008 04:32 AM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 09:40 PM
startup script ... again. Vindane Linux - Wireless Networking 2 03-04-2005 02:57 AM
startup script djinniyah Linux - Newbie 2 09-18-2003 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration