Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lede-mikrotik
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Rudolph
lede-mikrotik
Commits
8a790d97
Commit
8a790d97
authored
12 years ago
by
Felix Fietkau
Browse files
Options
Downloads
Patches
Plain Diff
relayd: use an init script instead of a legacy network proto handler (fixes #11276)
SVN-Revision: 31542
parent
cbfce538
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
package/relayd/Makefile
+2
-2
2 additions, 2 deletions
package/relayd/Makefile
package/relayd/files/relay.hotplug
+1
-35
1 addition, 35 deletions
package/relayd/files/relay.hotplug
package/relayd/files/relay.init
+97
-0
97 additions, 0 deletions
package/relayd/files/relay.init
with
100 additions
and
37 deletions
package/relayd/Makefile
+
2
−
2
View file @
8a790d97
...
@@ -35,8 +35,8 @@ define Package/relayd/install
...
@@ -35,8 +35,8 @@ define Package/relayd/install
$(INSTALL_BIN)
$(PKG_BUILD_DIR)/relayd
$(1)/usr/sbin/relayd
$(INSTALL_BIN)
$(PKG_BUILD_DIR)/relayd
$(1)/usr/sbin/relayd
$(INSTALL_DIR)
$(1)/etc/hotplug.d/iface
$(INSTALL_DIR)
$(1)/etc/hotplug.d/iface
$(INSTALL_DATA)
./files/relay.hotplug
$(1)/etc/hotplug.d/iface/30-relay
$(INSTALL_DATA)
./files/relay.hotplug
$(1)/etc/hotplug.d/iface/30-relay
$(INSTALL_DIR)
$(1)/
lib/network
$(INSTALL_DIR)
$(1)/
etc/init.d
$(INSTALL_
DATA
)
./files/relay.
sh
$(1)/
lib/network
/relay
.sh
$(INSTALL_
BIN
)
./files/relay.
init
$(1)/
etc/init.d
/relay
d
endef
endef
$(
eval
$(
call BuildPackage,relayd
))
$(
eval
$(
call BuildPackage,relayd
))
This diff is collapsed.
Click to expand it.
package/relayd/files/relay.hotplug
+
1
−
35
View file @
8a790d97
#!/bin/sh
#!/bin/sh
/etc/init.d/relayd enabled
&&
/etc/init.d/relayd start
# Break recursion
[
"
$PROTO
"
=
"relay"
]
&&
exit
0
include /lib/network
scan_interfaces
restart_relayd
()
{
local
cfg
=
"
$1
"
local
proto
config_get proto
"
$1
"
proto
[
"
$proto
"
=
"relay"
]
||
return
0
local
net networks
config_get networks
"
$cfg
"
network
for
net
in
$networks
;
do
[
"
$net
"
=
"
$INTERFACE
"
]
&&
{
env
-i
/sbin/ifup
"
$cfg
"
&
return
0
}
done
local
ifn ifnames
config_get ifnames
"
$cfg
"
ifname
for
ifn
in
$ifnames
;
do
[
"
$ifn
"
=
"
$DEVICE
"
]
&&
{
env
-i
/sbin/ifup
"
$cfg
"
&
return
0
}
done
}
config_foreach restart_relayd interface
This diff is collapsed.
Click to expand it.
package/relayd/files/relay.
sh
→
package/relayd/files/relay.
init
+
97
−
0
View file @
8a790d97
#
relay.sh - Abstract relayd protocol backend
#
!/bin/sh /etc/rc.common
# Copyright (c) 2011 OpenWrt.org
# Copyright (c) 2011
-2012
OpenWrt.org
START
=
80
# Hook into scan_interfaces() to synthesize a .device option
# This is needed for /sbin/ifup to properly dispatch control
resolve_ifname
()
{
# to setup_interface_relay() even if no .ifname is set in
grep
-qs
"^ *
$1
:"
/proc/net/dev
&&
{
# the configuration.
append args
"-I
$1
"
scan_relay
()
{
append ifaces
"
$1
"
config_set
"
$1
"
device
"relay-
$1
"
}
}
}
# No coldplugging needed, relayd will be restarted if one of
resolve_network
()
{
# the member interfaces goes up or down
local
ifn
#coldplug_interface_relay() {
config_get ifn
"
$1
"
ifname
# setup_interface_relay "relay-$1" "$1"
[
-z
"
$ifn
"
]
&&
return
1
#}
resolve_ifname
"
$ifn
"
return
0
}
setup_interface_relay
()
{
start_relay
()
{
local
iface
=
"
$1
"
local
cfg
=
"
$1
"
local
cfg
=
"
$2
"
local link
=
"relay-
$cfg
"
local
args
=
""
local
args
=
""
local
ifaces
=
""
local
ifaces
=
""
resolve_ifname
()
{
config_get proto
"
$cfg
"
proto
grep
-qs
"^ *
$1
:"
/proc/net/dev
&&
{
[[
"
$proto
"
==
relay
]]
||
return
0
append args
"-I
$1
"
append ifaces
"
$1
"
SERVICE_DAEMONIZE
=
1
}
SERVICE_WRITE_PID
=
1
}
SERVICE_PID_FILE
=
"/var/run/relay-
$cfg
.pid"
[
-f
"
$SERVICE_PID_FILE
"
]
&&
{
resolve_network
()
{
if
grep
-q
relayd
"/proc/
$(
cat
$SERVICE_PID_FILE
)
/cmdline"
;
then
local
ifn
return
0
config_get ifn
"
$1
"
ifname
else
resolve_ifname
"
$ifn
"
rm
-f
"
$SERVICE_PID_FILE
"
fi
}
}
local
net networks
local
net networks
config_get networks
"
$cfg
"
network
config_get networks
"
$cfg
"
network
for
net
in
$networks
;
do
for
net
in
$networks
;
do
resolve_network
"
$net
"
resolve_network
"
$net
"
||
{
return
1
}
done
done
local
ifn ifnames
local
ifn ifnames
...
@@ -76,25 +79,19 @@ setup_interface_relay() {
...
@@ -76,25 +79,19 @@ setup_interface_relay() {
config_get_bool fwd_dhcp
"
$cfg
"
forward_dhcp 1
config_get_bool fwd_dhcp
"
$cfg
"
forward_dhcp 1
[
$fwd_dhcp
-eq
1
]
&&
append args
"-D"
[
$fwd_dhcp
-eq
1
]
&&
append args
"-D"
SERVICE_DAEMONIZE
=
1
\
SERVICE_WRITE_PID
=
1
\
SERVICE_PID_FILE
=
"/var/run/
$link
.pid"
\
service_start /usr/sbin/relayd
$args
service_start /usr/sbin/relayd
$args
uci_set_state network
"
$cfg
"
device
"
$ifaces
"
env
-i
ACTION
=
"ifup"
DEVICE
=
"
$link
"
INTERFACE
=
"
$cfg
"
PROTO
=
"relay"
\
/sbin/hotplug-call iface
}
}
stop_interface_relay
()
{
stop
()
{
local
cfg
=
"
$1
"
for
pid
in
/var/run/relay-
*
.pid
;
do
local link
=
"relay-
$cfg
"
SERVICE_PID_FILE
=
"
$pid
"
service_stop /usr/sbin/relayd
env
-i
ACTION
=
"ifdown"
DEVICE
=
"
$link
"
INTERFACE
=
"
$cfg
"
PROTO
=
"relay"
\
rm
-f
"
$SERVICE_PID_FILE
"
/sbin/hotplug-call iface
done
SERVICE_PID_FILE
=
"/var/run/
$link
.pid"
\
service_stop /usr/sbin/relayd
}
}
start
()
{
include /lib/network
scan_interfaces
config_foreach start_relay interface
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment