Revision 41fb483a
Added by Ermal LUÇI almost 15 years ago
etc/rc | ||
---|---|---|
364 | 364 |
/usr/local/bin/minicron 240 /var/run/ping_hosts.pid /usr/local/bin/ping_hosts.sh |
365 | 365 |
|
366 | 366 |
# Start account expire handler every hour |
367 |
/usr/local/bin/minicron 3600 /var/run/expire_accounts.pid /etc/rc.exipireaccounts
|
|
367 |
/usr/local/bin/minicron 3600 /var/run/expire_accounts.pid /etc/rc.expireaccounts |
|
368 | 368 |
|
369 | 369 |
# Start alias url updater every 24 hours |
370 | 370 |
/usr/local/bin/minicron 86400 /var/run/update_alias_url_data.pid /etc/rc.update_alias_url_data |
etc/rc.exipireaccounts | ||
---|---|---|
1 |
#!/usr/local/bin/php -f |
|
2 |
<?php |
|
3 |
/* $Id$ */ |
|
4 |
/* |
|
5 |
rc.exireaccounts |
|
6 |
part of pfSense |
|
7 |
|
|
8 |
Copyright (C) 2009 Shrew Soft Inc. |
|
9 |
All rights reserved. |
|
10 |
|
|
11 |
Redistribution and use in source and binary forms, with or without |
|
12 |
modification, are permitted provided that the following conditions are met: |
|
13 |
|
|
14 |
1. Redistributions of source code must retain the above copyright notice, |
|
15 |
this list of conditions and the following disclaimer. |
|
16 |
|
|
17 |
2. Redistributions in binary form must reproduce the above copyright |
|
18 |
notice, this list of conditions and the following disclaimer in the |
|
19 |
documentation and/or other materials provided with the distribution. |
|
20 |
|
|
21 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
22 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
23 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
24 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
|
25 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
26 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
27 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
28 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
29 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
30 |
POSSIBILITY OF SUCH DAMAGE. |
|
31 |
*/ |
|
32 |
|
|
33 |
require_once("config.inc"); |
|
34 |
require_once("functions.inc"); |
|
35 |
|
|
36 |
$removed = 0; |
|
37 |
if (!is_array($config['system']['user'])) |
|
38 |
return; |
|
39 |
|
|
40 |
$count = count($config['system']['user']); |
|
41 |
$index = 0; |
|
42 |
for(; $index < $count; $index++) { |
|
43 |
$user = $config['system']['user'][$index]; |
|
44 |
if($user['scope'] == "system") |
|
45 |
continue; |
|
46 |
echo "1\n"; |
|
47 |
echo "User {$user['name']} expires {$user['expires']}\n"; |
|
48 |
if(!$user['expires']) |
|
49 |
continue; |
|
50 |
echo "1\n"; |
|
51 |
if(strtotime("-1 day") > strtotime($user['expires'])) { |
|
52 |
echo "removing user {$user['name']} at index #{$index}\n"; |
|
53 |
unset($config['system']['user'][$index]); |
|
54 |
$removed++; |
|
55 |
$count--; |
|
56 |
$index--; |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
if($removed > 0) |
|
61 |
write_config("Expired {$removed} user accounts"); |
|
62 |
|
|
63 |
//print_r($config); |
|
64 |
|
|
65 |
?> |
etc/rc.expireaccounts | ||
---|---|---|
1 |
#!/usr/local/bin/php -f |
|
2 |
<?php |
|
3 |
/* $Id$ */ |
|
4 |
/* |
|
5 |
rc.exireaccounts |
|
6 |
part of pfSense |
|
7 |
|
|
8 |
Copyright (C) 2009 Shrew Soft Inc. |
|
9 |
All rights reserved. |
|
10 |
|
|
11 |
Redistribution and use in source and binary forms, with or without |
|
12 |
modification, are permitted provided that the following conditions are met: |
|
13 |
|
|
14 |
1. Redistributions of source code must retain the above copyright notice, |
|
15 |
this list of conditions and the following disclaimer. |
|
16 |
|
|
17 |
2. Redistributions in binary form must reproduce the above copyright |
|
18 |
notice, this list of conditions and the following disclaimer in the |
|
19 |
documentation and/or other materials provided with the distribution. |
|
20 |
|
|
21 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
22 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
23 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
24 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
|
25 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
26 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
27 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
28 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
29 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
30 |
POSSIBILITY OF SUCH DAMAGE. |
|
31 |
*/ |
|
32 |
|
|
33 |
require_once("config.inc"); |
|
34 |
require_once("functions.inc"); |
|
35 |
|
|
36 |
$removed = 0; |
|
37 |
if (!is_array($config['system']['user'])) |
|
38 |
return; |
|
39 |
|
|
40 |
$count = count($config['system']['user']); |
|
41 |
$index = 0; |
|
42 |
for(; $index < $count; $index++) { |
|
43 |
$user =& $config['system']['user'][$index]; |
|
44 |
if($user['scope'] == "system") |
|
45 |
continue; |
|
46 |
echo "1\n"; |
|
47 |
echo "User {$user['name']} expires {$user['expires']}\n"; |
|
48 |
if(!$user['expires']) |
|
49 |
continue; |
|
50 |
echo "1\n"; |
|
51 |
if(strtotime("-1 day") > strtotime($user['expires'])) { |
|
52 |
echo "Disabling user {$user['name']} at index #{$index}\n"; |
|
53 |
//unset($config['system']['user'][$index]); |
|
54 |
$user['disabled'] = true; |
|
55 |
$removed++; |
|
56 |
$count--; |
|
57 |
$index--; |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
if($removed > 0) |
|
62 |
write_config("Expired {$removed} user accounts"); |
|
63 |
|
|
64 |
//print_r($config); |
|
65 |
|
|
66 |
?> |
Also available in: Unified diff
Correct typo in file name. Also do not delete users just expire them.