-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·65 lines (57 loc) · 1.64 KB
/
init.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
#!/usr/bin/env bash
WEB_SITE=mysite
WEB_SITE_YII=mysite-yii
down_docker_compose(){
if [[ $(docker-compose top) ]]; then
docker-compose down
fi
}
run_docker_compose(){
if [[ -z $(docker-compose top) ]]; then
docker-compose up -d
fi
}
clear_docker_tmp_folders(){
sudo rm -rf runtime $WEB_SITE_YII/runtime $WEB_SITE_YII/vendor $WEB_SITE_YII/composer.lock
}
create_tmp_folders(){
mkdir -p runtime $WEB_SITE_YII/runtime $WEB_SITE_YII/runtime/properties $WEB_SITE_YII/public/assets $WEB_SITE_YII/models
sudo chmod -R 777 runtime $WEB_SITE_YII/runtime $WEB_SITE_YII/public/assets
}
if [ $# -eq 0 ]
then
echo "No arguments supplied. Run with --help to get more information."
exit
fi
while test $# -gt 0
do
case "$1" in
--help)
echo "[arguments]"
echo "reset - down composer, clear tmp folders"
echo "site - run empty web site"
echo "site-yii - run yii2 website (or just install composer dependencies if docker is already running)"
;;
reset)
down_docker_compose
docker-compose build
clear_docker_tmp_folders
;;
site)
create_tmp_folders
run_docker_compose
;;
site-yii)
create_tmp_folders
echo mysql >> $WEB_SITE_YII/runtime/properties/mysql_host
docker-compose run --rm php composer install -d /var/www/$WEB_SITE_YII/
run_docker_compose
;;
--*) echo "Unknown option $1"
;;
*) echo "Unknown argument $1"
;;
esac
shift
done
exit 0