Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
5a10f56a
Commit
5a10f56a
authored
Apr 25, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cron: remove install_cron_job() usage; #911
parent
98485c39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
44 deletions
+33
-44
services.inc
src/etc/inc/services.inc
+6
-0
upgrade_config.inc
src/etc/inc/upgrade_config.inc
+0
-6
diag_backup.php
src/www/diag_backup.php
+27
-38
No files found.
src/etc/inc/services.inc
View file @
5a10f56a
...
...
@@ -2350,6 +2350,8 @@ function configure_cron()
'/usr/local/etc/rc.backup_netflow'
,
'/usr/local/etc/rc.backup_rrd'
,
'/usr/local/etc/rc.update_bogons'
,
'/usr/local/opnsense/scripts/remote_backup.php'
,
'newsyslog'
,
/* old config migration for extra care */
);
foreach
(
$obsoletes
as
$obsolete
)
{
...
...
@@ -2374,6 +2376,10 @@ function configure_cron()
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_netflow'
,
$minute
=
'0'
,
'*/'
.
$config
[
'system'
][
'netflowbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/opnsense/scripts/remote_backup.php'
,
0
,
1
);
}
/* bogons fetch always set in default config.xml */
switch
(
$config
[
'system'
][
'bogons'
][
'interval'
])
{
case
'daily'
:
...
...
src/etc/inc/upgrade_config.inc
View file @
5a10f56a
...
...
@@ -3119,12 +3119,6 @@ function upgrade_098_to_099() {
}
}
function
upgrade_099_to_100
()
{
install_cron_job
(
"newsyslog"
,
false
);
configure_cron
();
}
function
upgrade_100_to_101
()
{
global
$config
;
...
...
src/www/diag_backup.php
View file @
5a10f56a
...
...
@@ -44,20 +44,6 @@ require_once("rrd.inc");
require_once
(
"system.inc"
);
require_once
(
"pfsense-utils.inc"
);
/**
* check if cron exists
*/
function
cron_job_exists
(
$command
)
{
global
$config
;
foreach
(
$config
[
'cron'
][
'item'
]
as
$item
)
{
if
(
strstr
(
$item
[
'command'
],
$command
))
{
return
true
;
}
}
return
false
;
}
function
rrd_data_xml
()
{
$rrddbpath
=
'/var/db/rrd'
;
...
...
@@ -426,7 +412,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if
(
is_numeric
(
$_POST
[
'GDriveBackupCount'
]))
{
$config
[
'system'
][
'remotebackup'
][
'GDriveBackupCount'
]
=
$_POST
[
'GDriveBackupCount'
];
}
else
{
$config
[
'system'
][
'remotebackup'
][
'GDriveBackupCount'
]
=
3
0
;
$config
[
'system'
][
'remotebackup'
][
'GDriveBackupCount'
]
=
6
0
;
}
if
(
$_POST
[
'GDrivePasswordConfirm'
]
!=
$_POST
[
'GDrivePassword'
]
)
{
...
...
@@ -434,34 +420,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors
[]
=
gettext
(
"The supplied 'Password' and 'Confirm' field values must match."
);
}
if
(
is_uploaded_file
(
$_FILES
[
'GDriveP12file'
][
'tmp_name'
]))
{
$data
=
file_get_contents
(
$_FILES
[
'GDriveP12file'
][
'tmp_name'
]);
$config
[
'system'
][
'remotebackup'
][
'GDriveP12key'
]
=
base64_encode
(
$data
);
}
elseif
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]
!=
"on"
)
{
unset
(
$config
[
'system'
][
'remotebackup'
][
'GDriveP12key'
]);
}
if
(
count
(
$input_errors
)
==
0
)
{
if
(
is_uploaded_file
(
$_FILES
[
'GDriveP12file'
][
'tmp_name'
]))
{
$data
=
file_get_contents
(
$_FILES
[
'GDriveP12file'
][
'tmp_name'
]);
$config
[
'system'
][
'remotebackup'
][
'GDriveP12key'
]
=
base64_encode
(
$data
);
}
elseif
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]
!=
"on"
)
{
unset
(
$config
[
'system'
][
'remotebackup'
][
'GDriveP12key'
]);
}
$savemsg
=
gettext
(
"Google Drive backup settings have been saved."
);
write_config
();
// test / perform backup
try
{
$filesInBackup
=
backup_to_google_drive
();
$cron_job
=
"/usr/local/opnsense/scripts/remote_backup.php"
;
if
(
!
cron_job_exists
(
$cron_job
))
{
install_cron_job
(
$cron_job
,
true
,
0
,
1
);
configure_cron
();
write_config
();
configure_cron
();
try
{
$filesInBackup
=
backup_to_google_drive
();
}
catch
(
Exception
$e
)
{
$filesInBackup
=
array
();
}
}
catch
(
Exception
$e
)
{
$filesInBackup
=
array
()
;
}
if
(
count
(
$filesInBackup
)
==
0
)
{
$input_errors
[]
=
gettext
(
"Google Drive communication failure"
);
}
else
{
$input_messages
=
gettext
(
"Backup succesfull, current filelist:"
);
foreach
(
$filesInBackup
as
$filename
=>
$file
)
{
$input_messages
=
$input_messages
.
"<br>"
.
$filename
;
if
(
empty
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]))
{
/* unused */
}
elseif
(
count
(
$filesInBackup
)
==
0
)
{
$input_errors
[]
=
gettext
(
"Google Drive communication failure"
);
}
else
{
$input_messages
=
gettext
(
"Backup successful, current file list:"
)
.
"<br>"
;
foreach
(
$filesInBackup
as
$filename
=>
$file
)
{
$input_messages
=
$input_messages
.
"<br>"
.
$filename
;
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment