Last active
March 6, 2020 13:56
-
-
Save texboy/bf5c9a933fbfe27b35d4d2a9c47196e6 to your computer and use it in GitHub Desktop.
made by @lnoering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function had { | |
case $1 in | |
## list ip of container specific | |
'dip') | |
if [ $# -eq 2 ]; then | |
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $2 | |
else | |
echo "=[ Parameters ]===============================================" | |
echo " Please, inform the container name " | |
fi | |
;; | |
## control php version | |
'php') | |
if [ $# -eq 2 ]; then | |
changePHPVersion $2 | |
else | |
echo "=[ Parameters ]===============================================" | |
echo " Please, inform the version number " | |
fi | |
;; | |
## control xdebug enable or disable with version | |
'debug') | |
if [ $# -eq 2 ]; then | |
controlXdebug $2 | |
else | |
echo "=[ Parameters ]===============================================" | |
echo " Please, inform ON or OFF " | |
fi | |
;; | |
*) echo "=[ Info ]=====================================================" | |
echo "Use $0 command " | |
echo "=[ Parameters ]===============================================" | |
echo " dip : Informe o nome do container. ex.: database_db_1 " | |
echo " php : Informe a versão do PHP ex.: 7.2 " | |
echo " debug : Informe se deseja ativar (on) ou desativar (off) " | |
echo "=[ Examplo ]==================================================" | |
echo "had php 7.1 | had debug on | had dip database_db_1 " | |
;; | |
esac | |
} | |
function changePHPVersion { | |
echo " You changing php version to $1 " | |
## validar a versão | |
phpVersion="php"$1 | |
listVersions=`ls /usr/bin/php*` | |
echo $phpVersion | |
if [ -f "/usr/bin/$phpVersion" ]; then | |
for file in /usr/bin/php[0-9]*; do | |
phpVersionExist=$(echo "${file##*/}"); | |
sudo a2dismod $phpVersionExist | |
done | |
sudo a2enmod $phpVersion | |
sudo update-alternatives --set php /usr/bin/$phpVersion | |
controlWebServer | |
echo " Current version: $( php -v | head -n 1 | cut -c-7 ) " | |
else | |
echo " The php ($phpVersion) version not exist bin FILE " | |
fi | |
} | |
function controlXdebug { | |
echo " You changing XDEBUG to $1 " | |
case $1 in | |
'on') | |
sudo sed -i "s/;zend_extension=xdebug.so/zend_extension=xdebug.so/g" /etc/php/*/mods-available/xdebug.ini | |
sudo sed -i "s/;xdebug.remote_enable=true/xdebug.remote_enable=true/g" /etc/php/*/mods-available/xdebug.ini | |
sudo sed -i "s/;xdebug.remote_autostart=true/xdebug.remote_autostart=true/g" /etc/php/*/mods-available/xdebug.ini | |
;; | |
*) | |
sudo sed -i "s/zend_extension=xdebug.so/;zend_extension=xdebug.so/g" /etc/php/*/mods-available/xdebug.ini | |
sudo sed -i "s/xdebug.remote_enable=true/;xdebug.remote_enable=true/g" /etc/php/*/mods-available/xdebug.ini | |
sudo sed -i "s/xdebug.remote_autostart=true/;xdebug.remote_autostart=true/g" /etc/php/*/mods-available/xdebug.ini | |
;; | |
esac | |
controlWebServer | |
cat /etc/php/*/mods-available/xdebug.ini | |
} | |
function controlWebServer { | |
sudo service apache2 restart | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment