Create v-edit-domain-php-ini

This commit is contained in:
isscbta 2024-04-09 16:44:05 +02:00 committed by GitHub
parent 929241c5f7
commit 40afd5b5c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

80
bin/v-edit-domain-php-ini Normal file
View file

@ -0,0 +1,80 @@
#!/bin/bash
# info: Edit php.ini for certain domain
# options: DOMAIN
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
whoami=$(whoami)
if [ "$whoami" != "root" ]; then
echo "You must be root to execute this script"
exit 1
fi
# Importing system environment
source /etc/profile
SILENT_MODE=1
# Argument definition
domain=$1
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
USER=$user
# Includes
source /usr/local/vesta/func/main.sh
source /usr/local/vesta/func/domain.sh
if [ -z "$user" ]; then
check_result $E_NOTEXIST "domain $domain doesn't exist"
fi
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'DOMAIN'
is_format_valid 'domain'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
if [ ! -d "/home/$user" ]; then
# echo "User doesn't exist";
exit 1;
fi
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
# echo "Domain doesn't exist";
exit 1;
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
fpm_ver=$(/usr/local/vesta/bin/v-get-php-version-of-domain $domain)
if [ -z "$fpm_ver" ]; then
echo "PHP version for domain $domain could not be determined."
exit 1
fi
config_file="/etc/php/${fpm_ver}/fpm/pool.d/${domain}.conf"
if command -v mcedit >/dev/null; then
mcedit "$config_file"
else
nano "$config_file"
fi
echo "Restarting PHP-FPM service for PHP version $fpm_ver..."
echo ""
systemctl restart php${fpm_ver}-fpm
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit 1;