Parcourir la source

etherwake: import from packages

Peter Wagner il y a 10 ans
Parent
révision
bf27645121

+ 54
- 0
net/etherwake/Makefile Voir le fichier

@@ -0,0 +1,54 @@
1
+#
2
+# Copyright (C) 2007-2011 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=etherwake
11
+PKG_VERSION:=1.09
12
+PKG_RELEASE:=3
13
+
14
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
15
+PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/e/etherwake
16
+PKG_MD5SUM:=628e8b2a28d47f262e4c26c989402a59
17
+
18
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION).orig
19
+
20
+include $(INCLUDE_DIR)/package.mk
21
+
22
+define Package/etherwake
23
+  SECTION:=net
24
+  CATEGORY:=Network
25
+  TITLE:=WoL client for magic packets via ethernet frames
26
+  URL:=http://ftp.debian.org/debian/pool/main/e/etherwake
27
+endef
28
+
29
+define Package/etherwake/description
30
+	You can wake up WOL compliant Computers which have been powered down to
31
+	sleep mode or start WOL compliant Computers with a BIOS feature.
32
+	WOL is an abbreviation for Wake-on-LAN. It is a standard that allows you
33
+	to turn on a computer from another location over a network connection.
34
+	ether-wake also supports WOL passwords.
35
+endef
36
+
37
+define Build/Compile
38
+	$(TARGET_CC) $(TARGET_CFLAGS) -D__UCLIBC__ $(PKG_BUILD_DIR)/ether-wake.c -o $(PKG_BUILD_DIR)/etherwake
39
+endef
40
+
41
+define Package/etherwake/install
42
+	$(INSTALL_DIR) $(1)/usr/bin
43
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/etherwake $(1)/usr/bin/
44
+	$(INSTALL_DIR) $(1)/etc/config
45
+	$(INSTALL_DATA) files/$(PKG_NAME).config $(1)/etc/config/$(PKG_NAME)
46
+	$(INSTALL_DIR) $(1)/etc/init.d
47
+	$(INSTALL_BIN) files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
48
+endef
49
+
50
+define Package/etherwake/conffiles
51
+/etc/config/etherwake
52
+endef
53
+
54
+$(eval $(call BuildPackage,etherwake))

+ 28
- 0
net/etherwake/files/etherwake.config Voir le fichier

@@ -0,0 +1,28 @@
1
+config 'etherwake' 'setup'
2
+	# possible program pathes
3
+	option 'pathes' '/usr/bin/etherwake /usr/bin/ether-wake'
4
+	# use sudo, defaults to off
5
+	option 'sudo' 'off'
6
+	# interface, defaults to 'eth0'
7
+	# -i <ifname>
8
+	option 'interface' ''
9
+	# send wake-up packet to the broadcast address, defaults to off
10
+	# -b
11
+	option 'broadcast' 'off'
12
+
13
+config 'target'
14
+	# name for the target
15
+	option 'name' 'example'
16
+	# mac address to wake up
17
+	option 'mac' '11:22:33:44:55:66'
18
+	# password in hex without any delimiters
19
+	option 'password' 'AABBCCDDEEFF'
20
+	# wake up on system start, defaults to off
21
+	option 'wakeonboot' 'off'
22
+
23
+# To add a new target use:
24
+#  uci add etherwake target
25
+#  uci set etherwake.@target[-1].name=example
26
+#  uci set etherwake.@target[-1].mac=11:22:33:44:55:66
27
+#  uci set etherwake.@target[-1].password=AABBCCDDEEFF
28
+#  uci set etherwake.@target[-1].wakeonboot=off

+ 132
- 0
net/etherwake/files/etherwake.init Voir le fichier

