One Hat Cyber Team
Your IP :
3.142.149.3
Server IP :
104.21.48.1
Server :
Linux agrigation-prod 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64
Server Software :
nginx/1.24.0
PHP Version :
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
thread-self
/
root
/
var
/
lib
/
dpkg
/
info
/
View File Name :
newrelic-php5.postrm
#!/bin/sh # postrm script for newrelic-php5 # # see: dh_installdeb(1) # Insert the contents of newrelic-php5.config here. # Start of included newrelic-php5.common code. # Shell functions common to the config and postinst maintainer scripts. We need # to inject them into those scripts at build time. # Test whether all /etc/php5/{apache2,cgi,cli,fpm}/conf.d/newrelic.ini files # are consistent. We'll do this by taking a SHA-512 checksum of each file and # comparing them to each other: this may result in false positives if there are # whitespace or comment only changes, but that's OK, since the fallback # behavior is to warn the user and not try anything clever. are_newrelic_ini_files_consistent () { get_config_path known_hash="" # This enumerates the possible subdirectories under /etc/php5, as of Trusty. for sapi_dir in apache2 cgi cli fpm; do if test -f "/etc/php5/$sapi_dir/conf.d/newrelic.ini"; then sapi_hash=$(sha512sum "/etc/php5/$sapi_dir/conf.d/newrelic.ini" | cut -d ' ' -f 1) if test -n "$known_hash"; then if test "$known_hash" != "$sapi_hash"; then return 1 fi else known_hash="$sapi_hash" fi fi done return 0 } get_architecture () { local arch arch=$(uname -m 2> /dev/null) case $arch in i[3456789]86 | i86pc) echo x86 ;; x86_64 | amd64) echo x64 ;; *) echo "Unknown architecture: $arch" 1>&2 return 1 ;; esac } get_config_path () { if [ -x /usr/sbin/php5enmod ]; then CONFIG_PATH=/etc/php5/mods-available/newrelic.ini else CONFIG_PATH=/etc/php5/conf.d/newrelic.ini fi } # Usage: install_agent_to_new_package VERSION SOURCEDIR # Dependencies: $LICENSE_KEY and $APPLICATION_NAME from debconf. install_agent_to_new_package () { local api arch extdir inidir arch=$(get_architecture) if [ -z "$arch" ]; then # get_architecture will have already printed an error message. return 1 fi api=$(version_to_api $1) if [ $? -ne 0 ]; then # Unsupported version: Since an error message has # already been displayed, just return return 1 fi extdir="/usr/lib/php/$api" if [ ! -d "$extdir" ]; then echo "Unable to find extension directory: $extdir" 1>&2 return 1 fi inidir="/etc/php/$1/mods-available" if [ ! -d "$inidir" ]; then echo "Unable to find module configuration directory: $inidir" 1>&2 return 1 fi # Remove any existing symlink in the extension directory and link the new # agent. rm -f "$extdir/newrelic.so" ln -s "$2/agent/$arch/newrelic-${api}.so" "$extdir/newrelic.so" # If there's no configuration file in the mods-available directory already, # let's add one. if [ ! -f "$inidir/newrelic.ini" ]; then python3 "$2/scripts/install/configure" "$LICENSE_KEY" "$APPLICATION_NAME" < "$2/scripts/newrelic.ini.template" > "$inidir/newrelic.ini" fi # Activate the module. phpenmod -v "$1" newrelic } # This function checks if PHP is installed via older style packages (generally # defined as the standard packages shipped for PHP 5 in Debian, Ubuntu, and via # Ondřej's PPA), where there's a php5-common package that can't provide # information on what PHPs are installed or where they're located, but in # practice we know where to place configuration and .so files because the # packages are laid out in a standard way. is_php5_packaged () { for package in php5-common; do # We need dpkg-query to tell us what state the package is in. It's possible # for a package that's uninstalled to be known by dpkg, in which case # dpkg-query will return an exit code of 0 and not 1, which means we can't # discriminate based solely on the exit code. # # Instead, we'll get dpkg-query to tell us exactly what state the package # is in. If it's anything other than "not-installed", the package is # installed (or partly installed), and we should consider it available. # # Note that although it would be simpler to use ${db:Status-Status} instead # of ${Status}, the oldest Debian and Ubuntu versions we support don't # handle that virtual field, so we just have to grab the whole status and # parse it using grep. if dpkg-query -W -f '${Status}' "$package" 2>/dev/null | grep -wiv not-installed >/dev/null 2>&1; then return 0 fi done return 1 } # This function checks if PHP is installed via newer style packages (generally # defined as the standard packages shipped for PHP 7 in Debian, Ubuntu, and via # Ondřej's PPA). Specifically, we're looking for a /usr/sbin/phpquery # executable, rather than a specifically named package, since phpquery can then # tell us what versions are installed. is_phpquery_available () { test -x /usr/sbin/phpquery return } needs_config () { # Check if we need to configure the license key and application name. # Unpackaged PHP installs never configure these. For packaged installs, we # need to check if the newrelic.ini is already in place. if is_php5_packaged; then get_config_path # We want to see if there are inconsistent newrelic.ini files: if so, then # we shouldn't overwrite anything. if are_newrelic_ini_files_consistent; then test ! -f "$CONFIG_PATH" return fi fi return 1 } # Usage: purge_agent_from_new_package VERSION purge_agent_from_new_package () { rm -f "/etc/php/$1/mods-available/newrelic.ini" } # Usage: uninstall_agent_from_new_package VERSION uninstall_agent_from_new_package () { local api extdir # Attempt to remove the extension. api=$(version_to_api $1) extdir="/usr/lib/php/$api" rm -f "$extdir/newrelic.so" # Disable the module, but don't purge. (We'll do that separately if # requested.) phpdismod -v "$1" newrelic > /dev/null 2>&1 } version_to_api () { case "$1" in 7.0*) echo 20151012 ;; 7.1*) echo 20160303 ;; 7.2*) echo 20170718 ;; 7.3*) echo 20180731 ;; 7.4*) echo 20190902 ;; 8.0*) echo 20200930 ;; 8.1*) echo 20210902 ;; 8.2*) echo 20220829 ;; 8.3*) echo 20230831 ;; *) echo "Unknown PHP version: $1" 1>&2 return 1 ;; esac } # PHP version handling follows: # # There are three states a PHP version can be in. A version must only appear in # one list below. # # Supported: the API number appears in $PHP_API_VERSIONS. These versions will # always be installed, and the .so will be removed on both upgrade # and uninstall. # # Deprecated: the API number appears in $DEPRECATED_PHP_API_VERSIONS. These # versions will always be installed, but the .so will NOT be removed # on upgrade, since the expectation is that the version will no # longer appear in $PHP_API_VERSIONS thereafter. # # Unsupported: the API number appears in $UNSUPPORTED_PHP_API_VERSIONS. These # versions were supported once upon a time, but are no longer # supported. # # What this really means to you, the developer, if and when you're changing the # agent's version support: # # Adding a version: add the new API number to $PHP_API_VERSIONS. Test it. Be # of good cheer. # # Removing a version: for one release, remove the API number from # $PHP_API_VERSIONS and add it to # $DEPRECATED_PHP_API_VERSIONS. Document loudly that # customers using that PHP version should pin to that # package version. For the subsequent release, remove the # version from $DEPRECATED_PHP_API_VERSIONS and add it to # $UNSUPPORTED_PHP_API_VERSIONS. PHP_API_VERSIONS="20151012 20160303 20170718 20180731 20190902 20200930 20210902 20220829 20230831" DEPRECATED_PHP_API_VERSIONS="" UNSUPPORTED_PHP_API_VERSIONS="20050922 20060613 20090626 20100525 20121212 20131226" # End of included newrelic-php5.common code. # vim: set ft=sh: if [ "$1" = "upgrade" ]; then : elif [ "$1" = "purge" ]; then if is_phpquery_available; then # Xenial packages use /etc/php/mods-available instead of the version # specific directory, so make sure we remove our configuration file from # that if it exists. rm -f /etc/php/mods-available/newrelic.ini for version in $(/usr/sbin/phpquery -V); do purge_agent_from_new_package "$version" done fi else rm -f /var/log/newrelic/php_agent.log* > /dev/null 2>&1 fi # Automatically added by dh_installdebconf/13.6ubuntu1 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge fi # End automatically added section exit 0