-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-dev.sh
115 lines (100 loc) · 2.64 KB
/
start-dev.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
production=false
if [[ "$2" = "production" ]] || [[ "$1" = "production" ]]
then
production=true
fi
CYAN='\033[00;36m'
WHITE='\033[01;37m'
echo " "
echo "----------------------------------------------------------"
echo "- SCRIPT Ruined world"
echo "- DERNIERE MAJ 27/02/2019"
echo "- MODE PRODUCTION ACTIVE : ${production}"
echo "----------------------------------------------------------"
setTitre() {
echo -e ""
echo -e "${CYAN}------------------------------------------------"
echo -e $1
echo -e "------------------------------------------------"
echo -e ""
}
all() {
composeupdate
checkcache
chmodfiles
updatedb
dumpenv
}
checkcache() {
setTitre "Vidage du cache"
sudo rm -rf var/cache/*
sudo rm -rf var/logs/*
php bin/console cache:clear --no-warmup
HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var var/cache var/logs var/sessions
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var var/cache var/logs var/sessions
php bin/console cache:warmup
}
composeupdate() {
setTitre "Composer update"
composer update
}
chmodfiles() {
setTitre "Ajout des permissions sur web, var, data et tmp"
mkdir var/sessions
mkdir var/sessions/dev
sudo chmod -R 775 var/*
sudo chmod -R 765 data
sudo chmod -R 765 tmp
sudo chown -R www-data:www-data data
sudo chown -R www-data:www-data tmp
sudo chown -R 1002:1002 public
}
restartservice() {
setTitre "Reload php-fpm + apache2"
sudo service php7.2-fpm reload
sudo service apache2 reload
}
updatedb(){
setTitre "Lancement de doctrine:schema:update"
php bin/console doctrine:schema:update --force
}
dumpenv() {
if [[ "$production" = true ]]
then
setTitre "Dump environment file (mode production)"
composer dump-env prod
else
setTitre "Dump environment file (mode dev)"
composer dump-env dev
fi
}
helpermore(){
setTitre "Commandes disponibles"
echo "cache: Vide le cache"
echo "update: Met a jour les packets Composer"
echo "doctrine: met à jour les entités"
echo "help: Affiche des informations sur les commandes disponibles"
}
if [[ "$1" = "cache" ]]
then
checkcache
elif [[ "$1" = "update" ]]
then
composeupdate
elif [[ "$1" = "doctrine" ]]
then
updatedb
elif [[ "$1" = "dumpenv" ]]
then
dumpenv
elif [[ "$1" = "" ]] || [[ "$1" = "production" ]]
then
all
elif [[ "$1" = "-h" ]] || [[ "$1" = "help" ]] || [[ "$1" = "--help" ]]
then
helpermore
else
helpermore
fi