-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpower
More file actions
35 lines (31 loc) · 825 Bytes
/
power
File metadata and controls
35 lines (31 loc) · 825 Bytes
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
#!/bin/bash
# wake on lan and shutdown script for remote servers
# for shutdown publickey ssh has to be set up on remote server
# Author: C. Schiller schreibcarl@gmail.com
#Path
_wol="/usr/bin/wakeonlan" #wakeonlan or wol
_ssh="/usr/bin/ssh" #ssh path
_shutdown="/usr/sbin/shutdown.sh"
#Time to wait after magic-package
waittime="60"
# IP or hostname of remote server
server="mycloud"
#mac adress of remote server
server_mac="00:90:a9:ed:8a:a9"
# parametercheck
if [ $# -ne 1 ]; then
echo "Too much or too few parameters."
echo "Use one of: <on | off>"
exit 1
fi
if [ $1 == "on" ]; then
#wake server
$_wol $server_mac &>/dev/null
sleep $waittime
elif [ $1 == "off" ]; then
#shutdwon server
$_ssh root@$server "sync && sync && $_shutdown" &>/dev/null
else
echo "Use one of: <on | off>"
exit 1
fi