mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 23:18:42 +01:00
etherwake-nfqueue: Add package etherwake-nfqueue
Signed-off-by: Mister Benjamin <144dbspl@gmail.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
config etherwake-nfqueue 'setup'
|
||||
option sudo 'off'
|
||||
option debug 'off'
|
||||
|
||||
# You can add targets with uci:
|
||||
# # uci add etherwake-nfqueue target
|
||||
# Set a name for the target
|
||||
# # uci set etherwake-nfqueue.@target[-1].name=example
|
||||
# Set MAC address of the host to wake up
|
||||
# # uci set etherwake-nfqueue.@target[-1].mac=00:22:44:66:88:aa
|
||||
# Set the nfqueue num used for receiving filtered packets, defaults to 0
|
||||
# # uci set etherwake-nfqueue.@target[-1].nfqueue_num=0
|
||||
# Set the interface used for sending the magic packet, defaults to 'eth0'
|
||||
# # uci set etherwake-nfqueue.@target[-1].interface=eth0
|
||||
# Configure if it should be sent to broadcast address, defaults to off
|
||||
# # uci set etherwake-nfqueue.@target[-1].broadcast=off
|
||||
# Optionally provide a password (required by some adapters)
|
||||
# e.g. 00:22:44:66:88:aa or 192.168.1.1
|
||||
# # uci set etherwake-nfqueue.@target[-1].password=00:22:44:66:88:aa
|
||||
# Optionally disable the target, by default it is enabled
|
||||
# # uci set etherwake-nfqueue.@target[-1].enabled=false
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2019 Mister Benjamin <144dbspl@gmail.com>
|
||||
|
||||
NAME='etherwake-nfqueue'
|
||||
|
||||
START=60
|
||||
USE_PROCD=1
|
||||
|
||||
PROGRAM=${NAME}
|
||||
|
||||
start_service()
|
||||
{
|
||||
local value
|
||||
|
||||
config_load ${NAME}
|
||||
|
||||
config_get_bool value setup sudo 0
|
||||
[ "${value}" -ne 0 ] && PROGRAM="sudo ${PROGRAM}"
|
||||
|
||||
config_get_bool value setup debug 0
|
||||
if [ "${value}" -ne 0 ]; then
|
||||
PROCD_DEBUG=1
|
||||
append PROGRAM '-D'
|
||||
fi
|
||||
|
||||
config_foreach start_instance target
|
||||
}
|
||||
|
||||
start_instance()
|
||||
{
|
||||
local section="$1"
|
||||
local value name mac
|
||||
|
||||
config_get_bool value "${section}" enabled 1
|
||||
[ "${value}" -ne 1 ] && return 0
|
||||
|
||||
config_get value "${section}" name
|
||||
[ -z "${value}" ] && value="{section}"
|
||||
name=${value}
|
||||
|
||||
config_get mac "${section}" mac
|
||||
[ -z "${mac}" ] && {
|
||||
echo "${initscript}: Target ${name} has no MAC address"
|
||||
return 1
|
||||
}
|
||||
|
||||
procd_open_instance ${name}
|
||||
procd_set_param command ${PROGRAM}
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
config_get_bool value "${section}" broadcast 0
|
||||
[ "${value}" -ne 0 ] && procd_append_param command -b
|
||||
|
||||
config_get value "${section}" interface
|
||||
[ -n "${value}" ] && procd_append_param command -i "${value}"
|
||||
|
||||
config_get value "${section}" password
|
||||
[ -n "${value}" ] && procd_append_param command -p "${value}"
|
||||
|
||||
config_get value "${section}" nfqueue_num 0
|
||||
procd_append_param command -q "${value}"
|
||||
|
||||
procd_append_param command "${mac}"
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
Reference in New Issue
Block a user