-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagement.sh
149 lines (128 loc) · 3.25 KB
/
management.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
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
148
149
#!/bin/bash
echo "--------------------------"
echo "| Welcome to Anime&Manga |"
echo "--------------------------"
#Ask privilege root
if [ "$EUID" -ne 0 ]
then
echo "Eseguire come root"
exit 1
fi
# start installation of the script
ENABLE_PROXY=false
FILE_COMPOSE="docker-compose.yml"
SERVICE_POSTGRES=true
SERVICE_MONGO=true
SERVICE_RABBIT=true
SERVICE_PROXY=true
DEFAULT_FOLDER=true
for arg in "$@"
do
if [ "$arg" == "-h" ]
then
echo "Short explane this script of installation: "
echo "Create default folder for mount point and start docker compose"
echo ""
echo "Following commands: "
echo "dev -> Launch docker compose unstable"
echo ""
echo "Manage:"
echo "down -> stop all services"
echo ""
echo "Actions for start:"
echo "no-default-folder -> No create default folder for volumes"
echo "no-postgres -> Not start service postgres"
echo "no-mongo -> Not start service mongo"
echo "no-rabbit -> Not start service rabbit"
echo "no-proxy -> Not start service tor proxy"
exit 1
fi
if [ "$arg" == "dev" ]
then
FILE_COMPOSE="docker-compose-unstable.yml"
continue
fi
if [ "$arg" == "down" ]
then
sudo docker compose -f $FILE_COMPOSE down --timeout 120
exit 1
fi
if [ "$arg" == "no-default-folder" ]
then
DEFAULT_FOLDER=false
continue
fi
if [ "$arg" == "no-postgres" ]
then
SERVICE_POSTGRES=false
continue
fi
if [ "$arg" == "no-mongo" ]
then
SERVICE_MONGO=false
continue
fi
if [ "$arg" == "no-proxy" ]
then
SERVICE_PROXY=false
continue
fi
echo "Unknow command: $arg"
exit 1
done
#change value env of downloadservice
ENV_FILE="./env/download.env"
VAR_TO_CHANGE="PROXY_ENABLE"
NEW_VALUE="$SERVICE_PROXY"
if [ -f "$ENV_FILE" ]; then
sed -i "s/^$VAR_TO_CHANGE=.*/$VAR_TO_CHANGE=$NEW_VALUE/" "$ENV_FILE"
else
echo "The file $ENV_FILE not exists."
fi
# check folder
if [ "$DEFAULT_FOLDER" = true ]
then
if [ ! -d "/animeManga/data" ]
then
sudo mkdir -p /animeManga/data
echo "Created folder: /animeManga/data"
echo ""
fi
if [ ! -d "/animeManga/temp" ]
then
sudo mkdir /animeManga/temp
echo "Created folder: /animeManga/temp"
echo ""
fi
if [ ! -d "/animeManga/dataPostgres" ]
then
sudo mkdir /animeManga/dataPostgres
echo "Created folder: /animeManga/dataPostgres"
echo ""
fi
if [ ! -d "/animeManga/dataMongo" ]
then
sudo mkdir /animeManga/dataMongo
echo "Created folder: /animeManga/dataMongo"
echo ""
fi
fi
# start service
sudo docker compose -f $FILE_COMPOSE pull
sudo docker compose -f $FILE_COMPOSE down
COMMAND_COMPOSE="docker compose -f $FILE_COMPOSE up -d"
if [ "$SERVICE_POSTGRES" = false ]
then
COMMAND_COMPOSE="$COMMAND_COMPOSE --scale postgres=0 "
fi
if [ "$SERVICE_MONGO" = false ]
then
COMMAND_COMPOSE="$COMMAND_COMPOSE --scale mongo=0 "
fi
if [ "$SERVICE_PROXY" = false ]
then
COMMAND_COMPOSE="$COMMAND_COMPOSE --scale tor-proxy=0 "
fi
COMMAND_COMPOSE="$COMMAND_COMPOSE"
sudo $COMMAND_COMPOSE
sudo docker image prune