Project

General

Profile

Download (1.86 KB) Statistics
| Branch: | Tag: | Revision:
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-2016 Rubicon Communications, LLC (Netgate)
8
 * All rights reserved.
9
 *
10
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13
 *
14
 * http://www.apache.org/licenses/LICENSE-2.0
15
 *
16
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21
 */
22

    
23
/* If PHP is not running, silently abort and run registration during boot */
24
if (!file_exists('/var/run/php-fpm.pid')) {
25
	exit;
26
}
27

    
28
require_once("config.inc");
29
require_once("functions.inc");
30
require_once("filter.inc");
31
require_once("shaper.inc");
32
require_once("captiveportal.inc");
33
require_once("pkg-utils.inc");
34
require_once("pfsense-utils.inc");
35

    
36
function usage() {
37
	print "Usage: rc.packages PKG_NAME (POST-INSTALL|DEINSTALL|POST-DEINSTALL)\n";
38
	exit(1);
39
}
40

    
41
$pkg_interface = "console";
42

    
43
/* Keep old behavior: with no params, sync all and exit */
44
if ($argc == 1) {
45
	resync_all_package_configs(true);
46
	exit;
47
}
48

    
49
$pkg = '';
50
$when = '';
51

    
52
if (isset($_GET['pkg'])) {
53
	$pkg = $_GET['pkg'];
54
} else {
55
	$pkg = $argv[1];
56
}
57

    
58
if (isset($_GET['when'])) {
59
	$when = strtolower($_GET['when']);
60
} else {
61
	$when = strtolower($argv[2]);
62
}
63

    
64
if ($pkg == '' || $when == '') {
65
	print "Error: invalid parameters\n";
66
	usage();
67
}
68

    
69
/* Remove pkg_prefix from pkg name */
70
pkg_remove_prefix($pkg);
71

    
72
switch ($when) {
73
	case "post-install":
74
		install_package_xml($pkg);
75
		break;
76
	case "deinstall":
77
	case "post-deinstall":
78
		delete_package_xml($pkg, $when);
79
		break;
80
	default:
81
		usage();
82
}
83

    
84
?>
(59-59/78)