Merge pull request 'PHP 8 intergration readiness' (#11) from PHP8-Testing into master

Reviewed-on: https://git.ictmaatwerk.com/VPS-scripts/Web-V2/pulls/11
This commit was merged in pull request #11.
This commit is contained in:
Bram Prieshof
2020-12-18 15:30:17 +01:00
20 changed files with 150 additions and 43 deletions

View File

@@ -6,11 +6,15 @@ if [ ! -f "/etc/ICTM/selopts.list" ] || [ ! -f "/etc/ICTM/mainvar.list" ] ; then
source /etc/ICTM/selopts.list
source /etc/ICTM/mainvar.list
if [ -z $shortdist ] ; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/MicroOSDetect.sh) ; fi
if [ $webserv != nginx_nonphp ]; then
if [ ! -f "/etc/ICTM/phpvar.list" ] ; then echo 'Php var list missing,Please run /Scipts/GeneratePhplist from the repo ' && exit ; fi
if [ ! -f "/etc/ICTM/phpvar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GeneratePhplist.sh) ; fi
source /etc/ICTM/phpvar.list
fi
if [ -f "/etc/ICTM/apachevar.list" ] ; then source /etc/ICTM/apachevar.list; fi
if [ $webserv = apache ]; then
if [ ! -f "/etc/ICTM/apachevar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GenerateApacheList.sh) ; fi
source /etc/ICTM/apachevar.list
fi
rm /tmp/pkg.list > $OUTPUT 2>&1
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/ModulesMenu.list)

View File

@@ -10,11 +10,15 @@ if [ ! -f "/etc/ICTM/selopts.list" ] || [ ! -f "/etc/ICTM/mainvar.list" ] ; then
source /etc/ICTM/selopts.list
source /etc/ICTM/mainvar.list
if [ -z $shortdist ] ; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/MicroOSDetect.sh) ; fi
if [ $webserv != nginx_nonphp ]; then
if [ ! -f "/etc/ICTM/phpvar.list" ] ; then echo 'Php var list missing,Please run /Scipts/GeneratePhplist from the repo ' && exit ; fi
if [ ! -f "/etc/ICTM/phpvar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GeneratePhplist.sh) ; fi
source /etc/ICTM/phpvar.list
fi
if [ -f "/etc/ICTM/apachevar.list" ] ; then source /etc/ICTM/apachevar.list; fi
if [ $webserv = apache ]; then
if [ ! -f "/etc/ICTM/apachevar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GenerateApacheList.sh) ; fi
source /etc/ICTM/apachevar.list
fi
rm /tmp/pkg.list
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/ModulesMenu.list)

View File

@@ -29,7 +29,7 @@ cat <<EOF > /var/www/$domain/html/config/autoconfig.php
"dbname" => "${db_name}",
"dbuser" => "${db_user}",
"dbpass" => "${db_pass}",
"dbhost" => "localhost",
"dbhost" => "127.0.0.1",
"dbtableprefix" => "",
"simpleSignUpLink.shown" => false,
"directory" => "/var/www/$domain/html/data",

View File

@@ -2,7 +2,7 @@
define('DB_NAME', 'DBName');
define('DB_USER', 'DBUser');
define('DB_PASSWORD', 'DBPass');
define('DB_HOST', 'localhost');
define('DB_HOST', '127.0.0.1');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
#define( 'WP_SITEURL', '' );

View File

@@ -1,4 +1,7 @@
for f in /etc/apache2/sites-available/*; do
if [ ! -f "/etc/ICTM/apachevar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GenerateApacheList.sh) ; fi
source /etc/ICTM/apachevar.list
for f in $apacheConfDir/sites-available/*; do
if [ $IMODE = n ] && [ $PhpPurge = 0 ]; then
if (whiptail --title "Update apache config ?" --yesno "Update php version in apache site: ${f##*/} ?" 8 78); then
sed -i "s/$phpver/$newphpver/" $f
@@ -21,4 +24,4 @@ for f in /etc/apache2/sites-available/*; do
fi
done
systemctl reload apache2
systemctl reload $apacheService

View File

@@ -1,11 +1,18 @@
#sysCheck
if [ ! -f "/etc/ICTM/selopts.list" ] || [ ! -f "/etc/ICTM/mainvar.list" ] ; then echo 'This system is not yet setup, please run the main installer first' && exit ; fi
PKGI="${PKGM} install -y --no-install-recommends"
rm /tmp/pkg.list
#Getting variables
source /etc/ICTM/mainvar.list
PPAversion=`apt list php | egrep -o "([0-9]{1,}.)+[0-9]{1,}" | cut -c 3-` && PPAversion=`echo $PPAversion | awk '{print $1; }' | cut -f1 -d"+"`
if [ -z $shortdist ] ; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/MicroOSDetect.sh) ; fi
if [ ! -f "/etc/ICTM/phpvar.list" ] ; then bash <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/GeneratePhplist.sh) ; fi
source /etc/ICTM/phpvar.list
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
apt update
RepoVersion=`apt list |grep php | grep deb.sury.org| cut -f1 -d"-"| tail -1 |sed 's/php//'`
elif [ "$shortdist" = "el8" ]; then
dnf check-update --refresh
RepoVersion=`dnf list php* | awk '{print $1; }' | cut -f1 -d"-"| tail -1 |sed 's/php//' | sed 's/./&./1'`
fi
msg () {
if [ $IMODE = n ]; then
TERM=ansi whiptail --title "Info" --msgbox "$1" 8 52
@@ -19,39 +26,25 @@ msg "Current php version: $phpver"
if [ $IMODE = n ]; then
# Legacy/Main Menu
PKGP="debconf-apt-progress -- apt purge -y"
PKGD="debconf-apt-progress -- apt purge -y"
#Menu
if (whiptail --title "Set new php version?" --yesno "Install php version $PPAversion ?" 8 78); then
newphpver=$PPAversion
if (whiptail --title "Set new php version?" --yesno "Install php version $RepoVersion ?" 8 78); then
newphpver=$RepoVersion
else
newphpver=$(whiptail --inputbox "Please enter the version to install" --title "Custom" 8 39 3>&1 1>&2 2>&3)
fi
#Install
apt list --installed | less | grep php$phpver | cut -f1 -d"/" | sed "s/$phpver/$newphpver/" | xargs $PKGI
#Config
cp /etc/php/$phpver/fpm/pool.d/* /etc/php/$newphpver/fpm/pool.d/
#Purge
if (whiptail --title "Set new php version?" --yesno "Remove php $phpver ?" 8 78); then
PhpPurge=1
$PKGP -y php$phpver*
else
PhpPurge=0
fi
fi
if [ $IMODE = l ]; then
# Legacy/Main Menu
PKGP="apt purge -y"
PKGD="apt purge -y"
#Menu
while true; do
read -p "Set phpversion to version $PPAversion ? -> yes/no?" yn
read -p "Set phpversion to version $RepoVersion ? -> yes/no?" yn
case $yn in
[Yy]* ) newphpver=$PPAversion
[Yy]* ) newphpver=$RepoVersion
break;;
[Nn]* ) echo "";
echo "Please enter php version to install:";read newphpver
@@ -59,18 +52,56 @@ if [ $IMODE = l ]; then
* ) echo "Choose yes or no.";;
esac
done
fi
#Genereating vars for new php version
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
# Debian/Ubunbtu Php variables
newphpPoolDir=/etc/php/${newphpver}/fpm/pool.d
newphpPkgName=php${newphpver}
newphpMainConf=/etc/php/${newphpver}/fpm/php.ini
newphpFPMService=php${newphpver}-fpm
PKGP=$PKGD
apt list --installed | less | grep php$phpver | cut -f1 -d"/" | sed "s/$phpPkgName/$newphpPkgName/" > /tmp/pkg.list
elif [ "$shortdist" = "el8" ]; then
# Centos Php variable
newphpPoolDir=/etc/opt/remi/php${newphpver//.}/php-fpm.d/
newphpPkgName=php${newphpver//.}-php
newphpMainConf=/etc/opt/remi/php${newphpver//.}/php.ini
newphpFPMService=php${newphpver//.}-php-fpm
PKGP="dnf remove -y"
dnf list --installed | sort | grep $phpPkgName | awk '{print $1;}' | cut -f1 -d"." | sed "s/$phpPkgName/$newphpPkgName/" > /tmp/pkg.list
fi
#Install
apt list --installed | less | grep php$phpver | cut -f1 -d"/" | sed "s/$phpver/$newphpver/" | xargs $PKGI
if [ ${newphpver//.} -ge 80 ] && [ ${newphpver//.} -lt 90 ]; then
sed -i -e "s/$newphpPkgName-xmlrpc//g" -e "s/$newphpPkgName-json//g" /tmp/pkg.list
fi
cat /tmp/pkg.list | xargs $PKGI
#Config
cp /etc/php/$phpver/fpm/pool.d/* /etc/php/$newphpver/fpm/pool.d/
systemctl stop $newphpFPMService
cp $phpPoolDir/* $newphpPoolDir
if [ $IMODE = n ]; then
#Purge
if (whiptail --title "Set new php version?" --yesno "Remove php $phpver ?" 8 78); then
PhpPurge=1
$PKGP -y $phpPkgName*
else
PhpPurge=0
fi
fi
if [ $IMODE = l ]; then
#Purge
while true; do
read -p "Remove php $phpver ? -> yes/no?" yn
case $yn in
[Yy]* ) PhpPurge=1 ; $PKGP php$phpver*
[Yy]* ) PhpPurge=1 ; $PKGP $phpPkgName*
break;;
[Nn]* ) PhpPurge=0 ; echo ""
break;;
@@ -79,13 +110,23 @@ if [ $IMODE = l ]; then
done
fi
for f in /etc/php/$newphpver/fpm/pool.d/*; do
for f in $newphpPoolDir/*; do
sed -i "s/$phpver/$newphpver/" $f
sed -i "s/${phpver//.}/${newphpver//.}/" $f
done
systemctl reload php$newphpver-fpm
systemctl start $newphpFPMService
systemctl enable $newphpFPMService
sed -i "/phpver/c\phpver=\"$newphpver\"" /etc/ICTM/mainvar.list
mv /etc/ICTM/phpvar.list /etc/ICTM/phpvar"$phpver".list
for storeme in newphpPoolDir newphpPkgName newphpMainConf newphpFPMService; do
declare -p $storeme | cut -d ' ' -f 3- >> /etc/ICTM/phpvar.list
done
sed -i 's/new//' /etc/ICTM/phpvar.list
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/phpupdate-handeler.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/phpupdate-handeler.sh)
fi

View File

@@ -0,0 +1,19 @@
if [ ! -f "/etc/ICTM/mainvar.list" ] ; then echo 'This system is not yet setup, please run the main installer first' && exit ; fi
source /etc/ICTM/mainvar.list
if [ -z $shortdist ] ; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/MicroOSDetect.sh) ; fi
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
# Debian/Ubunbtu apache variables
apacheConfDir=/etc/apache2
apacheService=apache2
elif [ "$shortdist" = "el8" ]; then
# Centos Php variable
apacheConfDir=/etc/httpd
apacheService=httpd
fi
#Storing vars to config
for storeme in apacheService apacheConfDir; do
declare -p $storeme | cut -d ' ' -f 3- >> /etc/ICTM/apachevar.list
done

View File

@@ -1,4 +1,6 @@
if [ ! -f "/etc/ICTM/mainvar.list" ] ; then echo 'This system is not yet setup, please run the main installer first' && exit ; fi
source /etc/ICTM/mainvar.list
if [ -z $shortdist ] ; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/MicroOSDetect.sh) ; fi
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
# Debian/Ubunbtu Php variables

14
Scripts/MicroOSDetect.sh Normal file
View File

@@ -0,0 +1,14 @@
dist_ver=$(grep --color=never -Po "^VERSION_ID=\K.*" "/etc/os-release")
dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release")
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
shortdist=ubu1804
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
shortdist=ubu2004
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
shortdist=deb10
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
shortdist=el8
else
echo "This os in known"
fi

View File

@@ -1 +0,0 @@
php-pear

View File

@@ -1 +0,0 @@
PHPprefix-pear PHPprefix

View File

@@ -1 +0,0 @@
PHPprefix-imagick PHPprefix-cli PHPprefix-apcu PHPprefix-fpm PHPprefix-mysql PHPprefix-cgi PHPprefix-common PHPprefix-mbstring PHPprefix-curl PHPprefix-gd PHPprefix-intl PHPprefix-soap PHPprefix-xml PHPprefix-xmlrpc PHPprefix-zip

View File

@@ -0,0 +1 @@
php-pear PHPprefix-mysql

View File

@@ -0,0 +1 @@
PHPprefix-pear PHPprefix PHPprefix-mysqlnd

View File

@@ -0,0 +1 @@
PHPprefix-imagick PHPprefix-cli PHPprefix-apcu PHPprefix-fpm PHPprefix-cgi PHPprefix-common PHPprefix-mbstring PHPprefix-curl PHPprefix-gd PHPprefix-intl PHPprefix-soap PHPprefix-xml PHPprefix-xmlrpc PHPprefix-zip

View File

@@ -0,0 +1 @@
php-pear PHPprefix-mysql

View File

@@ -0,0 +1 @@
PHPprefix-pear PHPprefix PHPprefix-mysqlnd

View File

@@ -0,0 +1 @@
PHPprefix-imagick PHPprefix-cli PHPprefix-apcu PHPprefix-fpm PHPprefix-cgi PHPprefix-common PHPprefix-mbstring PHPprefix-curl PHPprefix-gd PHPprefix-intl PHPprefix-soap PHPprefix-xml PHPprefix-zip

View File

@@ -15,8 +15,25 @@ elif [ "$shortdist" = "el8" ]; then
mkdir -p /var/run/php
fi
#Setting php version branch
if [ ${phpver//.} -ge 70 ] && [ ${phpver//.} -lt 80 ] ; then
phpVerBranch=7x
elif [ ${phpver//.} -ge 80 ] && [ ${phpver//.} -lt 90 ]; then
phpVerBranch=8x
fi
#Getting php pkglist
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/php"$phpVerBranch"/generic.php.pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/php"$phpVerBranch"/generic.php.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/php"$phpVerBranch"/"$PKGLIST".php.pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/php"$phpVerBranch"/"$PKGLIST".php.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
#Storing vars to config
for storeme in phpPoolDir phpPkgName phpMainConf phpFPMService; do
for storeme in phpPoolDir phpPkgName phpMainConf phpFPMService phpVerBranch; do
declare -p $storeme | cut -d ' ' -f 3- >> /etc/ICTM/phpvar.list
done

View File

@@ -24,7 +24,7 @@ fi
#Git-repo
repo=https://git.ictmaatwerk.com/VPS-scripts/Web-V2
branch=master
branch=PHP8-Testing
branchtype=branch #=branch for branch and =tag for release
#Installer-config
phpver=7.4