#!/bin/sh set -e # Load debconf . /usr/share/debconf/confmodule if [ "$1" != reconfigure ]; then php70_done=1 for SAPI in apache2 cli; do db_fget php7.0-cn/${SAPI} seen if [ "$RET" != "true" ]; then php70_done=0 break fi done test $php70_done -eq 1 && exit 0 fi PHP70DIR="/etc/php/7.0" # phpmemlimit () # # Calculate memory size for PHP memory_limit option. # phpmemlimit () { local memtotal memlimit memtotal=`awk 'tolower($1) == "memtotal:" { printf("%i", $2/1024); }' /proc/meminfo` if [ $memtotal -lt 512 ]; then memlimit=16; fi if [ $memtotal -ge 512 ]; then memlimit=32; fi if [ $memtotal -gt 1024 ]; then memlimit=64; fi echo $memlimit } # Check for PHP5 SAPI configuration. # for SAPI in apache2 cli; do ini_diff=0 ini_file="$PHP70DIR/$SAPI/php.ini" upload_max_filesize= post_max_size= memory_limit= error_reporting= phplimit="$(phpmemlimit)M" if [ -f "$ini_file" ]; then if egrep -q "^[[:space:]]*(upload_max_filesize|post_max_size|memory_limit|error_reporting)[[:space:]]*=" $ini_file; then upload_max_filesize=`awk '$1 == "upload_max_filesize" { print $3; exit(0) }' $ini_file` post_max_size=`awk '$1 == "post_max_size" { print $3; exit(0) }' $ini_file` memory_limit=`awk '$1 == "memory_limit" { print $3; exit(0) }' $ini_file` error_reporting=`awk '$1 == "error_reporting" { print $3; exit(0) }' $ini_file` if [ "$upload_max_filesize" != "256M" ]; then ini_diff=1; fi if [ "$post_max_size" != "$phplimit" ]; then ini_diff=1; fi if [ "$memory_limit" != "$phplimit" ]; then ini_diff=1; fi if [ "$error_reporting" != "E_ERROR" ]; then ini_diff=1; fi else ini_diff=1 fi else ini_diff=1 fi if [ $ini_diff -eq 1 ]; then # Configurations are not the same - ask user what to do. test -z "$upload_max_filesize" && upload_max_filesize="2M" test -z "$post_max_size" && post_max_size="8M" test -z "$memory_limit" && memory_limit="16M" test -z "$error_reporting" && error_reporting="E_ALL & ~E_DEPRECATED" db_title php7.0-cn - konfiguracija za $(echo ${SAPI} | sed 's/a/A/;s/cli/CLI/') db_subst php7.0-cn/${SAPI} ini_file "$ini_file" db_subst php7.0-cn/${SAPI} upload_max_filesize "$upload_max_filesize" db_subst php7.0-cn/${SAPI} post_max_size "$post_max_size" db_subst php7.0-cn/${SAPI} memory_limit "$memory_limit" db_subst php7.0-cn/${SAPI} new_phplimit "$phplimit" db_subst php7.0-cn/${SAPI} error_reporting "$error_reporting" db_subst php7.0-cn/${SAPI} new_error_reporting "E_ERROR" db_input critical php7.0-cn/${SAPI} || true db_go || true else db_set php7.0-cn/${SAPI} false || true db_fset php7.0-cn/${SAPI} seen true fi done exit 0