Server IP : 103.53.40.154 / Your IP : 18.117.78.87 Web Server : Apache System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : ppcad7no ( 715) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /etc/subversion/../cron.hourly/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
#! /usr/bin/env perl use Sys::Syslog; use strict; use warnings; my $conf = "/opt/mod_security/modsec_localips.txt"; my $time = time; my $tmpname = "$conf.new.$time"; my @ips = qx(/sbin/ip addr) =~ /((?:\d+\.){3}\d+)/g; my $old = slurp($conf); my $new = join("\n", map { "/$_/" } sort @ips)."\n"; exit if $old eq $new; # don't kick apache if local IPs haven't changed open my $tmp, '>', $tmpname or die "Unable to open $tmpname for writing : $!"; chmod 0640, $tmpname; print {$tmp} $new; close $tmp && rename $tmpname => $conf; restart_apache(); sub slurp { my ($file) = @_; local $/ = undef; open my $f, '<', $file or warn "Unable to open $file for reading : $!"; my $content = <$f>; close $f; return $content } sub restart_apache { openlog 'update_modsec_localips', 'cons,pid', 'LOG_USER'; syslog 'notice', 'local IPs changed, so httpd reloaded'; if ( -x '/usr/local/cpanel/bin/servers_queue' ) { exec "/usr/local/cpanel/bin/servers_queue queue apache_restart >/dev/null"; } elsif ( -x '/usr/sbin/apachectl' ) { exec "/usr/sbin/apachectl -t && /usr/sbin/apachectl -k graceful"; } else { syslog 'notice', 'Apache binary not found. Failed to restart!'; } return; }