-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0-list-projets
executable file
·148 lines (112 loc) · 2.84 KB
/
0-list-projets
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
#set -x
usage() {
PROGNAME=$0
cat <<- EOF
$PROGNAME dev|prod
EOF
exit 1
}
init(){
GREEN='\033[0;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
. ./config.ini
}
clearmsg(){
msg=$1
printf "${CYAN}${msg}${NC}\n"
}
generaldb_credential(){
unset login
prompt="Enter generaldb_mariadb ADMIN username: "
read -p "$prompt" username
unset password
prompt="Enter generaldb_mariadb ADMIN password: "
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
prompt='*'
password+="$char"
done
echo
}
generaldb_credentials_file(){
mode=$1
unset username
unset password
if [[ ! -f .${mode}_generaldb_creds ]]; then
echo "Credentials file cannot be found (.generaldb_creds)"
exit 1
fi
. ./.${mode}_generaldb_creds
username=${mode}_username
username=${!username}
password=${mode}_password
password=${!password}
if [[ -z $username ]] || [[ -z password ]]; then
echo "Credentials are empty (in .generaldb_creds)"
exit 1
fi
}
show_dbs(){
mode=$1
generaldb_container_name=${mode}_generaldb_container_name
generaldb_container_name=${!generaldb_container_name}
command="show databases;"
docker exec -it $generaldb_container_name mysql -u "$username" -p$password -e"$command"
}
show_db_users(){
mode=$1
generaldb_container_name=${mode}_generaldb_container_name
generaldb_container_name=${!generaldb_container_name}
command="SELECT User FROM mysql.user;"
docker exec -it $generaldb_container_name mysql -u "$username" -p$password -e"$command"
}
main(){
init
# mode=$1
# generaldb_container_name=${mode}_generaldb_container_name
# generaldb_container_name=${!generaldb_container_name}
clearmsg "Content of /var/www"
ls -1A /var/www
echo
clearmsg "Content of /projects"
ls -1A /projects
echo
generaldb_credentials_file dev
clearmsg "Databases in dev DB container"
show_dbs dev
echo
clearmsg "Users in dev DB container"
show_db_users dev
echo
generaldb_credentials_file prod
clearmsg "Databases in prod DB container"
show_dbs prod
echo
clearmsg "Users in prod DB container"
show_db_users prod
echo
clearmsg "Running containers"
docker ps --format='{{.Names}}'
echo
clearmsg "Stopped containers"
diff --unchanged-group-format="" --new-group-format="%>" <(docker ps --format='{{.Names}}') <(docker ps -a --format='{{.Names}}')
echo
clearmsg "Content of Reverse Proxy path"
for file in $(ls -1Atr $reverse_proxy_defpath); do
echo $file $(grep proxy_pass $reverse_proxy_defpath/$file)
done
echo
}
if [[ $# -ne 0 ]]
then
init
usage
fi
main $@