mirror of
https://github.com/myvesta/vesta
synced 2025-07-31 03:51:14 -07:00
v-fix-php-ini-disable-functions
This commit is contained in:
parent
24371b8bbf
commit
da84a0b913
1 changed files with 28 additions and 0 deletions
28
bin/v-fix-php-ini-disable-functions
Normal file
28
bin/v-fix-php-ini-disable-functions
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
whoami=$(whoami)
|
||||
if [ "$whoami" != "root" ]; then
|
||||
echo "You must be root to execute this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Fixing php.ini files to have the correct disable_functions line"
|
||||
|
||||
export NOTFOUNDVAL="exec,system,passthru,shell_exec"
|
||||
export LINEBEGINSWITH="disable_functions ="
|
||||
export NEWVAL="disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen"
|
||||
|
||||
echo "== Fixing existing lines"
|
||||
find /etc/php/*/fpm/ -type f -name "php.ini" -exec grep -L "$NOTFOUNDVAL" {} \; | xargs sh -c 'for arg do echo "= Patching $arg"; sed -i "s|^$LINEBEGINSWITH.*|$NEWVAL|g" $arg; done' _
|
||||
|
||||
export NOTFOUNDVAL2="^$LINEBEGINSWITH"
|
||||
export REMOVELINETHATCONTAINS=$LINEBEGINSWITH
|
||||
|
||||
echo "== Adding missing lines"
|
||||
find /etc/php/*/fpm/ -type f -name "php.ini" -exec grep -L "$NOTFOUNDVAL2" {} \; | xargs sh -c 'for arg do echo "= Patching $arg"; sed -i "s|.*$REMOVELINETHATCONTAINS.*||g" $arg; echo "$NEWVAL" >> $arg; done' _
|
||||
|
||||
echo "== Restarting all PHP-FPM services"
|
||||
systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | xargs systemctl restart
|
||||
|
||||
echo "=== Everything done."
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue