1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
rc.packages
|
5
|
part of pfSense (https://www.pfsense.org)
|
6
|
Copyright (C) 2004 Scott Ullrich
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
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
|
|
19
|
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
|
*/
|
30
|
|
31
|
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
|
|
39
|
function usage() {
|
40
|
print "Usage: rc.packages PKG_NAME (POST-INSTALL|DEINSTALL|POST-DEINSTALL)\n";
|
41
|
exit(1);
|
42
|
}
|
43
|
|
44
|
$pkg_interface = "console";
|
45
|
|
46
|
/* Keep old behavior: with no params, sync all and exit */
|
47
|
if ($argc == 1) {
|
48
|
resync_all_package_configs(true);
|
49
|
exit;
|
50
|
}
|
51
|
|
52
|
/* If PHP is not running, silently abort and run registration during boot */
|
53
|
if (!isvalidpid('/var/run/php-fpm.pid')) {
|
54
|
exit;
|
55
|
}
|
56
|
|
57
|
$pkg = '';
|
58
|
$when = '';
|
59
|
|
60
|
if (isset($_GET['pkg'])) {
|
61
|
$pkg = $_GET['pkg'];
|
62
|
} else {
|
63
|
$pkg = $argv[1];
|
64
|
}
|
65
|
|
66
|
if (isset($_GET['when'])) {
|
67
|
$when = strtolower($_GET['when']);
|
68
|
} else {
|
69
|
$when = strtolower($argv[2]);
|
70
|
}
|
71
|
|
72
|
if ($pkg == '' || $when == '') {
|
73
|
print "Error: invalid parameters\n";
|
74
|
usage();
|
75
|
}
|
76
|
|
77
|
/* Remove pkg_prefix from pkg name */
|
78
|
pkg_remove_prefix($pkg);
|
79
|
|
80
|
switch ($when) {
|
81
|
case "post-install":
|
82
|
install_package_xml($pkg);
|
83
|
break;
|
84
|
case "deinstall":
|
85
|
case "post-deinstall":
|
86
|
delete_package_xml($pkg, $when);
|
87
|
break;
|
88
|
default:
|
89
|
usage();
|
90
|
}
|
91
|
|
92
|
?>
|