Project

General

Profile

Download (2.51 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 0ba30e57 Reid Linnemann
require_once("config.lib.inc");
27 aed6fc72 Ermal
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 6c19757e Ermal
require_once("service-utils.inc");
34 aed6fc72 Ermal
35 5987261f Ermal LUÇI
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
36 6990ad35 Phil Davis
	$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 5987261f Ermal LUÇI
}
44
45 84963037 jim-p
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 5987261f Ermal LUÇI
@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", "");
51
52 f1dbcf47 Ermal
log_error("Restarting/Starting all packages.");
53 aed6fc72 Ermal
54 dd9e0bdb phildd
$rcfiles = glob(RCFILEPREFIX . "*.sh");
55 e173dd74 Phil Davis
if (!$rcfiles) {
56 6c19757e Ermal
	$rcfiles = array();
57 e173dd74 Phil Davis
} else {
58 6c19757e Ermal
	$rcfiles = array_flip($rcfiles);
59 e173dd74 Phil Davis
	if (!$rcfiles) {
60 6c19757e Ermal
		$rcfiles = array();
61 e173dd74 Phil Davis
	}
62 6c19757e Ermal
}
63
64 0ba30e57 Reid Linnemann
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 6c19757e Ermal
}
72
73
$shell = @popen("/bin/sh", "w");
74
if ($shell) {
75 dfa6deda jim-p
	foreach ($rcfiles as $rcfile => $number) {
76 6c19757e Ermal
		echo " Starting {$rcfile}...";
77
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
78
		echo "done.\n";
79
	}
80
81
	pclose($shell);
82 aed6fc72 Ermal
}
83
84 5987261f Ermal LUÇI
@unlink("{$g['tmp_path']}/.rc.start_packages.running");
85 aed6fc72 Ermal
?>