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
7424a2d7
Commit
7424a2d7
authored
Nov 20, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: merge system_cron_configure rework from master
parent
8cabf4f0
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
108 deletions
+108
-108
services.inc
src/etc/inc/services.inc
+0
-92
system.inc
src/etc/inc/system.inc
+101
-0
rc.bootup
src/etc/rc.bootup
+1
-8
rc.reload_all
src/etc/rc.reload_all
+1
-1
diag_backup.php
src/www/diag_backup.php
+1
-1
firewall_rules_edit.php
src/www/firewall_rules_edit.php
+2
-2
system_advanced_firewall.php
src/www/system_advanced_firewall.php
+1
-2
system_advanced_misc.php
src/www/system_advanced_misc.php
+1
-2
No files found.
src/etc/inc/services.inc
View file @
7424a2d7
...
...
@@ -2013,98 +2013,6 @@ EOD;
return
0
;
}
function
configure_cron
()
{
global
$config
;
$autocron
=
array
();
/* 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 sshlockout'
,
'2'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 virusprot'
,
'3'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.expireaccounts'
,
'5'
);
/* daily */
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_alias_url_data'
,
'1'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_urltables'
,
'5'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.dyndns.update'
,
'11'
,
'1'
);
/* every now and then */
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/ping_hosts.sh'
,
'*/4'
);
if
(
!
empty
(
$config
[
'system'
][
'rrdbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_rrd'
,
'0'
,
'*/'
.
$config
[
'system'
][
'rrdbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'dhcpbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_dhcpleases'
,
'0'
,
'*/'
.
$config
[
'system'
][
'dhcpbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'netflowbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_netflow'
,
'0'
,
'*/'
.
$config
[
'system'
][
'netflowbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]))
{
$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_sync'
,
'0,15,30,45'
);
break
;
}
}
}
/* bogons fetch always set in default config.xml */
switch
(
$config
[
'system'
][
'bogons'
][
'interval'
])
{
case
'daily'
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'*'
,
'*'
,
'*'
);
break
;
case
'weekly'
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'*'
,
'*'
,
'0'
);
break
;
case
'monthly'
:
default
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'1'
,
'*'
,
'*'
);
break
;
}
$crontab_contents
=
"# DO NOT EDIT THIS FILE -- OPNsense auto-generated file
\n
"
;
$crontab_contents
.=
"# Please use /etc/crontab for your overrides instead.
\n
"
;
$crontab_contents
.=
"SHELL=/bin/sh
\n
"
;
$crontab_contents
.=
"PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
\n
"
;
$crontab_contents
.=
"#minute
\t
hour
\t
mday
\t
month
\t
wday
\t
command
\n
"
;
foreach
(
$autocron
as
$item
)
{
$crontab_contents
.=
"
{
$item
[
'minute'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'hour'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'mday'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'month'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'wday'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'command'
]
}
\n
"
;
}
file_put_contents
(
'/var/cron/tabs/root'
,
$crontab_contents
);
killbypid
(
'/var/run/cron.pid'
,
'HUP'
);
}
function
generate_cron_job
(
$command
,
$minute
=
'0'
,
$hour
=
'*'
,
$monthday
=
'*'
,
$month
=
'*'
,
$weekday
=
'*'
)
{
$cron_item
=
array
();
$cron_item
[
'minute'
]
=
$minute
;
$cron_item
[
'hour'
]
=
$hour
;
$cron_item
[
'mday'
]
=
$monthday
;
$cron_item
[
'month'
]
=
$month
;
$cron_item
[
'wday'
]
=
$weekday
;
$cron_item
[
'command'
]
=
$command
;
return
$cron_item
;
}
function
is_apinger_enabled
()
{
global
$config
;
...
...
src/etc/inc/system.inc
View file @
7424a2d7
...
...
@@ -1881,6 +1881,107 @@ function load_thermal_module()
}
}
function
system_cron_configure
(
$verbose
=
false
)
{
global
$config
;
function
generate_cron_job
(
$command
,
$minute
=
'0'
,
$hour
=
'*'
,
$monthday
=
'*'
,
$month
=
'*'
,
$weekday
=
'*'
)
{
$cron_item
=
array
();
$cron_item
[
'minute'
]
=
$minute
;
$cron_item
[
'hour'
]
=
$hour
;
$cron_item
[
'mday'
]
=
$monthday
;
$cron_item
[
'month'
]
=
$month
;
$cron_item
[
'wday'
]
=
$weekday
;
$cron_item
[
'command'
]
=
$command
;
return
$cron_item
;
}
$autocron
=
array
();
if
(
$verbose
)
{
echo
'Configuring CRON...'
;
flush
();
}
/* 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 sshlockout'
,
'2'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/expiretable -v -t 3600 virusprot'
,
'3'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.expireaccounts'
,
'5'
);
/* daily */
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_alias_url_data'
,
'1'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_urltables'
,
'5'
,
'1'
);
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.dyndns.update'
,
'11'
,
'1'
);
/* every now and then */
$autocron
[]
=
generate_cron_job
(
'/usr/local/sbin/ping_hosts.sh'
,
'*/4'
);
if
(
!
empty
(
$config
[
'system'
][
'rrdbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_rrd'
,
'0'
,
'*/'
.
$config
[
'system'
][
'rrdbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'dhcpbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_dhcpleases'
,
'0'
,
'*/'
.
$config
[
'system'
][
'dhcpbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'netflowbackup'
]))
{
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.backup_netflow'
,
'0'
,
'*/'
.
$config
[
'system'
][
'netflowbackup'
]);
}
if
(
!
empty
(
$config
[
'system'
][
'remotebackup'
][
'GDriveEnabled'
]))
{
$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_sync'
,
'0,15,30,45'
);
break
;
}
}
}
/* bogons fetch always set in default config.xml */
switch
(
$config
[
'system'
][
'bogons'
][
'interval'
])
{
case
'daily'
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'*'
,
'*'
,
'*'
);
break
;
case
'weekly'
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'*'
,
'*'
,
'0'
);
break
;
case
'monthly'
:
default
:
$autocron
[]
=
generate_cron_job
(
'/usr/local/etc/rc.update_bogons cron'
,
'1'
,
'3'
,
'1'
,
'*'
,
'*'
);
break
;
}
$crontab_contents
=
"# DO NOT EDIT THIS FILE -- OPNsense auto-generated file
\n
"
;
$crontab_contents
.=
"# Please use /etc/crontab for your overrides instead.
\n
"
;
$crontab_contents
.=
"SHELL=/bin/sh
\n
"
;
$crontab_contents
.=
"PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
\n
"
;
$crontab_contents
.=
"#minute
\t
hour
\t
mday
\t
month
\t
wday
\t
command
\n
"
;
foreach
(
$autocron
as
$item
)
{
$crontab_contents
.=
"
{
$item
[
'minute'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'hour'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'mday'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'month'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'wday'
]
}
\t
"
;
$crontab_contents
.=
"
{
$item
[
'command'
]
}
\n
"
;
}
file_put_contents
(
'/var/cron/tabs/root'
,
$crontab_contents
);
killbypid
(
'/var/run/cron.pid'
,
'HUP'
);
if
(
$verbose
)
{
echo
"done.
\n
"
;
}
}
function
system_console_types
()
{
return
array
(
...
...
src/etc/rc.bootup
View file @
7424a2d7
...
...
@@ -174,15 +174,8 @@ mwexec("/usr/local/etc/rc.sshd");
/* start web server */
echo
'Starting webConfigurator...'
.
(
system_webgui_configure
()
?
"done.
\n
"
:
"failed.
\n
"
);
/* configure cron service */
echo
"Configuring CRON..."
;
configure_cron
();
echo
"done.
\n
"
;
/* set up static routes */
system_cron_configure
(
true
);
system_routing_configure
();
/* enable routing */
system_routing_enable
();
/* start dnsmasq service */
...
...
src/etc/rc.reload_all
View file @
7424a2d7
...
...
@@ -53,7 +53,7 @@ system_resolvconf_generate();
system_routing_enable
();
interfaces_configure
();
services_dyndns_configure
();
configure_cron
();
system_cron_configure
();
system_ntp_configure
();
mwexec_bg
(
'/usr/local/etc/rc.sshd'
);
mwexec_bg
(
'/usr/local/etc/rc.restart_webgui'
);
...
...
src/www/diag_backup.php
View file @
7424a2d7
...
...
@@ -449,7 +449,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$savemsg
=
gettext
(
"Google Drive backup settings have been saved."
);
write_config
();
configure_cron
();
system_cron_configure
();
try
{
$filesInBackup
=
backup_to_google_drive
();
...
...
src/www/firewall_rules_edit.php
View file @
7424a2d7
...
...
@@ -30,7 +30,7 @@
require_once
(
"guiconfig.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"s
ervices
.inc"
);
require_once
(
"s
ystem
.inc"
);
require_once
(
"filter.inc"
);
/* TCP flags */
...
...
@@ -451,7 +451,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
// sort filter items per interface, not really necessary but leaves a bit nicer sorted config.xml behind.
filter_rules_sort
();
configure_cron
();
system_cron_configure
();
// write to config
write_config
();
mark_subsystem_dirty
(
'filter'
);
...
...
src/www/system_advanced_firewall.php
View file @
7424a2d7
...
...
@@ -31,7 +31,6 @@
require_once
(
"guiconfig.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"services.inc"
);
require_once
(
"system.inc"
);
function
default_table_entries_size
()
...
...
@@ -201,7 +200,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$savemsg
=
get_std_save_message
();
configure_cron
();
system_cron_configure
();
filter_configure
();
}
}
...
...
src/www/system_advanced_misc.php
View file @
7424a2d7
...
...
@@ -33,7 +33,6 @@ require_once("guiconfig.inc");
require_once
(
"filter.inc"
);
require_once
(
"ipsec.inc"
);
require_once
(
"system.inc"
);
require_once
(
"services.inc"
);
require_once
(
"interfaces.inc"
);
function
crypto_modules
()
...
...
@@ -168,7 +167,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$savemsg
=
get_std_save_message
();
system_resolvconf_generate
(
true
);
configure_cron
();
system_cron_configure
();
activate_powerd
();
load_crypto_module
();
load_thermal_module
();
...
...
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