1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
* rc.packages
|
5
|
*
|
6
|
* part of pfSense (https://www.pfsense.org)
|
7
|
* Copyright (c) 2004-2013 BSD Perimeter
|
8
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
9
|
* Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
|
10
|
* All rights reserved.
|
11
|
*
|
12
|
* 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
|
*
|
16
|
* http://www.apache.org/licenses/LICENSE-2.0
|
17
|
*
|
18
|
* 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
|
*/
|
24
|
|
25
|
/* If PHP is not running, silently abort and run registration during boot */
|
26
|
if (!file_exists('/var/run/php-fpm.pid')) {
|
27
|
exit;
|
28
|
}
|
29
|
|
30
|
require_once("config.inc");
|
31
|
require_once("functions.inc");
|
32
|
require_once("filter.inc");
|
33
|
require_once("shaper.inc");
|
34
|
require_once("captiveportal.inc");
|
35
|
require_once("pkg-utils.inc");
|
36
|
require_once("pfsense-utils.inc");
|
37
|
|
38
|
function usage() {
|
39
|
print "Usage: rc.packages PKG_NAME (POST-INSTALL|DEINSTALL|POST-DEINSTALL)\n";
|
40
|
exit(1);
|
41
|
}
|
42
|
|
43
|
$pkg_interface = "console";
|
44
|
|
45
|
/* Keep old behavior: with no params, sync all and exit */
|
46
|
if ($argc == 1) {
|
47
|
resync_all_package_configs(true);
|
48
|
exit;
|
49
|
}
|
50
|
|
51
|
$pkg = '';
|
52
|
$when = '';
|
53
|
|
54
|
if (isset($_GET['pkg'])) {
|
55
|
$pkg = $_GET['pkg'];
|
56
|
} else {
|
57
|
$pkg = $argv[1];
|
58
|
}
|
59
|
|
60
|
if (isset($_GET['when'])) {
|
61
|
$when = strtolower($_GET['when']);
|
62
|
} else {
|
63
|
$when = strtolower($argv[2]);
|
64
|
}
|
65
|
|
66
|
if ($pkg == '' || $when == '') {
|
67
|
print "Error: invalid parameters\n";
|
68
|
usage();
|
69
|
}
|
70
|
|
71
|
/* Remove pkg_prefix from pkg name */
|
72
|
pkg_remove_prefix($pkg);
|
73
|
|
74
|
switch ($when) {
|
75
|
case "post-install":
|
76
|
install_package_xml($pkg);
|
77
|
break;
|
78
|
case "deinstall":
|
79
|
case "post-deinstall":
|
80
|
delete_package_xml($pkg, $when);
|
81
|
break;
|
82
|
default:
|
83
|
usage();
|
84
|
}
|
85
|
|
86
|
?>
|