@@ -0,0 +1,132 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2009 OpenWrt.org
3
+
4
+NAME='etherwake'
5
+START=60
6
+PROGRAM=''
7
+
8
+start()
9
+{
10
+	local searchlist=''
11
+	local section=''
12
+	local value=''
13
+
14
+	config_load "${NAME}"
15
+
16
+	# check for available program
17
+	config_get searchlist 'setup' 'pathes'
18
+	PROGRAM=$(search_program "${searchlist}")
19
+	[ -z "${PROGRAM}" ] && {
20
+		echo "${initscript}: No ${NAME} program installed. Check: opkg list | grep ${NAME}"
21
+		exit 1
22
+	}
23
+
24
+	# sudo
25
+	config_get_bool value 'setup' 'sudo' '0'
26
+	[ "${value}" -ne 0 ] && PROGRAM="sudo ${PROGRAM}"
27
+
28
+	# interface
29
+	config_get value 'setup' 'interface'
30
+	[ -n "${value}" ] && append PROGRAM "-i ${value}"
31
+
32
+	# broadcast
33
+	config_get_bool value 'setup' 'broadcast' '0'
34
+	[ "${value}" -ne 0 ] && append PROGRAM '-b'
35
+
36
+	# wake up targets
37
+	config_foreach etherwake_start target $*
38
+}
39
+
40
+etherwake_start()
41
+{
42
+	local section="$1"
43
+	shift
44
+
45
+	local names="$*"
46
+
47
+	local value=''
48
+	local target=''
49
+
50
+	if [ -z "${names}" ]
51
+	 then
52
+		# check if boot target
53
+		config_get_bool value "${section}" 'wakeonboot' '0'
54
+		[ "${value}" -eq 0 ] && return 0
55
+
56
+		# wake up target
57
+		do_etherwake "${section}"
58
+		return $?
59
+	else
60
+		# name
61
+		config_get value "${section}" 'name'
62
+		[ -z "${value}" ] && return 0
63
+
64
+		for target in ${names}
65
+		 do
66
+			[ "${value}" != "${target}" ] && continue
67
+
68
+			# wake up target
69
+			do_etherwake "${section}"
70
+			return $?
71
+		done
72
+	fi
73
+}
74
+
75
+# execute etherwake command for target
76
+do_etherwake()
77
+{
78
+	local section="$1"
79
+	local value=''
80
+	local password=''
81
+	local args=''
82
+
83
+	# password
84
+	config_get value "${section}" 'password'
85
+	[ -n "${value}" ] && {
86
+		password=$(etherwake_password "${value}")
87
+		append args "-p ${password}"
88
+	}
89
+
90
+	# mac address
91
+	config_get value "${section}" 'mac'
92
+	[ -z "${value}" ] && { echo "${initscript}: Target ${section} has no MAC address"; return 1; }
93
+	append args "${value}"
94
+
95
+	# name
96
+	config_get value "${section}" 'name'
97
+	[ -z "${value}" ] && value="{section}"
98
+
99
+	# execute command
100
+	echo "${initscript}: Waking up ${value} via ${PROGRAM}${args:+ ${args}}"
101
+	${PROGRAM} ${args}
102
+	return $?
103
+}
104
+
105
+
106
+# find first available program from searchlist
107
+search_program()
108
+{
109
+	local searchlist="$1"
110
+	local test=''
111
+	local program=''
112
+
113
+	for test in ${searchlist} ; do
114
+		[ -x "${test}" ] && {
115
+			program="${test}"
116
+			break;
117
+		}
118
+	done
119
+
120
+	[ -n "${program}" ] && echo "${program}"
121
+
122
+	return
123
+}
124
+
125
+# prepare hex password
126
+etherwake_password()
127
+{
128
+	local delimiter=':'
129
+	local password=`echo "$1" | sed "s/../&${delimiter}/g"`
130
+	echo "${password%${delimiter}}"
131
+	return
132
+}

+ 37
- 0
net/etherwake/patches/100-no_ether_hostton.patch Voir le fichier

@@ -0,0 +1,37 @@
1
+--- etherwake-1.09.orig/ether-wake.c	2005-07-10 20:44:25.000000000 +0200
2
++++ etherwake-1.09.orig.no_ether_hostton/ether-wake.c	2007-04-29 19:03:41.000000000 +0200
3
+@@ -15,7 +15,11 @@
4
+ "	an optional password appended.\n"
5
+ "\n"
6
+ "	The single required parameter is the Ethernet MAC (station) address\n"
7
++#if !defined(__UCLIBC__)
8
+ "	of the machine to wake or a host ID with known NSS 'ethers' entry.\n"
9
++#else
10
++"	of the machine to wake.\n"
11
++#endif
12
+ "	The MAC address may be found with the 'arp' program while the target\n"
13
+ "	machine is awake.\n"
14
+ "\n"
15
+@@ -289,16 +293,22 @@
16
+ 		if (debug)
17
+ 			fprintf(stderr, "The target station address is %s.\n",
18
+ 					ether_ntoa(eaddr));
19
++#if !defined(__UCLIBC__)
20
+ 	} else if (ether_hostton(hostid, eaddr) == 0) {
21
+ 		if (debug)
22
+ 			fprintf(stderr, "Station address for hostname %s is %s.\n",
23
+ 					hostid, ether_ntoa(eaddr));
24
++#endif
25
+ 	} else {
26
+ 		(void)fprintf(stderr,
27
+ 					  "ether-wake: The Magic Packet host address must be "
28
+ 					  "specified as\n"
29
++#if !defined(__UCLIBC__)
30
+ 					  "  - a station address, 00:11:22:33:44:55, or\n"
31
+ 					  "  - a hostname with a known 'ethers' entry.\n");
32
++#else
33
++					  "  - a station address, 00:11:22:33:44:55\n");
34
++#endif
35
+ 		return -1;
36
+ 	}
37
+ 	return 0;