Project

General

Profile

« Previous | Next » 

Revision a9488104

Added by Jim Pingle over 12 years ago

Bring in the RCFILEPREFIX as constant fixes from HEAD, since otherwise rc.stop_packages was globbing in the wrong dir and executing the wrong scripts. Also seems to have fixed the "bad fd" error.

View differences:

etc/inc/service-utils.inc
38 38
	pfSense_MODULE:	utils
39 39
*/
40 40

  
41
$rcfileprefix = "/usr/local/etc/rc.d/";
41
define("RCFILEPREFIX", "/usr/local/etc/rc.d/");
42 42
function write_rcfile($params) {
43 43
	global $g;
44
	global $rcfileprefix;
45 44

  
46
	if (!file_exists("{$rcfileprefix}{$params['file']}") && !touch("{$rcfileprefix}{$params['file']}"))
45
	$rcfile_fullname = RCFILEPREFIX . $params['file'];
46
	if (!file_exists($rcfile_fullname) && !touch($rcfile_fullname))
47 47
		return false;
48 48

  
49
	if (!is_writable("{$rcfileprefix}{$params['file']}") || empty($params['start']))
49
	if (!is_writable($rcfile_fullname) || empty($params['start']))
50 50
		return false;
51 51

  
52 52
	$towrite = "#!/bin/sh\n";
......
72 72
	/* begin rcfile logic */
73 73
	$towrite .= "case \$1 in\n\tstart)\n\t\trc_start\n\t\t;;\n\tstop)\n\t\trc_stop\n\t\t;;\n\trestart)\n\t\trc_stop\n\t\trc_start\n\t\t;;\nesac\n\n";
74 74

  
75
	file_put_contents("{$rcfileprefix}{$params['file']}", $towrite);
76
	@chmod("{$rcfileprefix}{$params['file']}", 0755);
75
	file_put_contents($rcfile_fullname, $towrite);
76
	@chmod("{$rcfile_fullname}", 0755);
77 77

  
78 78
	return;
79 79
}
80 80

  
81 81
function start_service($name) {
82 82
	global $config;
83
	global $rcfileprefix;
84 83

  
85 84
	if (empty($name))
86 85
		return;
......
89 88
	stop_service($name);
90 89
	sleep(2);
91 90

  
92
	if(file_exists("{$rcfileprefix}{$name}.sh")) {
93
		mwexec_bg("/bin/sh {$rcfileprefix}{$name}.sh start");
91
	$rcfile_fullname = RCFILEPREFIX . $name . '.sh';
92
	if(file_exists($rcfile_fullname)) {
93
		mwexec_bg("/bin/sh {$rcfile_fullname} start");
94 94
		return;
95 95
	}
96 96
	if($config['installedpackages']['service']) {
97 97
		foreach($config['installedpackages']['service'] as $service) {
98 98
			if(strtolower($service['name']) == strtolower($name)) {
99 99
				if($service['rcfile']) {
100
					$prefix = $rcfileprefix;
100
					$prefix = RCFILEPREFIX;
101 101
					if (!empty($service['prefix'])) {
102 102
						$prefix =& $service['prefix'];
103 103
					}
......
115 115

  
116 116
function stop_service($name) {
117 117
	global $config;
118
	global $rcfileprefix;
119 118

  
120 119
	if (empty($name))
121 120
		return;
......
124 123
		foreach($config['installedpackages']['service'] as $service) {
125 124
			if(strtolower($service['name']) == strtolower($name)) {
126 125
				if($service['rcfile']) {
127
					$prefix = $rcfileprefix;
126
					$prefix = RCFILEPREFIX;
128 127
					if(!empty($service['prefix'])) {
129 128
						$prefix =& $service['prefix'];
130 129
					}

Also available in: Unified diff