Revision 1098cb94
Added by Viktor Gurov over 3 years ago
src/etc/inc/services.inc | ||
---|---|---|
1920 | 1920 |
return 0; |
1921 | 1921 |
} |
1922 | 1922 |
|
1923 |
function services_igmpproxy_configure() { |
|
1923 |
function services_igmpproxy_configure($interface='') {
|
|
1924 | 1924 |
global $config, $g; |
1925 | 1925 |
|
1926 |
/* kill any running igmpproxy */ |
|
1927 |
killbyname("igmpproxy"); |
|
1926 |
if (!empty($interface) && is_array($config['igmpproxy']['igmpentry'])) { |
|
1927 |
foreach ($config['igmpproxy']['igmpentry'] as $igmpentry) { |
|
1928 |
if ($igmpentry['ifname'] == $interface) { |
|
1929 |
$igmpinf = true; |
|
1930 |
break; |
|
1931 |
} |
|
1932 |
} |
|
1933 |
if (!$igmpinf) { |
|
1934 |
return false; |
|
1935 |
} |
|
1936 |
} |
|
1928 | 1937 |
|
1929 | 1938 |
if (!isset($config['igmpproxy']['enable'])) { |
1930 |
return 0; |
|
1939 |
if (isvalidproc("igmpproxy")) { |
|
1940 |
log_error(gettext("Stopping IGMP Proxy service.")); |
|
1941 |
killbyname("igmpproxy"); |
|
1942 |
} |
|
1943 |
return true; |
|
1931 | 1944 |
} |
1932 | 1945 |
if (!is_array($config['igmpproxy']['igmpentry']) || (count($config['igmpproxy']['igmpentry']) == 0)) { |
1933 |
return 1; |
|
1946 |
return false; |
|
1947 |
} |
|
1948 |
|
|
1949 |
if (platform_booting()) { |
|
1950 |
echo gettext("Starting IGMP Proxy service..."); |
|
1951 |
} |
|
1952 |
|
|
1953 |
if (isvalidproc("igmpproxy")) { |
|
1954 |
log_error(gettext("Restarting IGMP Proxy service.")); |
|
1955 |
killbyname("igmpproxy"); |
|
1934 | 1956 |
} |
1935 | 1957 |
|
1936 | 1958 |
$iflist = get_configured_interface_list(); |
... | ... | |
1945 | 1967 |
EOD; |
1946 | 1968 |
|
1947 | 1969 |
foreach ($config['igmpproxy']['igmpentry'] as $igmpcf) { |
1970 |
if (empty($config['interfaces'][$igmpcf['ifname']]['ipaddr'])) { |
|
1971 |
continue; |
|
1972 |
} |
|
1948 | 1973 |
unset($iflist[$igmpcf['ifname']]); |
1949 | 1974 |
$realif = get_real_interface($igmpcf['ifname']); |
1950 | 1975 |
if (empty($igmpcf['threshold'])) { |
... | ... | |
1961 | 1986 |
} |
1962 | 1987 |
} |
1963 | 1988 |
$igmpconf .= "\n"; |
1989 |
if ($igmpcf['type'] == 'upstream') { |
|
1990 |
$upstream = true; |
|
1991 |
} else { |
|
1992 |
$downstream = true; |
|
1993 |
} |
|
1964 | 1994 |
} |
1965 | 1995 |
foreach ($iflist as $ifn) { |
1966 | 1996 |
$realif = get_real_interface($ifn); |
... | ... | |
1968 | 1998 |
} |
1969 | 1999 |
$igmpconf .= "\n"; |
1970 | 2000 |
|
2001 |
if (!$upstream || !$downstream) { |
|
2002 |
log_error(gettext("Could not find upstream or downstream IGMP Proxy interfaces!")); |
|
2003 |
return; |
|
2004 |
} |
|
2005 |
|
|
1971 | 2006 |
$igmpfl = fopen($g['varetc_path'] . "/igmpproxy.conf", "w"); |
1972 | 2007 |
if (!$igmpfl) { |
1973 |
log_error(gettext("Could not write Igmpproxy configuration file!"));
|
|
2008 |
log_error(gettext("Could not write IGMP Proxy configuration file!"));
|
|
1974 | 2009 |
return; |
1975 | 2010 |
} |
1976 | 2011 |
fwrite($igmpfl, $igmpconf); |
... | ... | |
1983 | 2018 |
mwexec_bg("/usr/local/sbin/igmpproxy {$g['varetc_path']}/igmpproxy.conf"); |
1984 | 2019 |
} |
1985 | 2020 |
|
1986 |
log_error(gettext("Started IGMP proxy service."));
|
|
2021 |
log_error(gettext("Started IGMP Proxy service."));
|
|
1987 | 2022 |
|
1988 |
return 0; |
|
2023 |
if (platform_booting()) { |
|
2024 |
echo gettext("done.") . "\n"; |
|
2025 |
} |
|
2026 |
|
|
2027 |
return true; |
|
1989 | 2028 |
} |
1990 | 2029 |
|
1991 | 2030 |
function services_dhcrelay_configure() { |
Also available in: Unified diff
IGMP Proxy service improvements. Fixes #12609