Project

General

Profile

Download (2.28 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php-cgi -f
2
<?php
3
/*
4
 * rc.start_packages
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
8
 * All rights reserved.
9
 *
10
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13
 *
14
 * http://www.apache.org/licenses/LICENSE-2.0
15
 *
16
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21
 */
22

    
23
require_once("config.inc");
24
require_once("functions.inc");
25
require_once("filter.inc");
26
require_once("shaper.inc");
27
require_once("captiveportal.inc");
28
require_once("pkg-utils.inc");
29
require_once("pfsense-utils.inc");
30
require_once("service-utils.inc");
31

    
32
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
33
	$stat = stat("{$g['tmp_path']}/.rc.start_packages.running");
34
	if (time() - $stat['mtime'] >= 90) {
35
		@unlink("{$g['tmp_path']}/.rc.start_packages.running");
36
	} else {
37
		log_error("Skipping STARTing packages process because previous/another instance is already running");
38
		return;
39
	}
40
}
41

    
42
@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", "");
43

    
44
log_error("Restarting/Starting all packages.");
45

    
46
$rcfiles = glob(RCFILEPREFIX . "*.sh");
47
if (!$rcfiles) {
48
	$rcfiles = array();
49
} else {
50
	$rcfiles = array_flip($rcfiles);
51
	if (!$rcfiles) {
52
		$rcfiles = array();
53
	}
54
}
55

    
56
if (is_array($config['installedpackages']['package'])) {
57
	foreach ($config['installedpackages']['package'] as $pkgid => $package) {
58
		echo " Starting package {$package['name']}...";
59
		sync_package($package['name']);
60
		$internal_name = get_package_internal_name($package);
61
		start_service($internal_name);
62
		unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
63
		echo "done.\n";
64
	}
65
}
66

    
67
$shell = @popen("/bin/sh", "w");
68
if ($shell) {
69
	foreach ($rcfiles as $rcfile => $number) {
70
		echo " Starting {$rcfile}...";
71
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
72
		echo "done.\n";
73
	}
74

    
75
	pclose($shell);
76
}
77

    
78
@unlink("{$g['tmp_path']}/.rc.start_packages.running");
79
?>
(72-72/78)