More fixes for AlpinePHPTool:
* Fixed wget check if cronjob config exists * Enhanced check for current php installation * Changed way nginx config is updated, it wil now always overwrite the entire line
This commit is contained in:
@@ -95,10 +95,10 @@ fi
|
|||||||
|
|
||||||
#Backup PHP config and purge PHP packages
|
#Backup PHP config and purge PHP packages
|
||||||
run_Purge() {
|
run_Purge() {
|
||||||
#Check if PHP is installed
|
|
||||||
if ! command -v php &> /dev/null; then printf "ERROR: PHP is not installed\n\n"; exit 1;fi
|
|
||||||
#Get current PHP Version
|
#Get current PHP Version
|
||||||
OldPHPVer=$(grep php /etc/apk/world -m 1|sed -e "s/\-.*//" -e "s/php//")
|
OldPHPVer=$(grep php /etc/apk/world -m 1|sed -e "s/\-.*//" -e "s/php//")
|
||||||
|
#Check if PHP is installed
|
||||||
|
if ! command -v php$OldPHPVer &> /dev/null; then printf "ERROR: PHP is not installed\n\n"; exit 1;fi
|
||||||
#Create Backup an its location
|
#Create Backup an its location
|
||||||
if [[ ! -d "/opt/PHPCfgBackup/" ]];then mkdir -p "/opt/PHPCfgBackup"; fi
|
if [[ ! -d "/opt/PHPCfgBackup/" ]];then mkdir -p "/opt/PHPCfgBackup"; fi
|
||||||
if [[ -f /etc/crontabs/nginx ]]; then cp /etc/crontabs/nginx /opt/PHPCfgBackup/crontabs-nginx; fi
|
if [[ -f /etc/crontabs/nginx ]]; then cp /etc/crontabs/nginx /opt/PHPCfgBackup/crontabs-nginx; fi
|
||||||
@@ -106,7 +106,7 @@ run_Purge() {
|
|||||||
rm -rf "/etc/php$OldPHPVer"
|
rm -rf "/etc/php$OldPHPVer"
|
||||||
|
|
||||||
#Set placeholder in Nginx for PHP Socket
|
#Set placeholder in Nginx for PHP Socket
|
||||||
sed -i -e 's/'$OldPHPVer'/PHPver/g' /etc/nginx/nginx.conf
|
sed -i "/fastcgi_pass unix:\/run\/php-/c\ \ fastcgi_pass unix:\/run\/php-fpmPHPver\/php-fpm.sock;" /etc/nginx/nginx.conf
|
||||||
#Purge PHP packages
|
#Purge PHP packages
|
||||||
apk del php*
|
apk del php*
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ run_Install() {
|
|||||||
printf "[Date]\ndate.timezone = Europe/Amsterdam" >/etc/php$NewPHPVer/conf.d/04_date_timezone.ini
|
printf "[Date]\ndate.timezone = Europe/Amsterdam" >/etc/php$NewPHPVer/conf.d/04_date_timezone.ini
|
||||||
|
|
||||||
#Configure Nginx PHP Socket
|
#Configure Nginx PHP Socket
|
||||||
sed -i -e 's/PHPver/'$NewPHPVer'/g' /etc/nginx/nginx.conf
|
sed -i "/fastcgi_pass unix:\/run\/php-/c\ \ fastcgi_pass unix:\/run\/php-fpm$NewPHPVer\/php-fpm.sock;" /etc/nginx/nginx.conf
|
||||||
|
|
||||||
#Unique settings for configuration
|
#Unique settings for configuration
|
||||||
case $config in
|
case $config in
|
||||||
@@ -168,7 +168,7 @@ fetch_Config() {
|
|||||||
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/$config/Configs/php.conf -O /tmp/php.conf || echo_exit "ERROR: Config download failed"
|
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/$config/Configs/php.conf -O /tmp/php.conf || echo_exit "ERROR: Config download failed"
|
||||||
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/"$config"/Configs/php.pkglist -O /tmp/php.pkglist || echo_exit "ERROR: Config download failed"
|
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/"$config"/Configs/php.pkglist -O /tmp/php.pkglist || echo_exit "ERROR: Config download failed"
|
||||||
#Check if crontab conf exists,if so get it
|
#Check if crontab conf exists,if so get it
|
||||||
if wget -q --method=HEAD "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/$config/Configs/crontab;
|
if wget -q --spider "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/$config/Configs/crontab 2>/dev/null;
|
||||||
then
|
then
|
||||||
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/"$config"/Configs/crontab -O /tmp/crontab || echo_exit "ERROR: Config download failed"
|
wget "$gitRepo"/raw/branch/"$gitBranch"/CT-Files/"$config"/Configs/crontab -O /tmp/crontab || echo_exit "ERROR: Config download failed"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user