mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
src: remove globbing-related unlink_if_exists() usage
This commit is contained in:
parent
1832a5a385
commit
ae8d44faa2
@ -204,7 +204,7 @@ function write_config($desc = 'Unknown', $backup = true)
|
||||
******/
|
||||
function reset_factory_defaults($sync = true)
|
||||
{
|
||||
unlink_if_exists('/conf/*' . $filename);
|
||||
mwexec('/bin/rm -r /conf/*');
|
||||
disable_security_checks();
|
||||
setup_serial_port();
|
||||
|
||||
@ -217,7 +217,8 @@ function reset_factory_defaults($sync = true)
|
||||
}
|
||||
}
|
||||
|
||||
function config_restore($conffile) {
|
||||
function config_restore($conffile)
|
||||
{
|
||||
global $config, $g;
|
||||
|
||||
if (!file_exists($conffile))
|
||||
|
||||
@ -2025,9 +2025,10 @@ function upgrade_054_to_055() {
|
||||
/* Let's save the RRD graphs after we run enable RRD graphing */
|
||||
/* The function will restore the rrd.tgz so we will save it after */
|
||||
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
|
||||
unlink_if_exists("/var/db/rrd/*.xml");
|
||||
if (file_exists("/var/run/booting"))
|
||||
mwexec('/bin/rm /var/db/rrd/*.xml');
|
||||
if (file_exists("/var/run/booting")) {
|
||||
echo "Updating configuration...";
|
||||
}
|
||||
}
|
||||
|
||||
function upgrade_055_to_056() {
|
||||
|
||||
@ -1034,21 +1034,6 @@ function mwexec_bg($command, $mute = false, $clearsigmask = false)
|
||||
mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask);
|
||||
}
|
||||
|
||||
/* unlink a file or directory, if it exists */
|
||||
function unlink_if_exists($fn)
|
||||
{
|
||||
$to_do = glob($fn);
|
||||
|
||||
foreach($to_do as $filename) {
|
||||
if (is_dir($filename)) {
|
||||
/* rmdir() is not recursive... */
|
||||
mwexecf('/bin/rm -r %s', $filename);
|
||||
} else {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* make a global alias table (for faster lookups) */
|
||||
function alias_make_table($config)
|
||||
{
|
||||
|
||||
@ -52,8 +52,8 @@ if ($_POST['apply']) {
|
||||
$savemsg = $retval;
|
||||
|
||||
/* reset rrd queues */
|
||||
unlink_if_exists("/var/db/rrd/*queuedrops.rrd");
|
||||
unlink_if_exists("/var/db/rrd/*queues.rrd");
|
||||
mwexec('/bin/rm /var/db/rrd/*queuedrops.rrd');
|
||||
mwexec('/bin/rm /var/db/rrd/*queues.rrd');
|
||||
enable_rrd_graphing();
|
||||
|
||||
clear_subsystem_dirty('shaper');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user