-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctrl.sh
More file actions
64 lines (57 loc) · 1.42 KB
/
ctrl.sh
File metadata and controls
64 lines (57 loc) · 1.42 KB
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
#!/usr/bin/env bash
printf 'Front - Experimental parser written in PHP - Control Script\n'
help()
{
printf "Help pages
ctrl.sh action [otions]
Available actions:
help - Show this help text
install - Run composer install (in docker)
run - Run application in docker (install must be run once before!)
-x, --xdebug - With xdebug enabled
"
}
install()
{
docker run --rm -v $(pwd):/app -v $HOME/.composer/auth.json:/tmp/composer/auth.json -v $HOME/.composer/cache/:/tmp/composer/cache/ -w /app in2code/php-dev:7.4-fpm composer install
}
run()
{
if [[ "$XDEBUG" -eq 1 ]]; then
docker run --rm -it -v$(pwd):/app -w /app -e PHP_IDE_CONFIG="serverName=front.docker" in2code/php-dev:7.4-fpm php -dxdebug.remote_autostart=1 -dxdebug.remote_host=$(ifconfig $(/sbin/ip route | grep -v tun | awk '/default/ { print $5 }') | awk -F ' *|:' '/inet /{print $3}') ./front
else
docker run --rm -it -v$(pwd):/app -w /app in2code/php-dev:7.4-fpm ./front
fi
}
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-x|--xdebug)
XDEBUG=1
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [[ "$1" != "" ]]; then
action="$1"
else
action='help'
fi
case "$action" in
help)
help;
;;
install)
install;
;;
run)
run;
;;
esac