Project

General

Profile

Download (2.51 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-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
10
 * All rights reserved.
11
 *
12
 * Licensed under the Apache License, Version 2.0 (the "License");
13
 * you may not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15
 *
16
 * http://www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an "AS IS" BASIS,
20
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23
 */
24

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

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

    
45
if (file_exists("{$g['conf_path']}/needs_package_sync")) {
46
	log_error("Skipping STARTing packages process because package reinstallation is pending.");
47
	return;
48
}
49

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

    
52
log_error("Restarting/Starting all packages.");
53

    
54
$rcfiles = glob(RCFILEPREFIX . "*.sh");
55
if (!$rcfiles) {
56
	$rcfiles = array();
57
} else {
58
	$rcfiles = array_flip($rcfiles);
59
	if (!$rcfiles) {
60
		$rcfiles = array();
61
	}
62
}
63

    
64
foreach (config_get_path('installedpackages/package', []) as $pkgid => $package) {
65
	echo " Starting package {$package['name']}...";
66
	sync_package($package['name']);
67
	$internal_name = get_package_internal_name($package);
68
	start_service($internal_name, true);
69
	unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
70
	echo "done.\n";
71
}
72

    
73
$shell = @popen("/bin/sh", "w");
74
if ($shell) {
75
	foreach ($rcfiles as $rcfile => $number) {
76
		echo " Starting {$rcfile}...";
77
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
78
		echo "done.\n";
79
	}
80

    
81
	pclose($shell);
82
}
83

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