From c5d70cc455a4fa367e207b3e337a387857b513e2 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Wed, 16 Dec 2020 13:25:11 +0100 Subject: [PATCH 1/5] Updated php module to support mutiple php versions --- SubModules/php-fpm/apt.pkg.list | 1 - SubModules/php-fpm/dnf.pkg.list | 1 - SubModules/php-fpm/generic.pkg.list | 1 - SubModules/php-fpm/php7x/apt.php.pkg.list | 1 + SubModules/php-fpm/php7x/dnf.php.pkg.list | 1 + SubModules/php-fpm/php7x/generic.php.pkg.list | 1 + SubModules/php-fpm/php8x/apt.php.pkg.list | 1 + SubModules/php-fpm/php8x/dnf.php.pkg.list | 1 + SubModules/php-fpm/php8x/generic.php.pkg.list | 1 + SubModules/php-fpm/preconf.sh | 19 ++++++++++++++++++- installer.sh | 2 +- 11 files changed, 25 insertions(+), 5 deletions(-) delete mode 100644 SubModules/php-fpm/apt.pkg.list delete mode 100644 SubModules/php-fpm/dnf.pkg.list delete mode 100644 SubModules/php-fpm/generic.pkg.list create mode 100644 SubModules/php-fpm/php7x/apt.php.pkg.list create mode 100644 SubModules/php-fpm/php7x/dnf.php.pkg.list create mode 100644 SubModules/php-fpm/php7x/generic.php.pkg.list create mode 100644 SubModules/php-fpm/php8x/apt.php.pkg.list create mode 100644 SubModules/php-fpm/php8x/dnf.php.pkg.list create mode 100644 SubModules/php-fpm/php8x/generic.php.pkg.list diff --git a/SubModules/php-fpm/apt.pkg.list b/SubModules/php-fpm/apt.pkg.list deleted file mode 100644 index 7521d75..0000000 --- a/SubModules/php-fpm/apt.pkg.list +++ /dev/null @@ -1 +0,0 @@ -php-pear \ No newline at end of file diff --git a/SubModules/php-fpm/dnf.pkg.list b/SubModules/php-fpm/dnf.pkg.list deleted file mode 100644 index 8ccb20f..0000000 --- a/SubModules/php-fpm/dnf.pkg.list +++ /dev/null @@ -1 +0,0 @@ -PHPprefix-pear PHPprefix \ No newline at end of file diff --git a/SubModules/php-fpm/generic.pkg.list b/SubModules/php-fpm/generic.pkg.list deleted file mode 100644 index 40d3c6b..0000000 --- a/SubModules/php-fpm/generic.pkg.list +++ /dev/null @@ -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 \ No newline at end of file diff --git a/SubModules/php-fpm/php7x/apt.php.pkg.list b/SubModules/php-fpm/php7x/apt.php.pkg.list new file mode 100644 index 0000000..eee9257 --- /dev/null +++ b/SubModules/php-fpm/php7x/apt.php.pkg.list @@ -0,0 +1 @@ +php-pear PHPprefix-mysql \ No newline at end of file diff --git a/SubModules/php-fpm/php7x/dnf.php.pkg.list b/SubModules/php-fpm/php7x/dnf.php.pkg.list new file mode 100644 index 0000000..3216834 --- /dev/null +++ b/SubModules/php-fpm/php7x/dnf.php.pkg.list @@ -0,0 +1 @@ +PHPprefix-pear PHPprefix PHPprefix-mysqlnd \ No newline at end of file diff --git a/SubModules/php-fpm/php7x/generic.php.pkg.list b/SubModules/php-fpm/php7x/generic.php.pkg.list new file mode 100644 index 0000000..9ad1d8c --- /dev/null +++ b/SubModules/php-fpm/php7x/generic.php.pkg.list @@ -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 \ No newline at end of file diff --git a/SubModules/php-fpm/php8x/apt.php.pkg.list b/SubModules/php-fpm/php8x/apt.php.pkg.list new file mode 100644 index 0000000..eee9257 --- /dev/null +++ b/SubModules/php-fpm/php8x/apt.php.pkg.list @@ -0,0 +1 @@ +php-pear PHPprefix-mysql \ No newline at end of file diff --git a/SubModules/php-fpm/php8x/dnf.php.pkg.list b/SubModules/php-fpm/php8x/dnf.php.pkg.list new file mode 100644 index 0000000..3216834 --- /dev/null +++ b/SubModules/php-fpm/php8x/dnf.php.pkg.list @@ -0,0 +1 @@ +PHPprefix-pear PHPprefix PHPprefix-mysqlnd \ No newline at end of file diff --git a/SubModules/php-fpm/php8x/generic.php.pkg.list b/SubModules/php-fpm/php8x/generic.php.pkg.list new file mode 100644 index 0000000..b32f2bb --- /dev/null +++ b/SubModules/php-fpm/php8x/generic.php.pkg.list @@ -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 \ No newline at end of file diff --git a/SubModules/php-fpm/preconf.sh b/SubModules/php-fpm/preconf.sh index 1085b2b..05225a2 100644 --- a/SubModules/php-fpm/preconf.sh +++ b/SubModules/php-fpm/preconf.sh @@ -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/generic.php"$phpVerBranch".php.pkg.list; then + curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/generic.phppkg.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/"$PKGLIST".phppkg.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 \ No newline at end of file diff --git a/installer.sh b/installer.sh index 461aa2c..f39d02a 100644 --- a/installer.sh +++ b/installer.sh @@ -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 From a24e075714d63aa360ea4c7ca3e50bdd7d6da7f5 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Wed, 16 Dec 2020 14:27:31 +0100 Subject: [PATCH 2/5] Fixed typo, after inital update for php module Fixes: #10 --- SubModules/php-fpm/preconf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SubModules/php-fpm/preconf.sh b/SubModules/php-fpm/preconf.sh index 05225a2..484d55b 100644 --- a/SubModules/php-fpm/preconf.sh +++ b/SubModules/php-fpm/preconf.sh @@ -23,13 +23,13 @@ elif [ ${phpver//.} -ge 80 ] && [ ${phpver//.} -lt 90 ]; then fi #Getting php pkglist -if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/generic.php"$phpVerBranch".php.pkg.list; then +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/generic.phppkg.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/"$PKGLIST".phppkg.list + curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/php-fpm/php"$phpVerBranch"/"$PKGLIST".php.pkg.list printf " " >>/tmp/pkg.list fi From 9115a36148ff99c1bb437f6af9737603c6972386 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Wed, 16 Dec 2020 14:35:54 +0100 Subject: [PATCH 3/5] fixed oopsie --- SubModules/php-fpm/preconf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SubModules/php-fpm/preconf.sh b/SubModules/php-fpm/preconf.sh index 484d55b..29ff8de 100644 --- a/SubModules/php-fpm/preconf.sh +++ b/SubModules/php-fpm/preconf.sh @@ -24,12 +24,12 @@ 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/generic.phppkg.list + 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 + 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 From d889f248e6251547db5a1339ca6671896ad50c37 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Thu, 17 Dec 2020 15:14:18 +0100 Subject: [PATCH 4/5] Prepared php updater for EL --- AppendCMS.sh | 8 +++-- AppendModule.sh | 8 +++-- CoreModules/apache/phpupdate-handeler.sh | 5 ++- PhpUpdater.sh | 42 +++++++++++++++++++++--- Scripts/GenerateApacheList.sh | 19 +++++++++++ Scripts/GeneratePhplist.sh | 2 ++ Scripts/MicroOSDetect.sh | 14 ++++++++ 7 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 Scripts/GenerateApacheList.sh create mode 100644 Scripts/MicroOSDetect.sh diff --git a/AppendCMS.sh b/AppendCMS.sh index 003a060..0966189 100644 --- a/AppendCMS.sh +++ b/AppendCMS.sh @@ -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) diff --git a/AppendModule.sh b/AppendModule.sh index f06e4b3..bdaed34 100644 --- a/AppendModule.sh +++ b/AppendModule.sh @@ -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) diff --git a/CoreModules/apache/phpupdate-handeler.sh b/CoreModules/apache/phpupdate-handeler.sh index 8abfe21..e91e63d 100644 --- a/CoreModules/apache/phpupdate-handeler.sh +++ b/CoreModules/apache/phpupdate-handeler.sh @@ -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 diff --git a/PhpUpdater.sh b/PhpUpdater.sh index cdd0221..b001d11 100644 --- a/PhpUpdater.sh +++ b/PhpUpdater.sh @@ -2,8 +2,12 @@ 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 +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 PPAversion=`apt list php | egrep -o "([0-9]{1,}.)+[0-9]{1,}" | cut -c 3-` && PPAversion=`echo $PPAversion | awk '{print $1; }' | cut -f1 -d"+"` msg () { @@ -60,11 +64,33 @@ if [ $IMODE = l ]; then esac done + #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 + elif [ "$shortdist" = "el8" ]; then + # Centos Php variable + phpPoolDir=/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 + fi + + + #Install - apt list --installed | less | grep php$phpver | cut -f1 -d"/" | sed "s/$phpver/$newphpver/" | xargs $PKGI + apt list --installed | less | grep php$phpver | cut -f1 -d"/" | sed "s/$phpver/$newphpver/" > /tmp/pkg.list + if [ ${newphpver//.} -ge 80 ] && [ ${newphpver//.} -lt 90 ]; then + sed -i -e "s/php${newphpver//}-xmlrpc//g" -e "s/php${newphpver//}-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 #Purge while true; do @@ -79,13 +105,21 @@ if [ $IMODE = l ]; then done fi -for f in /etc/php/$newphpver/fpm/pool.d/*; do +for f in $phpPoolDir/*; do 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 + 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 \ No newline at end of file diff --git a/Scripts/GenerateApacheList.sh b/Scripts/GenerateApacheList.sh new file mode 100644 index 0000000..49de67f --- /dev/null +++ b/Scripts/GenerateApacheList.sh @@ -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 diff --git a/Scripts/GeneratePhplist.sh b/Scripts/GeneratePhplist.sh index 1a007a1..e848b8e 100644 --- a/Scripts/GeneratePhplist.sh +++ b/Scripts/GeneratePhplist.sh @@ -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 diff --git a/Scripts/MicroOSDetect.sh b/Scripts/MicroOSDetect.sh new file mode 100644 index 0000000..c6ccf85 --- /dev/null +++ b/Scripts/MicroOSDetect.sh @@ -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 \ No newline at end of file From 22ca4d3464210671ac5cd10ba31c0a763bafa59f Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Fri, 18 Dec 2020 14:35:13 +0100 Subject: [PATCH 5/5] updated phpupdater for apache --- CMS/nextcloud/conf.sh | 2 +- CMS/wordpress/WordPress-unconfigured | 2 +- CoreModules/apache/phpupdate-handeler.sh | 2 +- PhpUpdater.sh | 71 +++++++++++++----------- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/CMS/nextcloud/conf.sh b/CMS/nextcloud/conf.sh index 25db50e..39bb16f 100644 --- a/CMS/nextcloud/conf.sh +++ b/CMS/nextcloud/conf.sh @@ -29,7 +29,7 @@ cat < /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", diff --git a/CMS/wordpress/WordPress-unconfigured b/CMS/wordpress/WordPress-unconfigured index 85000f8..ddd8bca 100644 --- a/CMS/wordpress/WordPress-unconfigured +++ b/CMS/wordpress/WordPress-unconfigured @@ -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', '' ); diff --git a/CoreModules/apache/phpupdate-handeler.sh b/CoreModules/apache/phpupdate-handeler.sh index e91e63d..f71fee5 100644 --- a/CoreModules/apache/phpupdate-handeler.sh +++ b/CoreModules/apache/phpupdate-handeler.sh @@ -24,4 +24,4 @@ for f in $apacheConfDir/sites-available/*; do fi done -systemctl reload apache2 \ No newline at end of file +systemctl reload $apacheService \ No newline at end of file diff --git a/PhpUpdater.sh b/PhpUpdater.sh index b001d11..41da8d8 100644 --- a/PhpUpdater.sh +++ b/PhpUpdater.sh @@ -1,15 +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 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 -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 [ "$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 @@ -23,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 @@ -63,7 +52,8 @@ 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 @@ -71,20 +61,22 @@ if [ $IMODE = l ]; then 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 - phpPoolDir=/etc/opt/remi/php${newphpver//.}/php-fpm.d/ + 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/" > /tmp/pkg.list + if [ ${newphpver//.} -ge 80 ] && [ ${newphpver//.} -lt 90 ]; then - sed -i -e "s/php${newphpver//}-xmlrpc//g" -e "s/php${newphpver//}-json//g" /tmp/pkg.list + sed -i -e "s/$newphpPkgName-xmlrpc//g" -e "s/$newphpPkgName-json//g" /tmp/pkg.list fi cat /tmp/pkg.list | xargs $PKGI @@ -92,11 +84,24 @@ if [ $IMODE = l ]; then 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;; @@ -105,8 +110,9 @@ if [ $IMODE = l ]; then done fi -for f in $phpPoolDir/*; do +for f in $newphpPoolDir/*; do sed -i "s/$phpver/$newphpver/" $f + sed -i "s/${phpver//.}/${newphpver//.}/" $f done systemctl start $newphpFPMService @@ -119,6 +125,7 @@ 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)