1 |
Author: zzam |
2 |
Date: 2008-07-30 16:05:58 +0000 (Wed, 30 Jul 2008) |
3 |
New Revision: 642 |
4 |
|
5 |
Modified: |
6 |
gentoo-vdr-scripts/trunk/ChangeLog |
7 |
gentoo-vdr-scripts/trunk/usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh |
8 |
Log: |
9 |
Simplify shutdown code a bit. |
10 |
|
11 |
Modified: gentoo-vdr-scripts/trunk/ChangeLog |
12 |
=================================================================== |
13 |
--- gentoo-vdr-scripts/trunk/ChangeLog 2008-07-30 15:46:17 UTC (rev 641) |
14 |
+++ gentoo-vdr-scripts/trunk/ChangeLog 2008-07-30 16:05:58 UTC (rev 642) |
15 |
@@ -2,6 +2,10 @@ |
16 |
# $Id$ |
17 |
|
18 |
30 Jul 2008; Matthias Schwarzott <zzam@g.o> |
19 |
+ usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh: |
20 |
+ Simplify shutdown code a bit. |
21 |
+ |
22 |
+ 30 Jul 2008; Matthias Schwarzott <zzam@g.o> |
23 |
+usr/share/vdr/bin/vdrshutdown-gate.sh, |
24 |
usr/share/vdr/bin/vdrshutdown-really.sh, |
25 |
usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh: |
26 |
|
27 |
Modified: gentoo-vdr-scripts/trunk/usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh |
28 |
=================================================================== |
29 |
--- gentoo-vdr-scripts/trunk/usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh 2008-07-30 15:46:17 UTC (rev 641) |
30 |
+++ gentoo-vdr-scripts/trunk/usr/share/vdr/bin/vdrshutdown-wakeup-helper.sh 2008-07-30 16:05:58 UTC (rev 642) |
31 |
@@ -10,15 +10,15 @@ |
32 |
# real shutdown/reboot. |
33 |
# |
34 |
|
35 |
-. /usr/share/vdr/inc/functions.sh |
36 |
-include shutdown-functions |
37 |
-shutdown_script_dir=/usr/share/vdr/shutdown |
38 |
- |
39 |
if [ "$UID" != "0" ]; then |
40 |
echo "This program should be run as root" |
41 |
exit 99 |
42 |
fi |
43 |
|
44 |
+. /usr/share/vdr/inc/functions.sh |
45 |
+include shutdown-functions |
46 |
+shutdown_script_dir=/usr/share/vdr/shutdown |
47 |
+ |
48 |
if [ "${DEBUG}" -ge 1 ]; then |
49 |
exec >/tmp/vdrshutdown-real-log 2>&1 |
50 |
echo Started debug output of $0 $@ |
51 |
@@ -44,8 +44,7 @@ |
52 |
date +%s > ${shutdown_data_dir}/shutdown-need-reboot |
53 |
} |
54 |
|
55 |
-read_reboot_setting() { |
56 |
- NEED_REBOOT=0 |
57 |
+need_reboot() { |
58 |
[ -e "${shutdown_data_dir}/shutdown-need-reboot" ] || return |
59 |
local TSTAMP=$(cat ${shutdown_data_dir}/shutdown-need-reboot) |
60 |
local NOW=$(date +%s) |
61 |
@@ -55,8 +54,10 @@ |
62 |
UPTIME=${UPTIME%%.*} |
63 |
|
64 |
if [ "${REBOOT_SET_AGO}" -lt "${UPTIME}" ]; then |
65 |
- NEED_REBOOT=1 |
66 |
+ return 0 |
67 |
fi |
68 |
+ |
69 |
+ return 1 |
70 |
} |
71 |
|
72 |
|
73 |
@@ -83,16 +84,23 @@ |
74 |
done |
75 |
[ ${wakeup_ok} = 0 ] && exit 99 |
76 |
|
77 |
+ |
78 |
+SHUTDOWN_METHOD=halt |
79 |
+if need_reboot; then |
80 |
+ SHUTDOWN_METHOD=reboot |
81 |
+fi |
82 |
+ |
83 |
+f="${shutdown_script_dir}/shutdown-${SHUTDOWN_METHOD}.sh" |
84 |
+ |
85 |
if [ "${DRY_SHUTDOWN}" = "1" ]; then |
86 |
+ echo "dry run: NOT executing shutdown-${SHUTDOWN_METHOD}.sh" |
87 |
exit 0 |
88 |
fi |
89 |
|
90 |
-read_reboot_setting |
91 |
+if [ -f "$f" ]; then |
92 |
+ echo "Executing shutdown-${SHUTDOWN_METHOD}.sh" |
93 |
+ . "$f" |
94 |
+fi |
95 |
|
96 |
-case "${NEED_REBOOT}" in |
97 |
- 1) . ${shutdown_script_dir}/shutdown-reboot.sh ;; |
98 |
- 0) . ${shutdown_script_dir}/shutdown-halt.sh ;; |
99 |
-esac |
100 |
- |
101 |
exit 0 |