Project

General

Profile

« Previous | Next » 

Revision 0ae6daf8

Added by Ermal LUÇI almost 15 years ago

Use the new events mechanisms to dispatch events.

View differences:

etc/devd.conf
30 30
#notify 0 {
31 31
#    match "type"            "LINK_DOWN";
32 32
#	media-type              "ethernet";
33
#    action "/bin/echo -n '$subsystem stop ' >>/tmp/rc.linkup";
33
#    action "/usr/local/sbin/pfSctl -c 'interface linkup stop $subsystem'";
34 34
#};
35 35

  
36 36
# When a USB keyboard arrives, attach it as the console keyboard.
......
54 54
        match "system"          "IFNET";
55 55
        match "type"            "LINK_UP";
56 56
        media-type              "ethernet";
57
        action "/bin/echo -n '$subsystem start ' >>/tmp/rc.linkup";
57
	action "/usr/local/sbin/pfSctl -c 'interface linkup start $subsystem'";
58 58
};
59 59

  
60 60
# Notify all users before beginning emergency shutdown when we get
etc/inc/filter.inc
136 136
		$mt = microtime();
137 137
		echo "filter_configure() being called $mt\n";
138 138
	}
139
	global $g;
140
	touch($g['tmp_path'] . "/filter_dirty");
139
	send_event("filter reload");
141 140
}
142 141

  
143 142
function filter_delete_states_for_down_gateways() {
etc/inc/globals.inc
58 58

  
59 59
$g = array(
60 60
	"base_packages" => "siproxd", 
61
	"event_address" => "unix:///var/run/check_reload_status",
61 62
	"factory_shipped_username" => "admin",
62 63
	"factory_shipped_password" => "pfsense",
63 64
	"upload_path" => "/root",
etc/inc/gwlb.inc
82 82

  
83 83
## These parameters can be overriden in a specific alarm configuration
84 84
alarm default { 
85
	command on "/usr/bin/touch /tmp/filter_dirty"
86
	command off "/usr/bin/touch /tmp/filter_dirty"
85
	command on "/usr/local/sbin/pfSctl -c 'filter reload'"
86
	command off "/usr/local/sbin/pfSctl -c 'filter reload'"
87 87
	combine 10s
88 88
}
89 89

  
etc/inc/interfaces.inc
848 848
					}
849 849
					unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf");
850 850
					if (isset($ppp['ondemand']) && !$destroy)
851
						file_put_contents("{$g['tmp_path']}/interface_configure", $interface);
851
						send_event("interface reconfigure {$interface}");
852 852
					break;
853 853
				}
854 854
			}
etc/inc/openvpn.inc
573 573
	/* start the new process */
574 574
	$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
575 575
	mwexec_bg("nohup openvpn --config {$fpath}");
576
	touch("{$g['tmp_path']}/filter_dirty");
576
	send_event("filter reload");
577 577
}
578 578

  
579 579
function openvpn_delete($mode, & $settings) {
etc/inc/pfsense-utils.inc
852 852
 ******/
853 853
function reload_all() {
854 854
	global $g;
855
	touch("{$g['tmp_path']}/reload_all");
855
	send_event("service reload all");
856 856
}
857 857

  
858 858
/****f* pfsense-utils/reload_interfaces
......
925 925
	conf_mount_ro();
926 926

  
927 927
	/* restart sshd */
928
	@touch("{$g['tmp_path']}/start_sshd");
928
	send_event("service restart sshd");
929 929

  
930 930
	/* restart webConfigurator if needed */
931
	touch("{$g['tmp_path']}/restart_webgui");
931
	send_event("service restart webgui");
932 932

  
933 933
	mwexec("/bin/rm {$g['tmp_path']}/reload*");
934 934
}
etc/inc/util.inc
137 137
	return;
