Project

General

Profile

Download (1.95 KB) Statistics
| Branch: | Tag: | Revision:
1 5ed5ede3 Renato Botelho
#!/usr/local/bin/php -f
2 ab0a8f88 Colin Smith
<?php
3
/*
4 ac24dc24 Renato Botelho
 * rc.packages
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9 8f2f85c3 Luiz Otavio O Souza
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
10 ac24dc24 Renato Botelho
 * All rights reserved.
11
 *
12 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 *
16 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
17 ac24dc24 Renato Botelho
 *
18 b12ea3fb Renato Botelho
 * 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 ac24dc24 Renato Botelho
 */
24 ab0a8f88 Colin Smith
25 b4f3beec Renato Botelho
/* 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 ca84833f Scott Ullrich
require_once("config.inc");
31 5f2d078e Scott Ullrich
require_once("functions.inc");
32
require_once("filter.inc");
33
require_once("shaper.inc");
34
require_once("captiveportal.inc");
35 69305751 Scott Ullrich
require_once("pkg-utils.inc");
36 93e523e8 Scott Ullrich
require_once("pfsense-utils.inc");
37 ab0a8f88 Colin Smith
38 eb9cc943 Renato Botelho
function usage() {
39
	print "Usage: rc.packages PKG_NAME (POST-INSTALL|DEINSTALL|POST-DEINSTALL)\n";
40
	exit(1);
41
}
42
43 e2fa1b81 Scott Ullrich
$pkg_interface = "console";
44
45 eb9cc943 Renato Botelho
/* 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 0e715186 Renato Botelho
$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 eb9cc943 Renato Botelho
	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 4e322e2c Phil Davis
	case "post-install":
76
		install_package_xml($pkg);
77
		break;
78 92c2bd7f Renato Botelho
	case "deinstall":
79 4e322e2c Phil Davis
	case "post-deinstall":
80
		delete_package_xml($pkg, $when);
81
		break;
82
	default:
83
		usage();
84 eb9cc943 Renato Botelho
}
85 ab0a8f88 Colin Smith
86
?>