summaryrefslogtreecommitdiffstats
path: root/net/netifyd/files/netifyd.init
blob: 1f7d9311a280477f3401e0e3600f0933fc02be7d (plain)
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
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2016-2019 eGloo, Incorporated
#
# This is free software, licensed under the GNU General Public License v2.

START=50
STOP=50

USE_PROCD=1
PROG=/usr/sbin/netifyd

start_netifyd() {
	local instance enabled autoconfig internal_if external_if

	instance="$1"

	config_get_bool enabled "$instance" enabled 0
	[ "$enabled" -eq 0 ] && return 0

	[ ! -d /var/run/netifyd ] && mkdir -p /var/run/netifyd

	config_get_bool autoconfig "$instance" autoconfig 1

	if [ "$autoconfig" -gt 0 ] ; then
		source /usr/share/netifyd/functions.sh
		load_modules
		NETIFYD_AUTODETECT=yes
		NETIFYD_OPTS=$(auto_detect_options)
	else
		config_get internal_if "$instance" internal_if "eth0"
		config_get external_if "$instance" external_if "eth1"
		NETIFYD_OPTS="-E $external_if -I $internal_if"
	fi

	procd_open_instance
	procd_set_param command $PROG -R $NETIFYD_OPTS
	procd_set_param file /etc/netifyd.conf
	procd_set_param respawn
	procd_close_instance
}

start_service() {
	config_load netifyd
	config_foreach start_netifyd netifyd
}