-
Notifications
You must be signed in to change notification settings - Fork 97
/
update.sh
executable file
·30 lines (22 loc) · 930 Bytes
/
update.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
#!/bin/bash
cd "$1" # dir with python script
# check if update is required
server_version=$(curl -L -s https://gitlab.com/a_gonda/nowarddos/-/raw/main/version.txt | head)
local_version=$(cat version.txt)
if [ "$server_version" = "$local_version" ]; then
echo "No update is required. Installed latest version: $local_version"
exit 1
fi
echo "Update is required. Server version is $server_version. Local version is $local_version"
cd "$( dirname "$1" )" # parent dir of python script
git clone "https://gitlab.com/a_gonda/nowarddos.git" "tmp" || exit 1
kill -9 $(pgrep python3) &> /dev/null
rm -rf "$1"
mv "tmp" "$1"
rm -rf ../logs && \
mkdir -p ../logs && touch ../logs/nowar.log && \
cd "$1"
# for migration from docker to direct python run: stop currently running containers, if any
docker-compose -f docker-compose.yml down &> /dev/null
# start python script directly
nohup python3 main.py > ../logs/nowar.log 2>&1