Quelle:
http://ubuntuforums.org/showthread.php?t=234588
Um Wake on Lan unter Linux einzurichten, muss man neben der BIOS Einstellung auch Linux so umkonfigurieren, dass die Schnittstelle mit Strom versorgt wird und auf Befehle wartet.
Man kann das manuell machen oder man nutzt folgendes Script, welches von der oben genannten Quelle stammt.
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#!/bin/bash
function set_variables {
wakeinitscript="/etc/init.d/wakeonlanconfig"
wakeinitscriptname="wakeonlanconfig"
}
function lanwake_intro {
clear
echo "Lazyman's Wake On LAN Automatic configuration script for Ubuntu 6.06 Dapper"
echo "Written by Kai Hanari"
echo
echo
}
function get_codename {
lsb_release -c
}
function version_good {
sleep 0.5
echo "OK, continuing"
sleep 0.5
echo
}
function version_bad {
echo "This is NOT Ubuntu 6.06! This linux version says that it is \"" get_codename "\""
}
function check_version {
echo "Checking Ubuntu version "
sleep 0.5
echo "-- this script is ONLY tested as of yet for Ubuntu 6.06 Dapper"
if (get_codename | grep apper > /dev/null)
then
version_good
else
version_bad
fi
}
function check_root {
clear
echo "Checking for root access..."
check_uid
}
function root_bad {
sleep 0.5
echo "You are not root!"
sleep 0.2
echo "You must run this program as root or using sudo."
sleep 1.5
exit 1
}
function root_good {
sleep 0.5
echo "OK"
}
function check_uid {
if ([[ $UID != 0 ]])
then
root_bad
fi
root_good
}
function check_iface_null {
if ([[ $iface1 = "" ]])
then
iface1="eth0"
fi
}
function get_interface {
clear
sleep 0.5
read -p "Enter the device name to turn on WOL on (ONLY ONE INTERFACE) [eth0]: " iface1
echo
check_iface_null
sleep 0.7
echo "Applying to" $iface1
echo
}
function prompt_file {
# << improvment later: if no, prompt for a different filename and use it >>
# << also, clean up if statement block >>
echo "This will make/overrite /etc/init.d/wakeonlanconfig,"
sleep 0.2
echo "which does not exist by default"
yesno=""
sleep 0.5
read -p "Ok? (Y/N) [Y]: " yesno
if ([[ $yesno = "n" ]])
then
user_abort
elif ([[ $yesno = "N" ]])
then
user_abort
fi
}
function user_abort {
sleep 0.5
echo "User aborted"
sleep 1.5
exit 1
}
function create_script_file {
touch $wakeinitscript
}
function fill_script {
echo "Filling script with data"
echo "#!/bin/bash" > $wakeinitscript
echo "ethtool -s" $iface1 "wol g" >> $wakeinitscript
echo "exit" >> $wakeinitscript
}
function set_permissions {
echo "setting permissions..."
chmod a+x $wakeinitscript
}
function add_to_startup {
echo
echo "Script created, making it start on startup"
update-rc.d -f $wakeinitscriptname defaults >/dev/null
}
function run_this_time {
echo
echo "All done, running the script now."
$wakeinintscript
}
function get_mac {
macaddr1=`ifconfig $iface1 | grep HW | awk '{ print $5 }'`
}
function show_mac {
echo
echo "Getting MAC address of" $iface1
get_mac
sleep 0.7
echo $iface1 "'s MAC address is" $macaddr1
}
function lanwake_end {
echo
echo
echo "Finished. Test it out. For a wake on lan program,"
echo "apt-get install wakeonlan You may have to enable universe/multiverse"
echo "repositories in your sources.list"
echo "---------------------------------------------------------------------"
exit
}
set_variables
lanwake_intro
sleep 1
check_version
sleep 1
check_root
sleep 1
# fun begins
# which device? << improvement for later versions: accept more than one network interface here and loop to apply to them all >>
get_interface
sleep 0.5
prompt_file
sleep 0.7
create_script_file
sleep 0.2
fill_script
sleep 0.9
set_permissions
sleep 0.2
add_to_startup
sleep 0.2
run_this_time
sleep 0.5
show_mac
sleep 0.2
lanwake_end
|
Danach muss man nur noch am zweiten Rechner
|
Quellcode
|
1
|
sudo aptitude install wakeonlan
|
ausführen und schon kann man den ausgeschaltenen Rechner mit
|
Quellcode
|
1
|
wakeonlan MACADRESSE
|
aufwecken