From 6f64cb8c3f1fd9e82d2c2477d7f01c8c526671fb Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 12 Jul 2017 18:26:36 +0200 Subject: [PATCH] run tmpwatch for PHP temp dir --- createlinks | 2 ++ .../templates.metadata/etc/cron.daily/tmpwatch-php-fpm | 1 + .../templates/etc/cron.daily/tmpwatch-php-fpm/10Defaults | 8 ++++++++ .../templates/etc/cron.daily/tmpwatch-php-fpm/20Shares | 14 ++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 root/etc/e-smith/templates.metadata/etc/cron.daily/tmpwatch-php-fpm create mode 100644 root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/10Defaults create mode 100644 root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/20Shares diff --git a/createlinks b/createlinks index 478cd7c..adf9e4e 100644 --- a/createlinks +++ b/createlinks @@ -28,6 +28,8 @@ foreach my $file qw( /etc/php-fpm.conf safe_symlink('/etc/e-smith/templates-default/template-begin-ini', "root/etc/e-smith/templates$file/template-begin"); } +safe_symlink('/etc/e-smith/templates-default/template-begin-shell', 'root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm'); + foreach my $file qw( /etc/sysconfig/php-fpm /opt/remi/php56/root/etc/sysconfig/php-fpm /etc/opt/remi/php70/sysconfig/php-fpm diff --git a/root/etc/e-smith/templates.metadata/etc/cron.daily/tmpwatch-php-fpm b/root/etc/e-smith/templates.metadata/etc/cron.daily/tmpwatch-php-fpm new file mode 100644 index 0000000..6bbf39b --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/cron.daily/tmpwatch-php-fpm @@ -0,0 +1 @@ +PERMS=0755 diff --git a/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/10Defaults b/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/10Defaults new file mode 100644 index 0000000..7510980 --- /dev/null +++ b/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/10Defaults @@ -0,0 +1,8 @@ + +for VER in php php56 php70 php71; do + /usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$VER/tmp + /usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$VER/opcache + /usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$VER/wsdlcache + /usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$VER/opcache +done + diff --git a/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/20Shares b/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/20Shares new file mode 100644 index 0000000..301fc42 --- /dev/null +++ b/root/etc/e-smith/templates/etc/cron.daily/tmpwatch-php-fpm/20Shares @@ -0,0 +1,14 @@ +{ +use esmith::AccountsDB; +my $a = esmith::AccountsDB->open_ro || die "Couldn't open the accounts database\n"; +foreach my $share ($a->get_all_by_prop(type => 'share')){ + next unless (($share->prop('DynamicContent') || 'disabled') =~ m/^enabled|on|yes|1$/); + my $key = $share->key; + $OUT .=_EOF; +/usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$key/tmp +/usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$key/opcache +/usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$key/wsdlcache +/usr/sbin/tmpwatch -umc --nodirs -q 7d /var/lib/php/$key/opcache +_EOF +} +}