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
29490c8d
Commit
29490c8d
authored
Mar 19, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugins: add plugins_cron() for autocron usage; closes #1483
parent
983134be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
12 deletions
+70
-12
plugins.inc
src/etc/inc/plugins.inc
+18
-0
dyndns.inc
src/etc/inc/plugins.inc.d/dyndns.inc
+9
-0
pf.inc
src/etc/inc/plugins.inc.d/pf.inc
+19
-1
rfc2136.inc
src/etc/inc/plugins.inc.d/rfc2136.inc
+9
-0
system.inc
src/etc/inc/system.inc
+15
-11
No files found.
src/etc/inc/plugins.inc
View file @
29490c8d
...
@@ -74,6 +74,24 @@ function plugins_services()
...
@@ -74,6 +74,24 @@ function plugins_services()
return
$services
;
return
$services
;
}
}
function
plugins_cron
()
{
$jobs
=
array
();
foreach
(
plugins_scan
()
as
$name
=>
$path
)
{
require_once
$path
;
$func
=
sprintf
(
'%s_cron'
,
$name
);
if
(
function_exists
(
$func
))
{
$workers
=
$func
();
foreach
(
$workers
as
$work
)
{
$jobs
[]
=
$work
;
}
}
}
return
$jobs
;
}
function
plugins_syslog
()
function
plugins_syslog
()
{
{
$syslogs
=
array
();
$syslogs
=
array
();
...
...
src/etc/inc/plugins.inc.d/dyndns.inc
View file @
29490c8d
...
@@ -41,6 +41,15 @@ function dyndns_configure()
...
@@ -41,6 +41,15 @@ function dyndns_configure()
);
);
}
}
function
dyndns_cron
()
{
$jobs
=
array
(
'autocron'
=>
array
());
$jobs
[
'autocron'
][]
=
array
(
'/usr/local/etc/rc.dyndns.update'
,
'11'
,
'1'
);
return
$jobs
;
}
function
dyndns_list
()
function
dyndns_list
()
{
{
return
array
(
return
array
(
...
...
src/etc/inc/plugins.inc.d/pf.inc
View file @
29490c8d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/*
/*
Copyright (C) 2016 Deciso B.V.
Copyright (C) 2016 Deciso B.V.
Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2016
-2017
Franco Fichtner <franco@opnsense.org>
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
...
@@ -49,6 +49,24 @@ function pf_services()
...
@@ -49,6 +49,24 @@ function pf_services()
return
$services
;
return
$services
;
}
}
function
pf_cron
()
{
global
$config
;
$jobs
=
array
(
'autocron'
=>
array
());
if
(
isset
(
$config
[
'filter'
][
'rule'
]))
{
foreach
(
$config
[
'filter'
][
'rule'
]
as
$rule
)
{
if
(
!
empty
(
$rule
[
'sched'
]))
{
$jobs
[
'autocron'
][]
=
array
(
'/usr/local/etc/rc.filter_configure'
,
'0,15,30,45'
);
break
;
}
}
}
return
$jobs
;
}
function
pf_interfaces
()
function
pf_interfaces
()
{
{
global
$config
;
global
$config
;
...
...
src/etc/inc/plugins.inc.d/rfc2136.inc
View file @
29490c8d
...
@@ -38,6 +38,15 @@ function rfc2136_configure()
...
@@ -38,6 +38,15 @@ function rfc2136_configure()
);
);
}
}
function
rfc2136_cron
()
{
$jobs
=
array
(
'autocron'
=>
array
());
$jobs
[
'autocron'
][]
=
array
(
'/usr/local/etc/rc.rfc2136.update'
,
'16'
,
'1'
);
return
$jobs
;
}
function
rfc2136_configure_do
(
$verbose
=
false
,
$int
=
''
,
$updatehost
=
''
,
$forced
=
false
)
function
rfc2136_configure_do
(
$verbose
=
false
,
$int
=
''
,
$updatehost
=
''
,
$forced
=
false
)
{
{
global
$config
;
global
$config
;
...
...
src/etc/inc/system.inc
View file @
29490c8d
...
@@ -1580,6 +1580,21 @@ function system_cron_configure($verbose = false)
...
@@ -1580,6 +1580,21 @@ function system_cron_configure($verbose = false)
flush
();
flush
();
}
}
foreach
(
plugins_cron
()
as
$cron_plugin
)
{
/*
* We are stuffing jobs inside 'autocron' to be able to
* depreceate this at a later time. Ideally all of the
* services should use a single cron-model, which this is
* not. At least this plugin function helps us to divide
* and conquer the code bits... :)
*/
if
(
!
empty
(
$cron_plugin
[
'autocron'
]))
{
foreach
(
$cron_plugin
[
'autocron'
]
as
$cron_job
)
{
$autocron
[]
=
call_user_func_array
(
'generate_cron_job'
,
$cron_job
);
}
}
}
/* hourly */
/* hourly */
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 webConfiguratorlockout'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 webConfiguratorlockout'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 sshlockout'
,
'2'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 sshlockout'
,
'2'
);
...
@@ -1589,8 +1604,6 @@ function system_cron_configure($verbose = false)
...
@@ -1589,8 +1604,6 @@ function system_cron_configure($verbose = false)
/* daily */
/* daily */
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_alias_url_data'
,
'1'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_alias_url_data'
,
'1'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_urltables'
,
'6'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_urltables'
,
'6'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.dyndns.update'
,
'11'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.rfc2136.update'
,
'16'
,
'1'
);
/* every now and then */
/* every now and then */
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/ping_hosts.sh'
,
'*/4'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/ping_hosts.sh'
,
'*/4'
);
...
@@ -1615,15 +1628,6 @@ function system_cron_configure($verbose = false)
...
@@ -1615,15 +1628,6 @@ function system_cron_configure($verbose = false)
$autocron
[]
=
generate_cron_job
(
'/usr/local/opnsense/scripts/remote_backup.php'
,
0
,
1
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/opnsense/scripts/remote_backup.php'
,
0
,
1
);
}
}
if
(
isset
(
$config
[
'filter'
][
'rule'
]))
{
foreach
(
$config
[
'filter'
][
'rule'
]
as
$rule
)
{
if
(
!
empty
(
$rule
[
'sched'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.filter_configure'
,
'0,15,30,45'
);
break
;
}
}
}
/* bogons fetch always set in default config.xml */
/* bogons fetch always set in default config.xml */
switch
(
$config
[
'system'
][
'bogons'
][
'interval'
])
{
switch
(
$config
[
'system'
][
'bogons'
][
'interval'
])
{
case
'daily'
:
case
'daily'
:
...
...
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