Project

General

Profile

Download (2.87 KB) Statistics
| Branch: | Tag: | Revision:
1 cb7d18d5 Renato Botelho
#!/usr/local/bin/php-cgi -f
2 aed6fc72 Ermal
<?php
3
/*
4 e173dd74 Phil Davis
	rc.start_packages
5
	part of pfSense (https://www.pfsense.org)
6
	Copyright (C) 2004 Scott Ullrich
7
	All rights reserved.
8 969d7f5e Scott Ullrich
9 e173dd74 Phil Davis
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11 969d7f5e Scott Ullrich
12 e173dd74 Phil Davis
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14 969d7f5e Scott Ullrich
15 e173dd74 Phil Davis
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18 969d7f5e Scott Ullrich
19 e173dd74 Phil Davis
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29 aed6fc72 Ermal
*/
30 969d7f5e Scott Ullrich
31 aed6fc72 Ermal
require_once("config.inc");
32
require_once("functions.inc");
33
require_once("filter.inc");
34
require_once("shaper.inc");
35
require_once("captiveportal.inc");
36
require_once("pkg-utils.inc");
37
require_once("pfsense-utils.inc");
38 6c19757e Ermal
require_once("service-utils.inc");
39 aed6fc72 Ermal
40 5987261f Ermal LUÇI
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
41 6990ad35 Phil Davis
	$stat = stat("{$g['tmp_path']}/.rc.start_packages.running");
42
	if (time() - $stat['mtime'] >= 90) {
43
		@unlink("{$g['tmp_path']}/.rc.start_packages.running");
44
	} else {
45
		log_error("Skipping STARTing packages process because previous/another instance is already running");
46
		return;
47
	}
48 5987261f Ermal LUÇI
}
49
50
@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
if (is_array($config['installedpackages']['package'])) {
65 e173dd74 Phil Davis
	foreach ($config['installedpackages']['package'] as $pkgid => $package) {
66 6c19757e Ermal
		echo " Starting package {$package['name']}...";
67 a0d4336f Renato Botelho
		sync_package($package['name']);
68 af5d93f6 Renato Botelho
		$internal_name = get_package_internal_name($package);
69 e205bdb7 Phil Davis
		start_service($internal_name);
70
		unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
71 6c19757e Ermal
		echo "done.\n";
72
	}
73
}
74
75
$shell = @popen("/bin/sh", "w");
76
if ($shell) {
77 dfa6deda jim-p
	foreach ($rcfiles as $rcfile => $number) {
78 6c19757e Ermal
		echo " Starting {$rcfile}...";
79
		fwrite($shell, "{$rcfile} start >>/tmp/bootup_messages 2>&1 &");
80
		echo "done.\n";
81
	}
82
83
	pclose($shell);
84 aed6fc72 Ermal
}
85
86 5987261f Ermal LUÇI
@unlink("{$g['tmp_path']}/.rc.start_packages.running");
87 aed6fc72 Ermal
?>