From 9649dd42228f0f2fdaf26948a96b014a190f9c56 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sat, 8 Jul 2017 12:05:32 +0200 Subject: [PATCH] Add a script to create and delete php pool dirs --- createlinks | 5 ++++ root/etc/e-smith/events/actions/php-pool-dirs | 34 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 root/etc/e-smith/events/actions/php-pool-dirs diff --git a/createlinks b/createlinks index b76c06e..ba1b5ff 100644 --- a/createlinks +++ b/createlinks @@ -23,3 +23,8 @@ foreach my $file qw( /etc/php-fpm.conf /etc/opt/remi/php71/php-fpm.d/shares.conf ){ templates2events($file, qw(webapps-update bootstrap-console-save)); } + +event_link("php-pool-dirs", "share-create", "90"); +event_link("php-pool-dirs", "share-modify", "90"); +event_link("php-pool-dirs", "share-modify-server", "90"); +event_link("php-pool-dirs", "share-delete", "90"); diff --git a/root/etc/e-smith/events/actions/php-pool-dirs b/root/etc/e-smith/events/actions/php-pool-dirs new file mode 100644 index 0000000..93bd442 --- /dev/null +++ b/root/etc/e-smith/events/actions/php-pool-dirs @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use esmith::AccountsDB; +use File::Path qw(make_path remove_tree); + +my $a = esmith::AccountsDB->open_ro || die "Couldn't open the accounts database\n"; + +my $event = shift; +my $pool = shift; + +die "Misssing pool name argument" unless $pool; + +my $acc = $a->get($pool); + +die "$pool not found in the account database\n" unless $acc; + +my $dyn = $acc->prop('DynamicContent') || 'disabled'; + +if ($acc =~ m/^enabled|on|1|yes$/){ + make_path( qw( /var/log/php/$pool + /var/lib/php/$pool/session + /var/lib/php/$pool/wsdlcache + /var/lib/php/$pool/opcache + /var/lib/php/$pool/tmp ), { + chmode => 0770, + owner => 'root', + group => 'www' + }); +} +else{ + remote_tree( qw(/var/log/php/$pool /var/lib/php/$pool/) ); +}