Project

General

Profile

Download (2.54 KB) Statistics
| Branch: | Tag: | Revision:
1 cb7d18d5 Renato Botelho
#!/usr/local/bin/php-cgi -f
2 aed6fc72 Ermal
<?php
3
/*
4 ac24dc24 Renato Botelho
 * rc.start_packages
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9 8f2f85c3 Luiz Otavio O Souza
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
10 ac24dc24 Renato Botelho
 * All rights reserved.
11
 *
12 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 *
16 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
17 ac24dc24 Renato Botelho
 *
18 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 */
24 969d7f5e Scott Ullrich
25 aed6fc72 Ermal
require_once("config.inc");
26
require_once("functions.inc");
27
require_once("filter.inc");
28
require_once("shaper.inc");
29
require_once("captiveportal.inc");
30
require_once("pkg-utils.inc");
31
require_once("pfsense-utils.inc");
32 6c19757e Ermal
require_once("service-utils.inc");
33 aed6fc72 Ermal
34 5987261f Ermal LUÇI
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
35 6990ad35 Phil Davis
	$stat = stat("{$g['tmp_path']}/.rc.start_packages.running");
36
	if (time() - $stat['mtime'] >= 90) {
37
		@unlink("{$g['tmp_path']}/.rc.start_packages.running");
38
	} else {
39
		log_error("Skipping STARTing packages process because previous/another instance is already running");
40
		return;
41
	}
42 5987261f Ermal LUÇI
}
43
44 84963037 jim-p
if (file_exists("{$g['conf_path']}/needs_package_sync")) {
45
	log_error("Skipping STARTing packages process because package reinstallation is pending.");
46
	return;
47
}
48
49 5987261f Ermal LUÇI
@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", "");
50
51 f1dbcf47 Ermal
log_error("Restarting/Starting all packages.");
52 aed6fc72 Ermal
53 dd9e0bdb phildd
$rcfiles = glob(RCFILEPREFIX . "*.sh");
54 e173dd74 Phil Davis
if (!$rcfiles) {
55 6c19757e Ermal
	$rcfiles = array();
56 e173dd74 Phil Davis
} else {
57 6c19757e Ermal
	$rcfiles = array_flip($rcfiles);
58 e173dd74 Phil Davis
	if (!$rcfiles) {
59 6c19757e Ermal
		$rcfiles = array();
60 e173dd74 Phil Davis
	}
61 6c19757e Ermal
}
62
63
if (is_array($config['installedpackages']['package'])) {
64 e173dd74 Phil Davis
	foreach ($config['installedpackages']['package'] as $pkgid => $package) {
65 6c19757e Ermal
		echo " Starting package {$package['name']}...";
66 a0d4336f Renato Botelho
		sync_package($package['name']);
67 af5d93f6 Renato Botelho
		$internal_name = get_package_internal_name($package);
68 5d4f4900 jim-p
		start_service($internal_name, true);
69 e205bdb7 Phil Davis
		unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
70 6c19757e Ermal
		echo "done.\n";
71
	}
72
}
73
74
$shell = @popen("/bin/sh", "w");
75
if ($shell) {
76 dfa6deda jim-p
	foreach ($rcfiles as $rcfile => $number) {
77 6c19757e Ermal
		echo " Starting {$rcfile}...";
78
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
79
		echo "done.\n";
80
	}
81
82
	pclose($shell);
83 aed6fc72 Ermal
}
84
85 5987261f Ermal LUÇI
@unlink("{$g['tmp_path']}/.rc.start_packages.running");
86 aed6fc72 Ermal
?>