mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Use the new events mechanisms to dispatch events.
This commit is contained in:
parent
298e5e0ab9
commit
0ae6daf834
@ -30,7 +30,7 @@ notify 100 {
|
||||
#notify 0 {
|
||||
# match "type" "LINK_DOWN";
|
||||
# media-type "ethernet";
|
||||
# action "/bin/echo -n '$subsystem stop ' >>/tmp/rc.linkup";
|
||||
# action "/usr/local/sbin/pfSctl -c 'interface linkup stop $subsystem'";
|
||||
#};
|
||||
|
||||
# When a USB keyboard arrives, attach it as the console keyboard.
|
||||
@ -54,7 +54,7 @@ notify 0 {
|
||||
match "system" "IFNET";
|
||||
match "type" "LINK_UP";
|
||||
media-type "ethernet";
|
||||
action "/bin/echo -n '$subsystem start ' >>/tmp/rc.linkup";
|
||||
action "/usr/local/sbin/pfSctl -c 'interface linkup start $subsystem'";
|
||||
};
|
||||
|
||||
# Notify all users before beginning emergency shutdown when we get
|
||||
|
||||
@ -136,8 +136,7 @@ function filter_configure() {
|
||||
$mt = microtime();
|
||||
echo "filter_configure() being called $mt\n";
|
||||
}
|
||||
global $g;
|
||||
touch($g['tmp_path'] . "/filter_dirty");
|
||||
send_event("filter reload");
|
||||
}
|
||||
|
||||
function filter_delete_states_for_down_gateways() {
|
||||
|
||||
@ -58,6 +58,7 @@ function get_nics_with_capabilities($CAPABILITIES) {
|
||||
|
||||
$g = array(
|
||||
"base_packages" => "siproxd",
|
||||
"event_address" => "unix:///var/run/check_reload_status",
|
||||
"factory_shipped_username" => "admin",
|
||||
"factory_shipped_password" => "pfsense",
|
||||
"upload_path" => "/root",
|
||||
|
||||
@ -82,8 +82,8 @@ rrd interval 60s;
|
||||
|
||||
## These parameters can be overriden in a specific alarm configuration
|
||||
alarm default {
|
||||
command on "/usr/bin/touch /tmp/filter_dirty"
|
||||
command off "/usr/bin/touch /tmp/filter_dirty"
|
||||
command on "/usr/local/sbin/pfSctl -c 'filter reload'"
|
||||
command off "/usr/local/sbin/pfSctl -c 'filter reload'"
|
||||
combine 10s
|
||||
}
|
||||
|
||||
|
||||
@ -848,7 +848,7 @@ function interface_bring_down($interface = "wan", $destroy = false) {
|
||||
}
|
||||
unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf");
|
||||
if (isset($ppp['ondemand']) && !$destroy)
|
||||
file_put_contents("{$g['tmp_path']}/interface_configure", $interface);
|
||||
send_event("interface reconfigure {$interface}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ function openvpn_restart($mode, & $settings) {
|
||||
/* start the new process */
|
||||
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
|
||||
mwexec_bg("nohup openvpn --config {$fpath}");
|
||||
touch("{$g['tmp_path']}/filter_dirty");
|
||||
send_event("filter reload");
|
||||
}
|
||||
|
||||
function openvpn_delete($mode, & $settings) {
|
||||
|
||||
@ -852,7 +852,7 @@ function reload_interfaces_sync() {
|
||||
******/
|
||||
function reload_all() {
|
||||
global $g;
|
||||
touch("{$g['tmp_path']}/reload_all");
|
||||
send_event("service reload all");
|
||||
}
|
||||
|
||||
/****f* pfsense-utils/reload_interfaces
|
||||
@ -925,10 +925,10 @@ function reload_all_sync() {
|
||||
conf_mount_ro();
|
||||
|
||||
/* restart sshd */
|
||||
@touch("{$g['tmp_path']}/start_sshd");
|
||||
send_event("service restart sshd");
|
||||
|
||||
/* restart webConfigurator if needed */
|
||||
touch("{$g['tmp_path']}/restart_webgui");
|
||||
send_event("service restart webgui");
|
||||
|
||||
mwexec("/bin/rm {$g['tmp_path']}/reload*");
|
||||
}
|
||||
|
||||
@ -137,6 +137,36 @@ function unlock($cfglckkey = 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
function send_event($cmd) {
|
||||
global $g;
|
||||
|
||||
$fd = fsockopen($g['event_address']);
|
||||
if ($fd) {
|
||||
fwrite($fd, $cmd);
|
||||
$resp = fread($fd, 4096);
|
||||
if ($resp != "OK\n")
|
||||
log_error("send_event: sent {$cmd} got {$resp}");
|
||||
fclose($fd);
|
||||
}
|
||||
}
|
||||
|
||||
function send_multiple_events($cmds) {
|
||||
global $g;
|
||||
|
||||
if (!is_array($cmds))
|
||||
return;
|
||||
$fd = fsockopen($g['event_address']);
|
||||
if ($fd) {
|
||||
foreach ($cmds as $cmd) {
|
||||
fwrite($fd, $cmd);
|
||||
$resp = fread($fd, 4096);
|
||||
if ($resp != "OK\n")
|
||||
log_error("send_event: sent {$cmd} got {$resp}");
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
}
|
||||
|
||||
function refcount_init($reference) {
|
||||
$shmid = shmop_open($reference, "c", 0644, 10);
|
||||
shmop_write($shmid, 0, 0);
|
||||
@ -1176,8 +1206,6 @@ function start_devd() {
|
||||
|
||||
exec("/sbin/devd");
|
||||
sleep(1);
|
||||
if(file_exists("{$g['tmp_path']}/rc.linkup"))
|
||||
unlink("{$g['tmp_path']}/rc.linkup");
|
||||
}
|
||||
|
||||
function is_interface_mismatch() {
|
||||
@ -1207,7 +1235,7 @@ function is_interface_mismatch() {
|
||||
/* sync carp entries to other firewalls */
|
||||
function carp_sync_client() {
|
||||
global $g;
|
||||
touch($g['tmp_path'] . "/filter_sync");
|
||||
send_event("filter sync");
|
||||
}
|
||||
|
||||
/****f* util/isAjax
|
||||
|
||||
2
etc/rc
2
etc/rc
@ -360,8 +360,6 @@ rm -rf /usr/local/pkg/pf/CVS
|
||||
|
||||
# Remove stale files that have already been processed by bootup
|
||||
# scripts
|
||||
rm -f /tmp/filter_dirty
|
||||
rm -f /tmp/rc.linkup
|
||||
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null &
|
||||
|
||||
# Start ping handler every 240 seconds
|
||||
|
||||
@ -305,7 +305,7 @@ services_dnsmasq_configure();
|
||||
system_dhcpleases_configure();
|
||||
|
||||
/* start dyndns service */
|
||||
@touch("{$g['tmp_path']}/update_dyndns");
|
||||
send_event("service reload dyndnsall");
|
||||
|
||||
/* start DHCP relay */
|
||||
services_dhcrelay_configure();
|
||||
|
||||
@ -85,7 +85,7 @@ if (is_ipaddr($oldip) && $curwanip == $oldip)
|
||||
services_dnsupdate_process($interface);
|
||||
|
||||
/* signal dyndns update */
|
||||
file_put_contents("{$g['tmp_path']}/update_dyndns", $interface);
|
||||
send_event("service reload dyndns {$interface}");
|
||||
|
||||
/* reconfigure IPsec tunnels */
|
||||
vpn_ipsec_force_reload();
|
||||
|
||||
@ -81,10 +81,7 @@ add_new_address() {
|
||||
|
||||
echo $new_routers > /tmp/${interface}_router
|
||||
cp /var/db/${interface}_ip /tmp/rc.newwanip_oldip 2>/dev/null
|
||||
# echo $new_ip_address > /var/db/${interface}_ip
|
||||
|
||||
echo $interface > /tmp/rc.newwanip
|
||||
# echo $new_ip_address >> /tmp/rc.newwanip
|
||||
/usr/local/sbin/pfSctl -c "'interface reload $interface'"
|
||||
|
||||
}
|
||||
|
||||
@ -186,7 +183,7 @@ add_new_resolv_conf() {
|
||||
echo $new_domain_name >/var/etc/defaultdomain.conf
|
||||
fi
|
||||
|
||||
echo $interface > /tmp/rc.newwanip
|
||||
/usr/local/sbin/pfSctl -c "'interface reload $interface'"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -4,4 +4,4 @@
|
||||
/bin/rm -f /var/etc/nameserver_$1
|
||||
/bin/rm -f /tmp/$1_router
|
||||
/bin/rm -f /tmp/$1up
|
||||
/usr/bin/touch /tmp/filter_dirty
|
||||
/usr/local/sbin/pfSctl -c 'filter reload'
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
# write nameservers to file needs dns fidnings?!
|
||||
|
||||
# let the configuration system know that the ip has changed.
|
||||
#/bin/echo $1 > /tmp/rc.newwanip
|
||||
#/usr/local/sbin/pfSctl -c "'interface reload $interface'"
|
||||
/bin/echo $4 > /tmp/$1_router
|
||||
/usr/bin/touch /tmp/$1up
|
||||
# reload filter
|
||||
/usr/bin/touch /tmp/filter_dirty
|
||||
/usr/local/sbin/pfSctl -c 'filter reload'
|
||||
exit 0
|
||||
|
||||
@ -10,4 +10,4 @@ fi
|
||||
# Do not remove gateway used during filter reload.
|
||||
# /bin/rm -f /tmp/$1_router
|
||||
/bin/rm -f /tmp/$1up
|
||||
/usr/bin/touch /tmp/resolv_conf_generate
|
||||
/usr/local/sbin/pfSctl -c 'service reload dns'
|
||||
|
||||
@ -14,7 +14,7 @@ if [ $8 = "dns2" ]; then
|
||||
fi
|
||||
|
||||
# let the configuration system know that the ip has changed.
|
||||
/bin/echo $1 > /tmp/rc.newwanip
|
||||
/usr/local/sbin/pfSctl -c "'interface reload $1'"
|
||||
/bin/echo $4 > /tmp/$1_router
|
||||
/usr/bin/touch /tmp/$1up
|
||||
exit 0
|
||||
|
||||
@ -461,7 +461,7 @@ if ($restart_sshd) {
|
||||
|
||||
if ($config['system']['enablesshd']) {
|
||||
log_error(gettext("secure shell configuration has changed. Restarting sshd."));
|
||||
touch("{$g['tmp_path']}/start_sshd");
|
||||
send_event("service restart sshd");
|
||||
}
|
||||
}
|
||||
if ($restart_webgui) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user