Project

General

Profile

Download (2.98 KB) Statistics
| Branch: | Tag: | Revision:
1 aed6fc72 Ermal
#!/usr/local/bin/php -f
2
<?php
3
/* $Id$ */
4
/*
5
    rc.start_packages
6 34e2973e Chris Buechler
    part of pfSense (https://www.pfsense.org)
7 aed6fc72 Ermal
    Copyright (C) 2004 Scott Ullrich
8
    All rights reserved.
9 969d7f5e Scott Ullrich
10 aed6fc72 Ermal
    Redistribution and use in source and binary forms, with or without
11
    modification, are permitted provided that the following conditions are met:
12 969d7f5e Scott Ullrich
13 aed6fc72 Ermal
    1. Redistributions of source code must retain the above copyright notice,
14
       this list of conditions and the following disclaimer.
15 969d7f5e Scott Ullrich
16 aed6fc72 Ermal
    2. Redistributions in binary form must reproduce the above copyright
17
       notice, this list of conditions and the following disclaimer in the
18
       documentation and/or other materials provided with the distribution.
19 969d7f5e Scott Ullrich
20 aed6fc72 Ermal
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
    POSSIBILITY OF SUCH DAMAGE.
30
*/
31 969d7f5e Scott Ullrich
32 aed6fc72 Ermal
require_once("config.inc");
33
require_once("functions.inc");
34
require_once("filter.inc");
35
require_once("shaper.inc");
36
require_once("captiveportal.inc");
37
require_once("pkg-utils.inc");
38
require_once("pfsense-utils.inc");
39 6c19757e Ermal
require_once("service-utils.inc");
40 aed6fc72 Ermal
41 5987261f Ermal LUÇI
if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) {
42
        $stat = stat("{$g['tmp_path']}/.rc.start_packages.running");
43
        if (time() - $stat['mtime'] >= 90)
44
                @unlink("{$g['tmp_path']}/.rc.start_packages.running");
45
        else {
46
                log_error("Skipping STARTing packages process because previous/another instance is already running");
47
                return;
48
        }
49
}
50
51
@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", "");
52
53 f1dbcf47 Ermal
log_error("Restarting/Starting all packages.");
54 aed6fc72 Ermal
55 dd9e0bdb phildd
$rcfiles = glob(RCFILEPREFIX . "*.sh");
56 6c19757e Ermal
if (!$rcfiles)
57
	$rcfiles = array();
58
else {
59
	$rcfiles = array_flip($rcfiles);
60
	if (!$rcfiles)
61
		$rcfiles = array();
62
}
63
64
if (is_array($config['installedpackages']['package'])) {
65 d760445e Ermal
	foreach($config['installedpackages']['package'] as $pkgid => $package) {
66 6c19757e Ermal
		echo " Starting package {$package['name']}...";
67 d760445e Ermal
		sync_package($pkgid);
68 e205bdb7 Phil Davis
		$internal_name = get_pkg_internal_name($package);
69
		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
?>