From 3615b38fbf91b339dfb94b2649cbf8890956932a Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Mon, 11 Dec 2017 18:42:28 +0200 Subject: [PATCH] improved ioncube package specs --- src/deb/ioncube/postinst | 4 ++-- src/deb/ioncube/prerm | 8 ++++++++ src/deb/php/postinst | 8 ++++++++ src/rpm/conf/ioncube.sh | 23 +++++++++++++++++++---- src/rpm/specs/vesta-ioncube.spec | 12 ++++++++++-- src/rpm/specs/vesta-php.spec | 7 +++++++ 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100755 src/deb/ioncube/prerm create mode 100755 src/deb/php/postinst diff --git a/src/deb/ioncube/postinst b/src/deb/ioncube/postinst index ff9daa2c3..c9b3b1d2a 100755 --- a/src/deb/ioncube/postinst +++ b/src/deb/ioncube/postinst @@ -1,8 +1,8 @@ #!/bin/bash # Run triggers only on updates -if [ -e /usr/local/vesta/ioncube/add_ioncube.sh ]; then - /usr/local/vesta/ioncube/add_ioncube.sh +if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh add fi exit 0 diff --git a/src/deb/ioncube/prerm b/src/deb/ioncube/prerm new file mode 100755 index 000000000..9bf2bea60 --- /dev/null +++ b/src/deb/ioncube/prerm @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run triggers only on updates +if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh delete +fi + +exit 0 diff --git a/src/deb/php/postinst b/src/deb/php/postinst new file mode 100755 index 000000000..c9b3b1d2a --- /dev/null +++ b/src/deb/php/postinst @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run triggers only on updates +if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh add +fi + +exit 0 diff --git a/src/rpm/conf/ioncube.sh b/src/rpm/conf/ioncube.sh index 14d21be6d..b57672d7d 100755 --- a/src/rpm/conf/ioncube.sh +++ b/src/rpm/conf/ioncube.sh @@ -1,13 +1,28 @@ #!/bin/bash +action=${1-add} VESTA='/usr/local/vesta' ioncube="ioncube_loader_lin_5.6.so" php='/usr/local/vesta/php/lib/php.ini' -# Check if extention is enabled -if [ -z "$(grep $ioncube $php |grep -v ';')" ]; then - echo "zend_extension = '$VESTA/ioncube/$ioncube'" >> $php - /etc/init.d/vesta restart +if [ ! -e "$php" ]; then + exit +fi + +if [ ! -e "$VESTA/ioncube/$ioncube" ]; then + exit +fi + +if [ "$action" = 'install' ]; then + if [ -z "$(grep $ioncube $php |grep -v ';')" ]; then + echo "zend_extension = '$VESTA/ioncube/$ioncube'" >> $php + /etc/init.d/vesta restart + fi +else + if [ ! -z "$(grep $ioncube $php |grep -v ';')" ]; then + sed -i "/$ioncube/d" $php + /etc/init.d/vesta restart + fi fi exit diff --git a/src/rpm/specs/vesta-ioncube.spec b/src/rpm/specs/vesta-ioncube.spec index d7846bc99..64d1bdbc8 100644 --- a/src/rpm/specs/vesta-ioncube.spec +++ b/src/rpm/specs/vesta-ioncube.spec @@ -30,10 +30,18 @@ rm -rf %{buildroot} %post if [ $1 -eq 1 ]; then - if [ -e /usr/local/vesta/ioncube/add_ioncube.sh ]; then - /usr/local/vesta/ioncube/add_ioncube.sh + if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh add fi fi + +%preun +if [ $1 -eq 0 ]; then + if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh delete + fi +fi + %files %{_vestadir} diff --git a/src/rpm/specs/vesta-php.spec b/src/rpm/specs/vesta-php.spec index 966857ab9..aa99a59b0 100644 --- a/src/rpm/specs/vesta-php.spec +++ b/src/rpm/specs/vesta-php.spec @@ -40,6 +40,13 @@ rm -rf $RPM_BUILD_ROOT/.lock %clean rm -rf %{buildroot} +%post +if [ $1 -eq 1 ]; then + if [ -e /usr/local/vesta/ioncube/ioncube.sh ]; then + /usr/local/vesta/ioncube/ioncube.sh add + fi +fi + %postun if [ $1 -ge 1 ]; then if [ -e "/var/run/vesta-php.pid" ]; then