| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Avicap - Howto use shutdown & resume</title> |
| 5 |
|
| 6 |
<meta http-equiv="content-type" |
| 7 |
content="text/html; charset=ISO-8859-1"> |
| 8 |
</head> |
| 9 |
<body> |
| 10 |
|
| 11 |
<h2>HOWTO use shutdown & resume with Avicap</h2> |
| 12 |
<a |
| 13 |
href="avicap.html">back |
| 14 |
to Avicap Index</a><br> |
| 15 |
<br> |
| 16 |
docu by: Alexander Rawass (<a |
| 17 |
href="mailto:[email protected]">[email protected]</a>)<br> |
| 18 |
if anyone can write a better documentation - please do it and tell me<br> |
| 19 |
<br> |
| 20 |
this howto describes how you can shutdown,poweroff,resume & reboot |
| 21 |
your linux with Avicap, to have a video recording tool with a programmable |
| 22 |
timer, that allows your computer to be powered-off in-between recordings<br> |
| 23 |
<br> |
| 24 |
|
| 25 |
<ul> |
| 26 |
<li><a href="#check_bios">Check your BIOS</a></li> |
| 27 |
<li><a href="#install_nvramwakeup">Install nvram-wakeup</a> </li> |
| 28 |
<li><a href="#root_scripts">root scripts for your linux</a> </li> |
| 29 |
<li><a href="#config_shutdown">Configuring Avicap for shutdown & resume</a> |
| 30 |
</li> |
| 31 |
<li><a href="#known_problems">known problems</a> <br> |
| 32 |
</li> |
| 33 |
|
| 34 |
</ul> |
| 35 |
<br> |
| 36 |
|
| 37 |
<h3><a name="check_bios"></a>Step 1: Check your BIOS </h3> |
| 38 |
Most modern BIOS have an advanced power management section, which allows |
| 39 |
you not only to configure sleep/suspend modes, but also on which signals |
| 40 |
your computer should poweron from 'soft-off'<br> |
| 41 |
<br> |
| 42 |
Goto to the BIOS, to the advanced power management section<br> |
| 43 |
Turn on advanced power management on, if you haven't enabled it before, |
| 44 |
you might want to set most entries to 'disabled'.<br> |
| 45 |
<br> |
| 46 |
For awakening after a soft-off, we need to enable<br> |
| 47 |
'RTC Alarm Resume from Soft off'<br> |
| 48 |
<br> |
| 49 |
Below this, you should be able to set the date and the time to wakeup.<br> |
| 50 |
<br> |
| 51 |
If you don't find such entries in your BIOS, well, it won't work for |
| 52 |
you,sorry.<br> |
| 53 |
<br> |
| 54 |
|
| 55 |
<h3><a name="install_nvramwakeup"></a>Step 2: Install nvram-wakeup</h3> |
| 56 |
<a href="http://sourceforge.net/projects/nvram-wakeup"> http://sourceforge.net/projects/nvram-wakeup</a><br> |
| 57 |
<br> |
| 58 |
Download the latest version of nvram-wakeup.<br> |
| 59 |
<br> |
| 60 |
nvram-wakeup is a tool to set the RTC alarm time in your Bios - WARNING, |
| 61 |
this may be dangerous, be careful what you do!<br> |
| 62 |
<br> |
| 63 |
compile nvram-wakeup.<br> |
| 64 |
<br> |
| 65 |
Read the README file. Read it again.<br> |
| 66 |
<br> |
| 67 |
Read the README.mb file. Read it twice again!<br> |
| 68 |
<br> |
| 69 |
Now you can be lucky, then your motherboard/bios will be supported by |
| 70 |
nvram-wakeup.<br> |
| 71 |
<br> |
| 72 |
If you're unlucky (like me with my Asus K7M motherboard), you'll have |
| 73 |
to find out the bytes in your nvram that contain the RTC alarm date.<br> |
| 74 |
<br> |
| 75 |
Read the README.mb file again.<br> |
| 76 |
<br> |
| 77 |
Maybe you can use the latest CVS version of nvram-wakeup, else you'll |
| 78 |
have to run the 'guess' script that's delivered with nvram-wakeup, it's usage |
| 79 |
is described in README.mb<br> |
| 80 |
<br> |
| 81 |
If you've now followed the steps in README.mb and you now seem to have |
| 82 |
a working configuration for nvram-wakeup, test it yourself, and be aware |
| 83 |
that false bytes written in your nvram may you cause to loose your precious |
| 84 |
bios settings.<br> |
| 85 |
<br> |
| 86 |
All I can say, the guess script worked for me, with a little modification.<br> |
| 87 |
<br> |
| 88 |
To use nvram-wakeup with avicap, you should edit 'nvram-wakeup.h' and |
| 89 |
set these defines to zero like this:<br> |
| 90 |
#define WAKEUP_BEFORE 0<br> |
| 91 |
#define NEED_TO_SHTDWN 0<br> |
| 92 |
cause these values can be set in Avicap's GUI directly.<br> |
| 93 |
<br> |
| 94 |
|
| 95 |
<h3><a name="root_scripts"></a>Step 3: root scripts for your linux</h3> |
| 96 |
For the shutdown & resume process to work for Avicap, you'll need |
| 97 |
to have several shell scripts that will be run via sudo:<br> |
| 98 |
<br> |
| 99 |
avicap-shutdown: let's avicap shutdown your computer<br> |
| 100 |
avicap-setnvram: sets the RTC alarm date in your BIOS via nvram-wakeup<br> |
| 101 |
avicap-boot: a init script for /etc/init.d that starts your |
| 102 |
computer either via the normal way, or it starts avicap in timer-mode, |
| 103 |
and manages the 'twice shutdown' problem.<br> |
| 104 |
<br> |
| 105 |
These scripts can be found in avifile/samples/qtvidcap/scripts<br> |
| 106 |
They will not get installed by 'make install', you have to copy them to |
| 107 |
their locations for yourself, cause they could do damage to your system |
| 108 |
by shutting down unexpectedly.<br> |
| 109 |
<br> |
| 110 |
avicap-shutdown and avicap-setnvram should be copied to /usr/local/bin<br> |
| 111 |
<br> |
| 112 |
avicap-boot should be copied to /etc/init.d<br> |
| 113 |
<br> |
| 114 |
You also have to create these links:<br> |
| 115 |
<br> |
| 116 |
/etc/init.d/boot.d/S01avicap -> /etc/init.d/avicap-boot<br> |
| 117 |
/etc/init.d/rc3.d/S99avicap -> /etc/init.d/avicap-boot<br> |
| 118 |
<br> |
| 119 |
You HAVE to edit all these scripts manually to suit them to your system |
| 120 |
- especially avicap-boot is highly customized to my system, my way of booting |
| 121 |
and my preferences.<br> |
| 122 |
<br> |
| 123 |
You also have to edit with 'visudo' your sudoers file to allow avicap |
| 124 |
to call avicap-shutdown and avicap-setnvram, something like this:<br> |
| 125 |
alex ALL= NOPASSWD: /home/alex/sbin/avicap-shutdown<br> |
| 126 |
alex ALL= NOPASSWD: /home/alex/sbin/avicap-setnvram<br> |
| 127 |
<br> |
| 128 |
Be aware that using these scripts and letting avicap shutdown & resume |
| 129 |
your computer interferes severely with the running of a full blown unix |
| 130 |
system.<br> |
| 131 |
<br> |
| 132 |
The shutdown & resume capabilites should only be used on a 'single-person' |
| 133 |
workstation, with no running jobs in background.<br> |
| 134 |
<br> |
| 135 |
I've prepared such scripts for my system, they might suit you or not, |
| 136 |
if you've got better solutions, send them to me.<br> |
| 137 |
<br> |
| 138 |
My system is a SuSE 8.1-based system, running kernel 2.4.18 with apm |
| 139 |
enabled (this is necessary to poweroff your ATX power...<br> |
| 140 |
<br> |
| 141 |
I am only booting my system to runlevel 3 (no networking, no graphics).<br> |
| 142 |
<br> |
| 143 |
I login in textmode and then do a 'startx' manually.<br> |
| 144 |
<br> |
| 145 |
The avicap-reboot script will check at the end of runlevel 3, if it should |
| 146 |
do nothing or start X and avicap automatically, you have to edit |
| 147 |
this script to suit it to your system and preferences.<br> |
| 148 |
<br> |
| 149 |
On my system, there's a special problem:<br> |
| 150 |
<br> |
| 151 |
the setting of the RTC and the resume will only work, if the system is |
| 152 |
resetted, after the RTC alarm date in the nvram has been set.<br> |
| 153 |
<br> |
| 154 |
So the shutdown & resume will have to shutdown TWICE, once to reboot |
| 155 |
to make a reset, and the other to actually shutdown.<br> |
| 156 |
<br> |
| 157 |
It goes like this:<br> |
| 158 |
<br> |
| 159 |
1. Avicap calls 'sudo avicap-setnvram <timestamp>' to set the RTC<br> |
| 160 |
avicap-setnvram will create a file /etc/avicap/next_recording<br> |
| 161 |
<br> |
| 162 |
2. Avicap calls 'sudo avicap-shutdown' to shutdown & reboot my system<br> |
| 163 |
avicap-shutdown will create a file /etc/avicap/first_shutdown<br> |
| 164 |
then it will make a shutdown -r (reboot) to reboot |
| 165 |
the system<br> |
| 166 |
<br> |
| 167 |
3. The system reboots, and shortly after booting, 'avicap-boot' is called |
| 168 |
again (in runlevel S)<br> |
| 169 |
<br> |
| 170 |
4. If the file /etc/avicap/first_shutdown exists, the file gets removed |
| 171 |
and the system will go down again with halt -p -f (force power off) to poweroff |
| 172 |
the computer.<br> |
| 173 |
<br> |
| 174 |
5. The computer is now off, till the time you've set for first recording.<br> |
| 175 |
<br> |
| 176 |
6. The RTC alarm will poweron your computer<br> |
| 177 |
<br> |
| 178 |
7. My linux will boot in runlevel 3, at the end of runlevel 3 'avicap-boot' |
| 179 |
is called.<br> |
| 180 |
<br> |
| 181 |
8. If the file /etc/avicap/next_recording exists, then it is assumed |
| 182 |
that the re-boot is a 'timed' reboot done by the RTC alarm.<br> |
| 183 |
<br> |
| 184 |
9. avicap-boot will then call 'startx' to start X and KDE (takes a long |
| 185 |
time...) or Gnome or whatever and then 'avicap -timer'<br> |
| 186 |
<br> |
| 187 |
10. and then avicap should start recording as you liked it<br> |
| 188 |
<br> |
| 189 |
11. until the recording stops and it is time to go down again<br> |
| 190 |
<br> |
| 191 |
|
| 192 |
<h3><a name="config_shutdown"></a>Step 4: Configuring Avicap for shutdown |
| 193 |
& resume</h3> |
| 194 |
There's a new Tab in the 'Configure'-Dialog named 'Shutdown&Resume'<br> |
| 195 |
<br> |
| 196 |
These options tell avicap when to shutdown:<br> |
| 197 |
|
| 198 |
<ul> |
| 199 |
<li> never shut down system<br> |
| 200 |
avicap will never try to shutdown your system</li> |
| 201 |
<li>shutdown after last tecording<br> |
| 202 |
avicap will shutdown (to poweroff) your system only after the last recording, |
| 203 |
when there are no pending records<br> |
| 204 |
you don't need nvram-wakeup for this<br> |
| 205 |
</li> |
| 206 |
<li>shutdown in-between recordings<br> |
| 207 |
avicap will shutdown (first to reboot, then to poweroff) your system with |
| 208 |
nvram-wakeup between recordings<br> |
| 209 |
</li> |
| 210 |
|
| 211 |
</ul> |
| 212 |
|
| 213 |
<ul> |
| 214 |
<li>minimum downtime in min<br> |
| 215 |
the system will only be shut down in-between recordings, when the system |
| 216 |
would be in power-off longer than this time<br> |
| 217 |
it is probably not sensible to send the system up and down for just 5 |
| 218 |
minutes downtime<br> |
| 219 |
sensible values could range from 10 to 30 minutes or so<br> |
| 220 |
</li> |
| 221 |
<li>boot n mins before recording<br> |
| 222 |
a unix system can take quite a lot of time to boot and to start X/KDE/Gnome |
| 223 |
on top of it.<br> |
| 224 |
the system will power-on and reboot n mins before the recording should |
| 225 |
start<br> |
| 226 |
make sure that time is long enough, if you are not using a journaling |
| 227 |
filesystem, you should be aware that sometimes booting can be quite long<br> |
| 228 |
sensible values could range from 5 to 15 minutes</li> |
| 229 |
<li>gracetime for shutdown in min<br> |
| 230 |
if avicap decides that a shutdown should be done, it pops up a critical |
| 231 |
requester, which shows a countdown for gracetime mins<br> |
| 232 |
press abort in that dialog to abort the shutdown</li> |
| 233 |
|
| 234 |
</ul> |
| 235 |
<br> |
| 236 |
To use that feature, you also have to enable the 'shutdown' checkbox in |
| 237 |
the main timertable window.<br> |
| 238 |
That checkbox will always be de-activated when you start avicap normally |
| 239 |
(so you have to check it again).<br> |
| 240 |
If you start avicap with 'avicap -timer', avicap will open the timertable |
| 241 |
window, sets that checkbox and starts the timer and waits for the first recording.<br> |
| 242 |
<br> |
| 243 |
avicap is started with -timer from avicap-boot, so it will go down if |
| 244 |
the recording has finished.<br> |
| 245 |
<br> |
| 246 |
I advise you strongly to test this feature thoroughly, so that you can |
| 247 |
be sure it works for you,too.<br> |
| 248 |
It would be a shame, if a precious recording is lost - but, alas, Free |
| 249 |
Software comes without any warranty, so be warned<br> |
| 250 |
<br> |
| 251 |
|
| 252 |
<h3><a name="known_problems"></a>Known Problems</h3> |
| 253 |
|
| 254 |
<ul> |
| 255 |
<li>my system is running it's hardware-clock in localtime, so the RTC |
| 256 |
alarm is also set in localtime, there's code to check if localtime differs |
| 257 |
from UTC and sets the RTC alarm correctly.<br> |
| 258 |
I believe. Umpft. Test it yourself.</li> |
| 259 |
<li>I have no idea what happens if your system (hardware) clock runs |
| 260 |
in UTC.<br> |
| 261 |
test it thoroughly and tell me about it</li> |
| 262 |
<li>I have no idea what happens if the local time switches an hour to |
| 263 |
the future or back - for example, when we Europeans switch from winter time |
| 264 |
(CET) to summer time (CEST) or back<br> |
| 265 |
Your recordings might start at the right time, an hour too late or an hour |
| 266 |
too early</li> |
| 267 |
<li>I have no idea what happens when you're flying in an airplane that |
| 268 |
travels round the world (with or against time), I also don't know what might |
| 269 |
happen if you fly in a spaceship at 95% light speed, you've been warned, |
| 270 |
the timer might do really crazy things there ;-)))</li> |
| 271 |
<li>I am using QDateTime for my calculations, I just hope it's clever |
| 272 |
enough to cope with leapyears and such</li> |
| 273 |
|
| 274 |
</ul> |
| 275 |
When you've started Avicap from a shell window, it will show it's output |
| 276 |
there when nvram-wakeup is setting the RTC alarm, you should see for yourself |
| 277 |
if the RTC is set correctly.<br> |
| 278 |
<br> |
| 279 |
<br> |
| 280 |
<br> |
| 281 |
<br> |
| 282 |
<br> |
| 283 |
</body> |
| 284 |
</html> |