forked from sugarcrm-developers/SugarDockerized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdebug.sh
executable file
·76 lines (63 loc) · 1.97 KB
/
xdebug.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/bash
# Grab full name of php container
PHP_CONTAINER=$(docker ps | grep sugar-web1 | awk '{print $1}')
getMyIP ()
{
local _ip _myip _line _nl=$'\n'
while IFS=$': \t' read -a _line ;do
[ -z "${_line%inet}" ] &&
_ip=${_line[${#_line[1]}>4?1:2]} &&
[ "${_ip#127.0.0.1}" ] && _myip=$_ip
done< <(LANG=C /sbin/ifconfig)
printf ${1+-v} $1 "%s${_nl:0:$[${#1}>0?0:1]}" $_myip
}
xdebug_status ()
{
echo 'xDebug status'
docker exec -it $PHP_CONTAINER bash -c 'php -v'
}
xdebug_start ()
{
echo 'Start xDebug'
# Uncomment line with xdebug extension, thus enabling it
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \
/usr/local/etc/php/conf.d/xdebug.ini"
docker exec -it $PHP_CONTAINER bash -c "${ON_CMD}"
if [[ "$1" == "change-ip" ]]; then
# Grab IP address of eth0
IP=$(getMyIP)
# Change IP address for parameter xdebug.client_host
IP_CMD="sed -i 's/^xdebug.client_host=.*/xdebug.client_host=$IP/g' \
/usr/local/etc/php/conf.d/xdebug.ini"
docker exec -it $PHP_CONTAINER bash -c "${IP_CMD}"
echo "New IP of client_host: $IP"
fi
docker restart $PHP_CONTAINER
docker exec -it $PHP_CONTAINER bash -c 'php -v'
}
xdebug_stop ()
{
echo 'Stop xDebug'
# Comment out xdebug extension line
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/xdebug.ini"
docker exec -it $PHP_CONTAINER bash -c "${OFF_CMD}"
docker restart $PHP_CONTAINER
docker exec -it $PHP_CONTAINER bash -c 'php -v'
}
case $1 in
stop|STOP)
xdebug_stop
;;
start|START)
xdebug_start "$2"
;;
status|STATUS)
xdebug_status
;;
*)
echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container."
echo "xDebug must have already been installed."
echo "Usage:"
echo " .php/xdebug stop|start|status"
esac
exit 1