138 138
}
139 139

  
140
function send_event($cmd) {
141
	global $g;
142

  
143
	$fd = fsockopen($g['event_address']);
144
	if ($fd) {
145
		fwrite($fd, $cmd);
146
		$resp = fread($fd, 4096);
147
		if ($resp != "OK\n")
148
			log_error("send_event: sent {$cmd} got {$resp}");
149
		fclose($fd);
150
	}
151
}
152

  
153
function send_multiple_events($cmds) {
154
        global $g;
155

  
156
	if (!is_array($cmds))
157
		return;
158
        $fd = fsockopen($g['event_address']);
159
        if ($fd) {
160
		foreach ($cmds as $cmd) {
161
                	fwrite($fd, $cmd);
162
                	$resp = fread($fd, 4096);
163
                	if ($resp != "OK\n")
164
                        	log_error("send_event: sent {$cmd} got {$resp}");
165
		}
166
                fclose($fd);
167
        }
168
}
169

  
140 170
function refcount_init($reference) {
141 171
	$shmid = shmop_open($reference, "c", 0644, 10);
142 172
	shmop_write($shmid, 0, 0);
......
1176 1206

  
1177 1207
        exec("/sbin/devd");
1178 1208
        sleep(1);
1179
        if(file_exists("{$g['tmp_path']}/rc.linkup"))
1180
                unlink("{$g['tmp_path']}/rc.linkup");
1181 1209
}
1182 1210

  
1183 1211
function is_interface_mismatch() {
......
1207 1235
/* sync carp entries to other firewalls */
1208 1236
function carp_sync_client() {
1209 1237
	global $g;
1210
	touch($g['tmp_path'] . "/filter_sync"); 
1238
	send_event("filter sync");
1211 1239
}
1212 1240

  
1213 1241
/****f* util/isAjax
etc/rc
360 360

  
361 361
# Remove stale files that have already been processed by bootup
362 362
# scripts
363
rm -f /tmp/filter_dirty
364
rm -f /tmp/rc.linkup
365 363
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null &
366 364

  
367 365
# Start ping handler every 240 seconds
etc/rc.bootup
305 305
system_dhcpleases_configure();
306 306

  
307 307
/* start dyndns service */
308
@touch("{$g['tmp_path']}/update_dyndns");
308
send_event("service reload dyndnsall");
309 309

  
310 310
/* start DHCP relay */
311 311
services_dhcrelay_configure();
etc/rc.newwanip
85 85
services_dnsupdate_process($interface);
86 86

  
87 87
/* signal dyndns update */
88
file_put_contents("{$g['tmp_path']}/update_dyndns", $interface);
88
send_event("service reload dyndns {$interface}");
89 89

  
90 90
/* reconfigure IPsec tunnels */
91 91
vpn_ipsec_force_reload();
sbin/dhclient-script
81 81

  
82 82
        echo $new_routers > /tmp/${interface}_router
83 83
	cp /var/db/${interface}_ip /tmp/rc.newwanip_oldip 2>/dev/null
84
#	echo $new_ip_address > /var/db/${interface}_ip
85

  
86
	echo $interface > /tmp/rc.newwanip
87
#	echo $new_ip_address >>  /tmp/rc.newwanip
84
	/usr/local/sbin/pfSctl -c "'interface reload $interface'"
88 85
				
89 86
}
90 87

  
......
186 183
		echo $new_domain_name >/var/etc/defaultdomain.conf
187 184
	fi
188 185

  
189
	echo $interface > /tmp/rc.newwanip
186
	/usr/local/sbin/pfSctl -c "'interface reload $interface'"
190 187

  
191 188
	return 0
192 189
}
usr/local/sbin/ovpn-linkdown
4 4
/bin/rm -f /var/etc/nameserver_$1
5 5
/bin/rm -f /tmp/$1_router
6 6
/bin/rm -f /tmp/$1up
7
/usr/bin/touch /tmp/filter_dirty
7
/usr/local/sbin/pfSctl -c 'filter reload'
usr/local/sbin/ovpn-linkup
3 3
# write nameservers to file needs dns fidnings?!
4 4

  
5 5
# let the configuration system know that the ip has changed.
6
#/bin/echo $1 > /tmp/rc.newwanip
6
#/usr/local/sbin/pfSctl -c "'interface reload $interface'"
7 7
/bin/echo $4 > /tmp/$1_router
8 8
/usr/bin/touch /tmp/$1up
9 9
# reload filter 
10
/usr/bin/touch /tmp/filter_dirty
10
/usr/local/sbin/pfSctl -c 'filter reload'
11 11
exit 0
usr/local/sbin/ppp-linkdown
10 10
# Do not remove gateway used during filter reload.
11 11
# /bin/rm -f /tmp/$1_router
12 12
/bin/rm -f /tmp/$1up
13
/usr/bin/touch /tmp/resolv_conf_generate
13
/usr/local/sbin/pfSctl -c 'service reload dns'
usr/local/sbin/ppp-linkup
14 14
fi
15 15

  
16 16
# let the configuration system know that the ip has changed.
17
/bin/echo $1 > /tmp/rc.newwanip
17
/usr/local/sbin/pfSctl -c "'interface reload $1'"
18 18
/bin/echo $4 > /tmp/$1_router
19 19
/usr/bin/touch /tmp/$1up
20 20
exit 0
usr/local/www/system_advanced_admin.php
461 461

  
462 462
	if ($config['system']['enablesshd']) {
463 463
		log_error(gettext("secure shell configuration has changed. Restarting sshd."));
464
		touch("{$g['tmp_path']}/start_sshd");
464
		send_event("service restart sshd");
465 465
	}
466 466
}
467 467
if ($restart_webgui) {

Also available in: Unified diff