Project

General

Profile

Download (2.45 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 880ed461 jim-p
 * Copyright (c) 2004-2020 Rubicon Communications, LLC (Netgate)
8 ac24dc24 Renato Botelho
 * All rights reserved.
9
 *
10 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 ac24dc24 Renato Botelho
 *
16 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 */
22 969d7f5e Scott Ullrich
23 aed6fc72 Ermal
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 6c19757e Ermal
require_once("service-utils.inc");
31 aed6fc72 Ermal
32 5987261f Ermal LUÇI
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
33 6990ad35 Phil Davis
	$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 5987261f Ermal LUÇI
}
41
42 d7f7ab4f jim-p
if (file_exists("{$g['conf_path']}/needs_package_sync")) {
43
	log_error("Skipping STARTing packages process because package reinstallation is pending.");
44
	return;
45
}
46
47 5987261f Ermal LUÇI
@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", "");
48
49 f1dbcf47 Ermal
log_error("Restarting/Starting all packages.");
50 aed6fc72 Ermal
51 dd9e0bdb phildd
$rcfiles = glob(RCFILEPREFIX . "*.sh");
52 e173dd74 Phil Davis
if (!$rcfiles) {
53 6c19757e Ermal
	$rcfiles = array();
54 e173dd74 Phil Davis
} else {
55 6c19757e Ermal
	$rcfiles = array_flip($rcfiles);
56 e173dd74 Phil Davis
	if (!$rcfiles) {
57 6c19757e Ermal
		$rcfiles = array();
58 e173dd74 Phil Davis
	}
59 6c19757e Ermal
}
60
61
if (is_array($config['installedpackages']['package'])) {
62 e173dd74 Phil Davis
	foreach ($config['installedpackages']['package'] as $pkgid => $package) {
63 6c19757e Ermal
		echo " Starting package {$package['name']}...";
64 a0d4336f Renato Botelho
		sync_package($package['name']);
65 af5d93f6 Renato Botelho
		$internal_name = get_package_internal_name($package);
66 5d4f4900 jim-p
		start_service($internal_name, true);
67 e205bdb7 Phil Davis
		unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
68 6c19757e Ermal
		echo "done.\n";
69
	}
70
}
71
72
$shell = @popen("/bin/sh", "w");
73
if ($shell) {
74 dfa6deda jim-p
	foreach ($rcfiles as $rcfile => $number) {
75 6c19757e Ermal
		echo " Starting {$rcfile}...";
76
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
77
		echo "done.\n";
78
	}
79
80
	pclose($shell);
81 aed6fc72 Ermal
}
82
83 5987261f Ermal LUÇI
@unlink("{$g['tmp_path']}/.rc.start_packages.running");
84 aed6fc72 Ermal
?>