forked from adrianreber/mirrorlist-server
-
Notifications
You must be signed in to change notification settings - Fork 6
/
start.sh
executable file
·80 lines (54 loc) · 1.33 KB
/
start.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
#!/usr/bin/bash
set -e
cd $(dirname $0)
cfg=$1
proto=./config/mirrorlist_cache.proto
gen_proto() {
./generate-mirrorlist-cache -c $cfg -o $proto
}
proto_checksum() {
md5sum -z $proto | awk '{print $1}'
}
process_num() {
ps -ef | grep "mirrorlist-server --listen 0.0.0.0" | grep -v grep | awk '{print $2}'
}
log() {
echo "$(date), $1"
}
gen_proto
checksum=$(proto_checksum)
log "checksum = $checksum"
set +e
while true
do
log "start server!!!"
./mirrorlist-server --listen 0.0.0.0 -c ./config/mirrorlist_cache.proto -g ./config/global_netblocks.txt --log ./mirrorlist-server.log --cccsv ./config/country_continent.csv --geoip ./config/GeoLite2-Country.mmdb &
sleep 5
pn=$(process_num)
test -z "$pn" && continue
sleep 3600
while true
do
gen_proto
if [ $? -eq 0 ]; then
v=$(proto_checksum)
log "check checksum, old=$checksum, new=$v"
if [ -n "$v" -a "$v" != "$checksum" ]; then
log "save new checksum"
checksum=$v
break
fi
else
log "gen proto failed"
fi
sleep 60
done
while true
do
pn=$(process_num)
test -z "$pn" && break
kill -9 $pn
log "kill mirrorlist-server: $pn"
sleep 1
done
done