Initial packaging
This commit is contained in:
commit
38893b38be
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
php-defaults (1) unstable; urgency=low
|
||||
|
||||
* Initial php-defaults package
|
||||
|
||||
-- Ondřej Surý <ondrej@debian.org> Wed, 22 Jan 2014 16:47:30 +0100
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
9
|
141
debian/control
vendored
Normal file
141
debian/control
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
Source: php-defaults
|
||||
Section: php
|
||||
Priority: optional
|
||||
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
|
||||
Uploaders: Ondřej Surý <ondrej@debian.org>,
|
||||
Thijs Kinkhorst <thijs@debian.org>,
|
||||
Lior Kaplan <kaplan@debian.org>
|
||||
Standards-Version: 3.9.6
|
||||
Build-Depends: debhelper (>= 9)
|
||||
Vcs-Browser: http://anonscm.debian.org/?p=pkg-php/php-defaults.git
|
||||
Vcs-Git: git://anonscm.debian.org/pkg-php/php-defaults.git
|
||||
|
||||
Package: php-common
|
||||
Architecture: all
|
||||
Section: php
|
||||
Description: Common files for PHP packages
|
||||
This package contains common utilities shared among all packaged PHP
|
||||
versions.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
|
||||
Package: php
|
||||
Architecture: all
|
||||
Depends: php7.0
|
||||
Description: server-side, HTML-embedded scripting language (default)
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: libapache2-mod-php
|
||||
Architecture: all
|
||||
Depends: libapache2-mod-php7.0
|
||||
Description: server-side, HTML-embedded scripting language (Apache 2 module) (default)
|
||||
This package provides the PHP module for the Apache 2 webserver.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-cgi
|
||||
Architecture: all
|
||||
Depends: php-cgi7.0
|
||||
Description: server-side, HTML-embedded scripting language (CGI binary) (default)
|
||||
This package provides the /usr/lib/cgi-bin/php CGI interpreter built
|
||||
for use in Apache 2 with mod_actions, or any other CGI httpd that
|
||||
supports a similar mechanism. Note that MOST users probably
|
||||
want the php-fpm package that provide FastCGI support.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-cli
|
||||
Architecture: all
|
||||
Depends: php-cli7.0
|
||||
Description: command-line interpreter for the PHP scripting language (default)
|
||||
This package provides the /usr/bin/php command interpreter, useful for
|
||||
testing PHP scripts from a shell or performing general shell scripting tasks.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-phpdbg
|
||||
Architecture: all
|
||||
Depends: php-phpdbg7.0
|
||||
Description: server-side, HTML-embedded scripting language (PHPDBG binary) (default)
|
||||
This package provides the /usr/bin/phpdbg command interpreter, useful for
|
||||
stepthrough debugging of PHP code.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-fpm
|
||||
Architecture: all
|
||||
Depends: php-fpm7.0
|
||||
Description: server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
|
||||
This package provides the Fast Process Manager interpreter that runs
|
||||
as a daemon and receives Fast/CGI requests.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: libphp-embed
|
||||
Architecture: all
|
||||
Depends: libphp-embed7.0
|
||||
Description: HTML-embedded scripting language (Embedded SAPI library) (default)
|
||||
This package provides the library /usr/lib/libphp.so which can
|
||||
be used by application developers to embed PHP scripting functionality.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-dev
|
||||
Architecture: all
|
||||
Depends: php7.0-dev
|
||||
Description: HTML-embedded scripting language (Embedded SAPI library) (default)
|
||||
Headers and other PHP needed for compiling additional modules.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
|
||||
Package: php-all-dev
|
||||
Architecture: all
|
||||
Depends: php7.0-dev
|
||||
Description: package depending on all supported PHP development packages
|
||||
The package currently depends on php7.0-dev.
|
||||
.
|
||||
This package is a dependency package used as a build dependency for other
|
||||
packages to avoid hardcoded dependencies on specific PHP development
|
||||
packages.
|
28
debian/copyright
vendored
Normal file
28
debian/copyright
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Author: Ondřej Surý <ondrej@debian.org>
|
||||
|
||||
Files: *
|
||||
Copyright: 2015 Ondřej Surý
|
||||
License: Expat
|
||||
|
||||
License: Expat
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
7
debian/gbp.conf
vendored
Normal file
7
debian/gbp.conf
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
[DEFAULT]
|
||||
debian-branch = master
|
||||
debian-tag = debian/%(version)s
|
||||
pristine-tar = False
|
||||
|
||||
[git-dch]
|
||||
meta = 1
|
5
debian/php-common.install
vendored
Normal file
5
debian/php-common.install
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
phpenmod /usr/sbin/
|
||||
phpquery /usr/sbin/
|
||||
sessionclean /usr/lib/php/
|
||||
php-helper /usr/lib/php/
|
||||
php-maintscript-helper /usr/lib/php/
|
14
debian/php-common.php.cron.d
vendored
Normal file
14
debian/php-common.php.cron.d
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# /etc/cron.d/php@PHP_VERSION@: crontab fragment for PHP
|
||||
# This purges session files in session.save_path older than X,
|
||||
# where X is defined in seconds as the largest value of
|
||||
# session.gc_maxlifetime from all your SAPI php.ini files
|
||||
# or 24 minutes if not defined. The script triggers only
|
||||
# when session.save_handler=files.
|
||||
#
|
||||
# WARNING: The scripts tries hard to honour all relevant
|
||||
# session PHP options, but if you do something unusual
|
||||
# you have to disable this script and take care of your
|
||||
# sessions yourself.
|
||||
|
||||
# Look for and purge old sessions every 30 minutes
|
||||
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
|
25
debian/rules
vendored
Executable file
25
debian/rules
vendored
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# debian/rules for PHP defaults
|
||||
# Copyright (C) 2011 Ondřej Surý
|
||||
# Published under the Expat license
|
||||
#
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
export DH_OPTIONS
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_configure:
|
||||
:
|
||||
|
||||
override_dh_auto_make:
|
||||
:
|
||||
|
||||
override_dh_auto_install:
|
||||
:
|
||||
|
||||
override_dh_installcron:
|
||||
dh_installcron -pphp-common --name=php
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
3.0 (native)
|
1
debian/substvars
vendored
Normal file
1
debian/substvars
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
misc:Depends=
|
218
php-helper
Normal file
218
php-helper
Normal file
|
@ -0,0 +1,218 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# php-helper - a PHP module manager for Debian
|
||||
#
|
||||
# Copyright 2013,2014,2015 Ondřej Surý <ondrej@sury.org>
|
||||
#
|
||||
# This program is licensed at your choice under the terms of the GNU General
|
||||
# Public License version 2+ or under the terms of the PHP License 3.01.
|
||||
#
|
||||
# For GPL-2+:
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
# USA.
|
||||
#
|
||||
# For PHP 3.01:
|
||||
# This source file is subject to version 3.01 of the PHP license,
|
||||
# that is bundled with this package in the file LICENSE, and is
|
||||
# available through the world-wide-web at the following url:
|
||||
# http://www.php.net/license/3_01.txt
|
||||
# If you did not receive a copy of the PHP license and are unable to
|
||||
# obtain it through the world-wide-web, please send a note to
|
||||
# license@php.net so we can mail you a copy immediately.
|
||||
#
|
||||
|
||||
warning() {
|
||||
echo "WARNING: ${@}" >&2
|
||||
}
|
||||
|
||||
remove_state() {
|
||||
local action=$1
|
||||
local version=$2
|
||||
local sapi=$3
|
||||
local modname=$4
|
||||
|
||||
local state_dir="$(get_state_dir $version $sapi)"
|
||||
rm -f "${state_dir}/${action}_by_admin/$modname"
|
||||
rm -f "${state_dir}/${action}_by_maint/$modname"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
mod_registry() {
|
||||
local action=$1
|
||||
local modname=$2
|
||||
local registry_dir="$(get_registry_dir)"
|
||||
local registry_file="$registry_dir/$modname"
|
||||
|
||||
case $action in
|
||||
register)
|
||||
if [ ! -d "$registry_dir" ]; then
|
||||
mkdir -p "$registry_dir"
|
||||
fi
|
||||
touch "$registry_file"
|
||||
;;
|
||||
unregister)
|
||||
rm -f "$registry_file"
|
||||
;;
|
||||
status)
|
||||
if [ -e "$registry_file" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
record_state() {
|
||||
local action=$1
|
||||
local version=$2
|
||||
local sapi=$3
|
||||
local modname=$4
|
||||
|
||||
local state_dir="$(get_state_dir $version $sapi)"
|
||||
local admin_state="${state_dir}/${action}_by_admin/$modname"
|
||||
local maint_state="${state_dir}/${action}_by_maint/$modname"
|
||||
|
||||
if [ -e "$admin_state" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -e "$maint_state" ]; then
|
||||
if [ "$MAINT_MODE" = "yes" ]; then
|
||||
return
|
||||
else
|
||||
rm "$maint_state"
|
||||
fi
|
||||
fi
|
||||
|
||||
# cleanup previous state
|
||||
remove_state disabled $version $sapi $modname
|
||||
remove_state enabled $version $sapi $modname
|
||||
|
||||
if [ "$MAINT_MODE" = "yes" ]; then
|
||||
mkdir -p "$(dirname $maint_state)"
|
||||
touch "$maint_state"
|
||||
else
|
||||
mkdir -p "$(dirname $admin_state)"
|
||||
touch "$admin_state"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
output() {
|
||||
if [ "$QUIET" != "yes" ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
get_priority() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
|
||||
local source_ini="/etc/php/${version}/mods-available/${modname}.ini"
|
||||
|
||||
module_ret=0
|
||||
module_exists $modname || module_ret=$?
|
||||
|
||||
if [ "$module_ret" -eq 0 ]; then
|
||||
priority=$(sed -ne "s/^; ?priority=\([0-9]\+\)$/\\1/p" $source_ini)
|
||||
[ -z "$priority" ] && priority=20
|
||||
echo $priority
|
||||
return 0
|
||||
fi
|
||||
|
||||
return $module_ret
|
||||
}
|
||||
|
||||
get_live_link() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
local priority=$4
|
||||
echo "/etc/php/${version}/${sapi}/conf.d/${priority}-${modname}.ini"
|
||||
}
|
||||
|
||||
get_live_link_content() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
local priority=$4
|
||||
echo "../../mods-available/${modname}.ini"
|
||||
}
|
||||
|
||||
module_exists() {
|
||||
local version=$1
|
||||
local modname=$2
|
||||
local source_ini="/etc/php/${version}/mods-available/${modname}.ini"
|
||||
|
||||
if [ ! -r "${source_ini}" ]; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
get_state_dir() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
echo "/var/lib/php/modules/${version}/${sapi}"
|
||||
return 0
|
||||
}
|
||||
|
||||
get_registry_dir() {
|
||||
echo "/var/lib/php/modules/registry"
|
||||
return 0
|
||||
}
|
||||
|
||||
get_version_dir() {
|
||||
echo "/usr/lib/php"
|
||||
return 0
|
||||
}
|
||||
|
||||
get_sapi_dir() {
|
||||
local version=$1
|
||||
echo "/usr/lib/php/${version}/sapi"
|
||||
return 0
|
||||
}
|
||||
|
||||
list_parts() {
|
||||
local dir=$1
|
||||
local regex=${2:-}
|
||||
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -mindepth 1 -maxdepth 1 \! \( -name '*.dpkg-old' -name '*.dpkg-new' -name '*.dpkg-dist' -name '*~' -name '*.bak' -name '*.ucf-old' -name '*.ucf-new' -name '*.ucf-dist' -name '*%' \) -printf '%f\n'
|
||||
return $?
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
list_parts_regex() {
|
||||
local dir=$1
|
||||
local regex=$2
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -mindepth 1 -maxdepth 1 -regex "$regex" -printf '%f\n'
|
||||
return $?
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
294
php-maintscript-helper
Normal file
294
php-maintscript-helper
Normal file
|
@ -0,0 +1,294 @@
|
|||
#!/bin/sh
|
||||
# php-maintscript-helper - PHP helper function for maintainer scripts
|
||||
# Copyright (C) 2012 Arno Töll <debian@toell.net>
|
||||
# 2013 Ondřej Surý <ondrej@sury.org>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
|
||||
|
||||
# global environment variables used by php-maintscript-helper:
|
||||
# * PHP_MAINTSCRIPT_DEBUG:
|
||||
# set this to any non-zero value to get debug output
|
||||
# * PHP_MAINTSCRIPT_HELPER_QUIET:
|
||||
# set this to any non-zero value to omit any output
|
||||
# * EXPORT_PHP_MAINTSCRIPT_HELPER:
|
||||
# will be defined by php-maintscript-helper
|
||||
# to avoid inclusion loops. Do not set this
|
||||
# variable manually
|
||||
# * PHP_NEED_ACTION:
|
||||
# will be defined if a function call wants to
|
||||
# override the behavior of php_needs_action.
|
||||
# Do not rely on this variable. It is considered
|
||||
# an implementation detail.
|
||||
# * PHP_MAINTSCRIPT_NAME
|
||||
# * PHP_MAINTSCRIPT_PACKAGE
|
||||
# * PHP_MAINTSCRIPT_METHOD
|
||||
# * PHP_MAINTSCRIPT_ARGUMENT
|
||||
# these variables contain information about the
|
||||
# maintainer script which is calling the
|
||||
# maintscript-helper. It contains arguments which
|
||||
# dpkg supplies to maintainer scripts and similar
|
||||
# information. These variables are an
|
||||
# implementation detail and not to be changed.
|
||||
#
|
||||
# You might want to set them manually only if you
|
||||
# are calling php-maintscript-helper from
|
||||
# some place which does not preserve the original
|
||||
# script arguments for example when calling from
|
||||
# a subfunction instead of the main function in
|
||||
# your maintainer script
|
||||
|
||||
#
|
||||
# INITIALIZATION
|
||||
#
|
||||
|
||||
if [ -n "${EXPORT_PHP_MAINTSCRIPT_HELPER:-}" ] ; then
|
||||
return
|
||||
else
|
||||
EXPORT_PHP_MAINTSCRIPT_HELPER=1
|
||||
|
||||
if [ -n "${PHP_MAINTSCRIPT_DEBUG:-}" ] ; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [ -z "$1" ] ; then
|
||||
echo "You must invoke php-maintscript-helper with an unmodified environment when sourcing it" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
PHP_MAINTSCRIPT_NAME="$DPKG_MAINTSCRIPT_NAME"
|
||||
[ "$PHP_MAINTSCRIPT_NAME" ] || PHP_MAINTSCRIPT_NAME="${0##*.}"
|
||||
|
||||
case "$PHP_MAINTSCRIPT_NAME" in
|
||||
preinst|prerm|postrm|postinst)
|
||||
# yay - recognized script
|
||||
;;
|
||||
*)
|
||||
echo "php-maintscript-helper invoked from an unrecognized maintainer script: exiting" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
PHP_MAINTSCRIPT_PACKAGE="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
if [ -z "$PHP_MAINTSCRIPT_PACKAGE" ]; then
|
||||
PHP_MAINTSCRIPT_PACKAGE="${0##*/}"
|
||||
PHP_MAINTSCRIPT_PACKAGE="${PHP_MAINTSCRIPT_PACKAGE%.*}"
|
||||
fi
|
||||
|
||||
if [ -z "$PHP_MAINTSCRIPT_METHOD" ] ; then
|
||||
PHP_MAINTSCRIPT_METHOD="$1"
|
||||
fi
|
||||
|
||||
case "$PHP_MAINTSCRIPT_METHOD" in
|
||||
install|upgrade|abort-upgrade|configure|abort-remove|abort-remove|abort-deconfigure|remove|failed-upgrade|purge|disappear|abort-install)
|
||||
# yay - recognized script
|
||||
;;
|
||||
*)
|
||||
echo "php-maintscript-helper invoked from a modified environment. Please hint required arguments manually" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$PHP_MAINTSCRIPT_ARGUMENT" ] ; then
|
||||
PHP_MAINTSCRIPT_ARGUMENT="${2:-}"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
#
|
||||
# FUNCTIONS
|
||||
#
|
||||
|
||||
#
|
||||
# Function php_msg
|
||||
# print out a warning to both, the syslog and a local standard output.
|
||||
# This function should generally be used to display messages related to
|
||||
# the web server in maintainer scripts.
|
||||
# Parameters:
|
||||
# priority
|
||||
# The message priority. Recognized values are the same as defined
|
||||
# by syslog(3), thus: one among debug, info, notice, warning,
|
||||
# err, crit, alert, emerg.
|
||||
# If no known priority is recognized, the priority is set to
|
||||
# "warning".
|
||||
# message
|
||||
# The message as a string. It is printed out verbatim.
|
||||
# Behavior:
|
||||
# No message is displayed if PHP_MAINTSCRIPT_HELPER_QUIET is defined
|
||||
# Returns:
|
||||
# this function always returns 0
|
||||
# Since: 5.5.0+dfsg-7
|
||||
php_msg()
|
||||
{
|
||||
local PRIORITY="$1"
|
||||
local MSG="$2"
|
||||
case "$PRIORITY" in
|
||||
debug|info|notice|warning|err|crit|alert|emerg)
|
||||
;;
|
||||
*)
|
||||
PRIORITY="warning"
|
||||
;;
|
||||
esac
|
||||
[ -z "$PHP_MAINTSCRIPT_HELPER_QUIET" ] && ( [ -n "${PHP_MAINTSCRIPT_DEBUG:-}" ] || [ "$PRIORITY" != "debug" ] ) && echo "$MSG" >&2
|
||||
[ -x /usr/bin/logger ] || return 0
|
||||
local LOGGER="/usr/bin/logger -p daemon.$PRIORITY -t $PHP_MAINTSCRIPT_PACKAGE "
|
||||
$LOGGER "$MSG" || return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Function php_invoke
|
||||
# invokes an PHP configuration helper to enable or disable a
|
||||
# particular piece of configuration, a site or a module. It carefully
|
||||
# checks whether the supplied configuration snippet exists and reloads the
|
||||
# web server if the site administrator desires that by call dpkg trigger
|
||||
# /etc/php/VERSION/SAPI/conf.d which is defined for apache2, apache2filter and fpm.
|
||||
#
|
||||
# Parameters:
|
||||
# command - The command to invoke. Recognized commands are "enconf",
|
||||
# "enmod", "ensite", "disconf", "dismod", "dissite"
|
||||
#
|
||||
# sapi - Either the specific SAPI (apache2, apache2filter, fpm,
|
||||
# cgi, cli, embed) or ALL
|
||||
#
|
||||
# arguments
|
||||
# - A single argument (e.g. a module) which shall be
|
||||
# enabled or disabled respectively.
|
||||
#
|
||||
# Returns
|
||||
# 0 if the changes could be activated
|
||||
# 1 otherwise
|
||||
# Since: 5.5.0+dsfg-7
|
||||
php_invoke()
|
||||
{
|
||||
local CMD=$1
|
||||
local VERSION=$2
|
||||
local SAPI=$3
|
||||
local MOD=$4
|
||||
local check_switch=""
|
||||
local invoke_string=""
|
||||
local rcd_action=""
|
||||
local rcd_scripts=""
|
||||
local sapi_list=""
|
||||
|
||||
[ -x "/usr/sbin/php$CMD" ] || return 1
|
||||
[ -x "/usr/sbin/phpquery" ] || return 1
|
||||
|
||||
version_list="$VERSION"
|
||||
|
||||
case "$VERSION" in
|
||||
ALL)
|
||||
version_list=$(phpquery -V)
|
||||
;;
|
||||
*)
|
||||
# FIXME - check if the version is supported
|
||||
:
|
||||
;;
|
||||
esac
|
||||
|
||||
for VERSION in $version_list; do
|
||||
|
||||
sapi_list="$SAPI"
|
||||
case "$SAPI" in
|
||||
apache2|apache2filter|fpm|cli|cgi|embed)
|
||||
;;
|
||||
ALL)
|
||||
sapi_list=$(phpquery -S -v $version)
|
||||
case "$CMD" in
|
||||
enmod|dismod)
|
||||
php$CMD -q -m -r "$MOD" || return 1
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
for SAPI in $sapi_list; do
|
||||
case "$CMD" in
|
||||
enmod)
|
||||
local phpquery_ret=0
|
||||
phpquery -v "$VERSION" -s "$SAPI" -m "$MOD" > /dev/null 2>&1 || phpquery_ret=$?
|
||||
if [ "$phpquery_ret" -eq 0 ] ; then
|
||||
# configuration is already enabled
|
||||
php$CMD -m -v "$VERSION" -s "$SAPI" -q "$MOD" > /dev/null 2>&1 || return 1
|
||||
php_msg "debug" "php_invoke $MOD: already enabled for PHP $VERSION $SAPI SAPI"
|
||||
PHP_NEED_ACTION=1
|
||||
elif [ "$phpquery_ret" -eq 32 ] ; then
|
||||
# the maintainer disabled the module
|
||||
php_msg "info" "php_invoke $MOD: no action - module was disabled by maintainer for PHP $VERSION $SAPI SAPI"
|
||||
return 0
|
||||
else
|
||||
# coming here either means:
|
||||
# a) we have no clue about the module (e.g. for upgrades prior to maintscript-helper
|
||||
# b) it's a fresh install
|
||||
PHP_NEED_ACTION=1
|
||||
php$CMD -m -v "$VERSION" -s "$SAPI" -q "$MOD" > /dev/null 2>&1 || return 1
|
||||
php_msg "info" "php_invoke: Enable module $MOD for $SAPI SAPI"
|
||||
fi
|
||||
;;
|
||||
dismod)
|
||||
local phpquery_ret=0
|
||||
phpquery -v "$VERSION" -s "$SAPI" -m "$MOD" > /dev/null 2>&1 || phpquery_ret=$?
|
||||
if [ "$phpquery_ret" -eq 0 ] ; then
|
||||
if [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] && [ "$PHP_MAINTSCRIPT_METHOD" = "purge" ] ; then
|
||||
php$CMD -p -f -v "$VERSION" -s "$SAPI" -q "$MOD" || return 1
|
||||
php_msg "debug" "php_invoke $PHP_MAINTSCRIPT_NAME: Purging module $MOD for $SAPI SAPI"
|
||||
PHP_NEED_ACTION=1
|
||||
elif [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] || [ "$PHP_MAINTSCRIPT_NAME" = 'prerm' ] ; then
|
||||
if [ "$PHP_MAINTSCRIPT_METHOD" = "remove" ] ; then
|
||||
php$CMD -m -f -v "$VERSION" -s "$SAPI" -q "$MOD" || return 1
|
||||
php_msg "info" "php_invoke $PHP_MAINTSCRIPT_NAME: Disable module $MOD for $SAPI SAPI"
|
||||
PHP_NEED_ACTION=1
|
||||
fi
|
||||
else
|
||||
php_msg "error" "php_invoke: module $MOD not supported in $PHP_MAINTSCRIPT_NAME for PHP $VERSION $SAPI SAPI"
|
||||
return 1
|
||||
fi
|
||||
elif [ "$phpquery_ret" -eq 32 ] || [ "$phpquery_ret" -eq 33 ] ; then
|
||||
if [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] && [ "$PHP_MAINTSCRIPT_METHOD" = "purge" ] ; then
|
||||
php_msg "debug" "php_invoke $PHP_MAINTSCRIPT_NAME: Purging state for $MOD for PHP $VERSION $SAPI SAPI"
|
||||
# this will return RC=1
|
||||
( php$CMD -p -f -v "$VERSION" -s "$SAPI" -q "$MOD" > /dev/null 2>&1 )
|
||||
else
|
||||
php_msg "debug" "php_invoke $MOD $PHP_MAINTSCRIPT_NAME: No action required for PHP $VERSION $SAPI SAPI"
|
||||
fi
|
||||
else
|
||||
php_msg "debug" "php_invoke $MOD $PHP_MAINTSCRIPT_NAME: No action required for PHP $VERSION $SAPI SAPI"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
if [ -n "${PHP_NEED_ACTION:-}" -a -n "$rcd_action" ]; then
|
||||
dpkg-trigger /etc/php/$VERSION/$SAPI/conf.d
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# vim: syntax=sh sw=8 sts=8 sr noet
|
293
phpenmod
Executable file
293
phpenmod
Executable file
|
@ -0,0 +1,293 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# phpenmod - a PHP module manager for Debian
|
||||
#
|
||||
# Copyright 2013 Ondřej Surý <ondrej@sury.org>
|
||||
#
|
||||
# This program is licensed at your choice under the terms of the GNU General
|
||||
# Public License version 2+ or under the terms of the PHP License 3.01.
|
||||
#
|
||||
# For GPL-2+:
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
# USA.
|
||||
#
|
||||
# For PHP 3.01:
|
||||
# This source file is subject to version 3.01 of the PHP license,
|
||||
# that is bundled with this package in the file LICENSE, and is
|
||||
# available through the world-wide-web at the following url:
|
||||
# http://www.php.net/license/3_01.txt
|
||||
# If you did not receive a copy of the PHP license and are unable to
|
||||
# obtain it through the world-wide-web, please send a note to
|
||||
# license@php.net so we can mail you a copy immediately.
|
||||
#
|
||||
|
||||
set -ue
|
||||
|
||||
SCRIPT_NAME=${0##*/}
|
||||
QUIET=no
|
||||
NEED_RESTART=no
|
||||
MAINT_MODE=no
|
||||
|
||||
. /usr/lib/php/php-helper
|
||||
|
||||
usage() {
|
||||
[ -n "$@" ] && warning $@
|
||||
echo "usage: ${SCRIPT_NAME} [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
resolve_versions() {
|
||||
local versions=$1
|
||||
if [ "$versions" = "ALL" ]; then
|
||||
versions=$(phpquery -V)
|
||||
fi
|
||||
echo $versions
|
||||
}
|
||||
|
||||
resolve_sapis() {
|
||||
local version=$1
|
||||
local sapis=$2
|
||||
|
||||
if [ "$sapis" = "ALL" ]; then
|
||||
sapis=$(phpquery -S -v $version)
|
||||
fi
|
||||
echo $sapis
|
||||
}
|
||||
|
||||
enmods() {
|
||||
local _versions="$1"
|
||||
local _sapis="$2"
|
||||
local mods="$3"
|
||||
local register="$4"
|
||||
local versions
|
||||
local sapis
|
||||
local version
|
||||
local sapi
|
||||
local mod
|
||||
|
||||
for mod in $mods; do
|
||||
for version in $(resolve_versions "$versions"); do
|
||||
for sapi in $(resolve_sapis $version "$sapis"); do
|
||||
enmod_ret=0
|
||||
enmod $version $sapi $mod || enmod_ret=$?
|
||||
case $enmod_ret in
|
||||
0)
|
||||
NEED_RESTART=yes
|
||||
record_state enabled $version $sapi $mod
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
if [ "$register" = "yes" ]; then
|
||||
mod_registry register $mod
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
dismods() {
|
||||
local versions="$1"
|
||||
local sapis="$2"
|
||||
local mods="$3"
|
||||
local register="$4"
|
||||
local purge="$5"
|
||||
local version
|
||||
local sapi
|
||||
local mod
|
||||
|
||||
for mod in $mods; do
|
||||
for version in $(resolve_versions "$versions"); do
|
||||
for sapi in $(resolve_sapis $version "$sapis"); do
|
||||
local dismod_ret=0
|
||||
dismod $version $sapi $mod $purge || dismod_ret=$?
|
||||
case $dismod_ret in
|
||||
0)
|
||||
NEED_RESTART=yes
|
||||
record_state disabled $version $sapi $mod
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
if [ "$purge" = "yes" ]; then
|
||||
remove_state enabled $sapi $mod
|
||||
remove_state disabled $sapi $mod
|
||||
mod_registry unregister $mod
|
||||
elif [ "$register" = "yes" ]; then
|
||||
mod_registry unregister $mod
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
enmod() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
|
||||
if ! module_exists $version $modname; then
|
||||
warning "Module $modname ini file doesn't exist under /etc/php/${version}/mods-available"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local priority=$(get_priority $version $sapi $modname)
|
||||
local live_link=$(get_live_link $version $sapi $modname $priority)
|
||||
local live_link_content=$(get_live_link_content $version $sapi $modname $priority)
|
||||
|
||||
local module_state=0
|
||||
phpquery -q -v $version -s $sapi -m $modname || module_state=$?
|
||||
|
||||
case $module_state in
|
||||
# module enabled, but re-enable the conf.d link just in case
|
||||
0)
|
||||
;;
|
||||
# module not yet enabled
|
||||
1)
|
||||
;;
|
||||
# module disabled by maintainer script
|
||||
33)
|
||||
;;
|
||||
# module disabled by site administrator
|
||||
# enable module only if not running in maintainer mode
|
||||
32)
|
||||
if [ "$MAINT_MODE" = "yes" ]; then
|
||||
warning "Not enabling the ${modname} module for PHP ${version} ${sapi} SAPI since the module"
|
||||
warning "was disabled by local administrator."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
34)
|
||||
warning "Not enabling the ${modname} module for PHP ${version} ${sapi} SAPI since module symlink"
|
||||
warning "already exists in /etc/php/${version}/${sapi}/conf.d with different content."
|
||||
return 1
|
||||
;;
|
||||
# fail if we get any different result
|
||||
*)
|
||||
warning "Unable to get module state, run phpquery -v $version -s $sapi -m $modname manually"
|
||||
warning "and fix the module state."
|
||||
return 1
|
||||
esac
|
||||
|
||||
if [ -d "/etc/php/${version}/$sapi/conf.d" ]; then
|
||||
if [ ! -h "${live_link}" ]; then
|
||||
ln -s "${live_link_content}" "${live_link}"
|
||||
fi
|
||||
else
|
||||
warning "Directory /etc/php/${version}/${sapi}/conf.d doesn't exist, not enabling the module"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
dismod() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
local purge=$4
|
||||
|
||||
if ! module_exists $version $modname; then
|
||||
if [ "$purge" = "no" ]; then
|
||||
warning "Module $modname ini file doesn't exist under /etc/php/${version}/mods-available"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local priority=$(get_priority $version $sapi $modname)
|
||||
local live_link=$(get_live_link $version $sapi $modname $priority)
|
||||
local live_link_content=$(get_live_link_content $version $sapi $modname $priority)
|
||||
|
||||
local module_state=0
|
||||
phpquery -q -v $version -s $sapi -m $modname || module_state=$?
|
||||
|
||||
case $module_state in
|
||||
# module enabled
|
||||
0)
|
||||
;;
|
||||
# module not enabled, but re-remove the link just in case
|
||||
1|32|33)
|
||||
;;
|
||||
34)
|
||||
warning "Not disabling module $modname for $sapi SAPI. The configuration was"
|
||||
warning "modified by local administrator."
|
||||
return 1
|
||||
;;
|
||||
# fail if we get any different result
|
||||
*)
|
||||
warning "Unable to get module state, run phpquery -v $version -s $sapi -m $modname manually"
|
||||
warning "and fix the module state."
|
||||
return 1
|
||||
esac
|
||||
|
||||
if [ -d "/etc/php/$version/$sapi/conf.d" ]; then
|
||||
if [ -h "$live_link" ]; then
|
||||
rm -f "$live_link"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
versions=
|
||||
sapis=
|
||||
register=no
|
||||
purge=no
|
||||
while getopts pfv:s:mqr opt; do
|
||||
case $opt in
|
||||
r) register=yes;;
|
||||
v)
|
||||
if [ "$versions" = "ALL" -o \( "$OPTARG" = "ALL" -a -n "$versions" \) ]; then
|
||||
warning "You cannot specify ALL and individual versions"
|
||||
usage
|
||||
fi
|
||||
versions="${versions}${versions:+ }$OPTARG"
|
||||
;;
|
||||
s)
|
||||
if [ "$sapis" = "ALL" -o \( "$OPTARG" = "ALL" -a -n "$sapis" \) ]; then
|
||||
warning "You cannot specify ALL and individual sapis"
|
||||
usage
|
||||
fi
|
||||
sapis="${sapis}${sapis:+ }$OPTARG"
|
||||
;;
|
||||
m) MAINT_MODE=yes;;
|
||||
p) purge=yes;;
|
||||
q) QUIET=yes;;
|
||||
\?) usage;;
|
||||
esac
|
||||
done
|
||||
shift $(expr $OPTIND - 1)
|
||||
mods=""
|
||||
for mod in $@; do
|
||||
mods="${mods}${mods:+ }${mod%%/*}"
|
||||
done
|
||||
if [ "$register" = "no" ]; then
|
||||
sapis="${sapis:-ALL}"
|
||||
|
||||
if [ "$sapis" = "ALL" ]; then
|
||||
register=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -z "$mods" ] && usage
|
||||
|
||||
case "${SCRIPT_NAME}" in
|
||||
phpenmod)
|
||||
enmods "$versions" "$sapis" "$mods" "$register"
|
||||
;;
|
||||
phpdismod)
|
||||
dismods "$versions" "$sapis" "$mods" "$register" "$purge"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
exit 0
|
261
phpquery
Executable file
261
phpquery
Executable file
|
@ -0,0 +1,261 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# phpquery - a PHP module manager for Debian
|
||||
#
|
||||
# Copyright 2013 Ondřej Surý <ondrej@sury.org>
|
||||
#
|
||||
# This program is licensed at your choice under the terms of the GNU General
|
||||
# Public License version 2+ or under the terms of the PHP License 3.01.
|
||||
#
|
||||
# For GPL-2+:
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
# USA.
|
||||
#
|
||||
# For PHP 3.01:
|
||||
# This source file is subject to version 3.01 of the PHP license,
|
||||
# that is bundled with this package in the file LICENSE, and is
|
||||
# available through the world-wide-web at the following url:
|
||||
# http://www.php.net/license/3_01.txt
|
||||
# If you did not receive a copy of the PHP license and are unable to
|
||||
# obtain it through the world-wide-web, please send a note to
|
||||
# license@php.net so we can mail you a copy immediately.
|
||||
#
|
||||
|
||||
set -ue
|
||||
|
||||
SCRIPT_NAME=${0##*/}
|
||||
QUIET=no
|
||||
|
||||
. /usr/lib/php/php-helper
|
||||
|
||||
usage() {
|
||||
[ -n "$@" ] && warning $@
|
||||
echo "usage: ${SCRIPT_NAME} [ -d ] [ -q ] -v version_name -s sapi_name [ -m module_name ] [ -M ] [ -S ] [ -V ]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
check_mod() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local modname=$3
|
||||
|
||||
if ! module_exists $version $modname; then
|
||||
output "No module matches $modname"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local priority=$(get_priority $version $sapi $modname)
|
||||
local live_link=$(get_live_link $version $sapi $modname $priority)
|
||||
local live_link_content=$(get_live_link_content $version $sapi $modname $priority)
|
||||
|
||||
found=no
|
||||
if [ -e "${live_link}" ] ; then
|
||||
if [ -h "${live_link}" ] ; then
|
||||
local content="$(readlink "${live_link}")"
|
||||
if [ "${content}" = "${live_link_content}" ] ; then
|
||||
found=yes
|
||||
fi
|
||||
fi
|
||||
if [ "$found" != "yes" ]; then
|
||||
output "Module $modname symlink was modified by local administrator."
|
||||
return 34
|
||||
fi
|
||||
fi
|
||||
|
||||
local state_dir="$(get_state_dir $version $sapi)"
|
||||
|
||||
if [ -e "${state_dir}/enabled_by_admin/$modname" ]; then
|
||||
output "$modname (Enabled for $sapi by local administrator)"
|
||||
return 0
|
||||
elif [ -e "${state_dir}/enabled_by_maint/$modname" ]; then
|
||||
output "$modname (Enabled for $sapi by maintainer script)"
|
||||
return 0
|
||||
elif [ -e "${state_dir}/disabled_by_admin/$modname" ]; then
|
||||
output "No module matches $modname (Disabled for $sapi by local administrator)"
|
||||
return 32
|
||||
elif [ -e "${state_dir}/disabled_by_maint/$modname" ]; then
|
||||
output "No module matches $modname (Disabled for $sapi by maintainer script)"
|
||||
return 33
|
||||
elif [ "$found" = "yes" ]; then
|
||||
output "$modname (Enabled for $sapi by unknown)"
|
||||
return 0
|
||||
else
|
||||
output "No module matches $modname"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
list_mod() {
|
||||
local verbose=$1
|
||||
local registry_dir="$(get_registry_dir)"
|
||||
|
||||
if [ -d "$registry_dir" ]; then
|
||||
for mod in $(list_parts "$registry_dir"); do
|
||||
versions=$(list_version)
|
||||
for version in $versions; do
|
||||
sapis=$(list_sapi $version)
|
||||
if [ "$verbose" = "yes" ]; then
|
||||
for sapi in $sapis; do
|
||||
check_mod $version $sapi $mod
|
||||
done
|
||||
else
|
||||
echo $mod
|
||||
fi
|
||||
done
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
list_version() {
|
||||
local version_dir="$(get_version_dir)"
|
||||
if [ -d "$version_dir" ]; then
|
||||
for version in $(list_parts_regex "$version_dir" '.*[0-9]\.[0-9]'); do
|
||||
echo $version;
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
list_sapi() {
|
||||
local version=$1
|
||||
local sapi_dir="$(get_sapi_dir $version)"
|
||||
|
||||
if [ -d "$sapi_dir" ]; then
|
||||
for sapi in $(list_parts "$sapi_dir"); do
|
||||
echo $sapi;
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
check_version() {
|
||||
local version=$1
|
||||
local version_dir=$(get_version_dir)
|
||||
if [ -d "$version_dir/$version" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_sapi() {
|
||||
local version=$1
|
||||
local sapi=$2
|
||||
local sapi_dir="$(get_sapi_dir $version)"
|
||||
|
||||
if [ -e "$sapi_dir/$sapi" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
QUIET=no
|
||||
verbose=no
|
||||
action=
|
||||
sapi=
|
||||
|
||||
double_action() {
|
||||
usage "Cannot use $1 and $2 at the same time, pick only one mode of operation.";
|
||||
}
|
||||
|
||||
while getopts ds:m:SMqv:V opt; do
|
||||
case $opt in
|
||||
v)
|
||||
new_action=check_version
|
||||
if [ -n "$action" ]; then
|
||||
case "$action" in
|
||||
check_mod|check_sapi) new_action= ;; # check_mod and check_sapi wins
|
||||
*) double_action $action $new_action
|
||||
esac
|
||||
else
|
||||
action=$new_action
|
||||
fi
|
||||
version="$OPTARG"
|
||||
;;
|
||||
V)
|
||||
new_action=list_version
|
||||
if [ -n "$action" ]; then double_action $action $new_action; fi
|
||||
;;
|
||||
s)
|
||||
new_action=check_sapi
|
||||
case "$action" in
|
||||
check_mod) new_action= ;; # check_mod wins
|
||||
check_version) ;;
|
||||
"") ;;
|
||||
*) double_action $action $new_action
|
||||
esac
|
||||
sapi="$OPTARG"
|
||||
;;
|
||||
S)
|
||||
new_action="list_sapi"
|
||||
if [ -n "$action" ]; then double_action $action $new_action; fi
|
||||
;;
|
||||
m)
|
||||
new_action=check_mod
|
||||
case "$action" in
|
||||
"") ;;
|
||||
check_version|check_sapi) ;;
|
||||
*) double_action $action $new_action ;;
|
||||
esac
|
||||
mod="$OPTARG"
|
||||
;;
|
||||
M)
|
||||
new_action="list_mod"
|
||||
if [ -n "$action" ]; then double_action $action $new_action; fi
|
||||
;;
|
||||
d)
|
||||
verbose=yes
|
||||
;;
|
||||
q)
|
||||
QUIET=yes
|
||||
;;
|
||||
\?) usage "Unknown parameter specified";;
|
||||
esac
|
||||
[ -n "$new_action" ] && action=$new_action
|
||||
done
|
||||
shift $(expr $OPTIND - 1)
|
||||
|
||||
if [ -z "$action" ]; then
|
||||
usage "You need to specify at least one action."
|
||||
fi
|
||||
|
||||
ret=0
|
||||
case "$action" in
|
||||
check_mod)
|
||||
[ -z "$version" -o -z "$sapi" ] && usage "You need to specify version (-v) and sapi (-s)"
|
||||
check_version $version || usage "Invalid PHP version ($version) specified"
|
||||
check_sapi $sapi || usage "Invalid SAPI ($sapi) specified"
|
||||
check_mod $version $sapi $mod || ret=$?
|
||||
;;
|
||||
check_sapi)
|
||||
[ -z "$version" ] && usage "You need to specify version (-v)"
|
||||
check_version $version || usage "Invalid PHP version ($version) specified"
|
||||
check_sapi $version $sapi || ret=$?
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
output "$sapi"
|
||||
fi
|
||||
;;
|
||||
check_version)
|
||||
check_version $version || ret=$?
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
output "$sapi"
|
||||
fi
|
||||
;;
|
||||
list_version) list_version || ret=$?;;
|
||||
list_mod) list_mod $verbose || ret=$?;;
|
||||
list_sapi) list_sapi || ret=$?;;
|
||||
*) usage "Unknown action $action";;
|
||||
esac
|
||||
|
||||
exit $ret
|
36
sessionclean
Executable file
36
sessionclean
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
SAPIS="apache2:apache2\napache2filter:apache2\ncgi:php5\nfpm:php5-fpm\n"
|
||||
|
||||
# Iterate through all web SAPIs
|
||||
(
|
||||
for version in $(/usr/sbin/phpquery -V); do
|
||||
proc_names=""
|
||||
printf "$SAPIS" | \
|
||||
while IFS=: read -r conf_dir proc_name; do
|
||||
if [ -e /etc/php5/${version}/${conf_dir}/php.ini ]; then
|
||||
# Get all session variables once so we don't need to start PHP to get each config option
|
||||
session_config=$(php5 -c /etc/php5/${version}/${conf_dir}/php.ini -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')
|
||||
save_handler=$(echo "$session_config" | sed -ne 's/^session\.save_handler=\(.*\)$/\1/p')
|
||||
save_path=$(echo "$session_config" | sed -ne 's/^session\.save_path=\(.*;\)\?\(.*\)$/\2/p')
|
||||
gc_maxlifetime=$(($(echo "$session_config" | sed -ne 's/^session\.gc_maxlifetime=\(.*\)$/\1/p')/60))
|
||||
|
||||
if [ "$save_handler" = "files" -a -d "$save_path" ]; then
|
||||
proc_names="$proc_names $proc_name";
|
||||
printf "%s:%s\n" "$save_path" "$gc_maxlifetime"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
# first find all open session files and touch them (hope it's not massive amount of files)
|
||||
for pid in $(pidof $proc_names); do
|
||||
find "/proc/$pid/fd" -ignore_readdir_race -lname "$save_path/sess_\*" -exec touch -c {} \;
|
||||
done ) | \
|
||||
sort -rn -t: -k2,2 | \
|
||||
sort -u -t: -k 1,1 | \
|
||||
while IFS=: read -r save_path gc_maxlifetime; do
|
||||
# find all files older then maxlifetime and delete them
|
||||
find -O3 "$save_path/" -depth -ignore_readdir_race -mindepth 1 -name 'sess_*' -type f -cmin "+$gc_maxlifetime" -delete
|
||||
done
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue