1
|
<?php
|
2
|
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
WipePackages.php
|
6
|
part of the pfSense project
|
7
|
Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
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
|
|
20
|
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
|
|
32
|
if(!function_exists("readline")) {
|
33
|
echo "\nThis script requires the readline() libary which is not present on this system.";
|
34
|
echo "\n\nSorry, but we cannot continue.\n";
|
35
|
die("Need readline() library");
|
36
|
}
|
37
|
|
38
|
require("functions.inc");
|
39
|
require("config.inc");
|
40
|
|
41
|
echo "\nThis script will wipe all installed packages off of your pfSense installation.\n";
|
42
|
|
43
|
$command = readline("\nAre you sure you would like to continue [y/N]? ");
|
44
|
if(strtoupper($command) == "Y" || strtoupper($command) == "YES") {
|
45
|
|
46
|
$rmconfig = readline("\nWould you like to remove all package configuration information as well [y/N]? ");
|
47
|
|
48
|
echo "\n\nStarting package wipe... One moment please... ";
|
49
|
exec("cd /var/db/pkg/ && find . -exec 'pkg_delete {}' \; ");
|
50
|
exec("rm -rf /var/db/pkg/*");
|
51
|
|
52
|
if(strtoupper($rmconfig) == "Y" || strtoupper($rmconfig) == "YES") {
|
53
|
echo "\nRemoving pfSense package configuration information...";
|
54
|
if($config['installedpackages']['package']) {
|
55
|
unset($config['installedpackages']['package']);
|
56
|
write_config("Package wipe procedure completed.");
|
57
|
}
|
58
|
echo "\n";
|
59
|
}
|
60
|
|
61
|
echo "\npfSense package wipe procedure has completed.\n\n";
|
62
|
}
|
63
|
|
64
|
?>
|