-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.sh
executable file
·41 lines (41 loc) · 1.27 KB
/
admin.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
#!/bin/bash
DIR=`pwd`
export USAGE="Usage: init.sh up|down|build|ls|init|shell [7|8]"
export CONTAINER7="php8_tips_php7"
export CONTAINER8="php8_tips_php8"
export INIT=0
if [[ -z "$1" ]]; then
echo $USAGE
exit 1
elif [[ "$1" = "up" || "$1" = "start" ]]; then
docker-compose up -d $2
elif [[ "$1" = "down" || "$1" = "stop" ]]; then
docker-compose down
sudo chown -R $USER:$USER *
sudo chown -R $USER:$USER .*
elif [[ "$1" = "build" ]]; then
docker-compose build $2
elif [[ "$1" = "ls" ]]; then
docker container ls
elif [[ "$1" = "init" ]]; then
docker exec $CONTAINER7 /bin/bash -c "/etc/init.d/mysql restart"
docker exec $CONTAINER7 /bin/bash -c "/etc/init.d/php-fpm restart"
docker exec $CONTAINER7 /bin/bash -c "/etc/init.d/httpd restart"
docker exec $CONTAINER8 /bin/bash -c "/etc/init.d/mysql restart"
docker exec $CONTAINER8 /bin/bash -c "/etc/init.d/php-fpm restart"
docker exec $CONTAINER8 /bin/bash -c "/etc/init.d/httpd restart"
elif [[ "$1" = "shell" ]]; then
if [[ -z "$2" ]]; then
echo "You need to specify either 7 or 8"
echo $USAGE
exit 1
elif [[ "$2" = "7" ]]; then
docker exec -it $CONTAINER7 /bin/bash
else
docker exec -it $CONTAINER8 /bin/bash
fi
else
echo $USAGE
exit 1
fi
exit 0