forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpypi.sh
executable file
·52 lines (46 loc) · 998 Bytes
/
pypi.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
#!/bin/bash
BANDERSNATCH=${BANDERSNATCH:-"/usr/local/bin/bandersnatch"}
CONF="/tmp/bandersnatch.conf"
INIT=${INIT:-"0"}
if [ ! -d "$TUNASYNC_WORKING_DIR" ]; then
mkdir -p $TUNASYNC_WORKING_DIR
INIT="1"
fi
echo "Syncing to $TUNASYNC_WORKING_DIR"
if [[ $INIT == "0" ]]; then
cat > $CONF << EOF
[mirror]
directory = ${TUNASYNC_WORKING_DIR}
master = https://pypi.python.org
timeout = 15
workers = 10
stop-on-error = true
delete-packages = true
EOF
/usr/bin/timeout -s INT 7200 $BANDERSNATCH -c $CONF mirror
if [[ $? == 124 ]]; then
echo 'Sync timeout (/_\\)'
exit 1
fi
else
cat > $CONF << EOF
[mirror]
directory = ${TUNASYNC_WORKING_DIR}
master = https://pypi.python.org
timeout = 15
workers = 10
stop-on-error = false
delete-packages = false
EOF
$BANDERSNATCH -c $CONF mirror
fi
TODOFILE="${TUNASYNC_WORKING_DIR}/todo"
if [[ -f $TODOFILE ]]; then
rsize=`stat -c "%s" ${TODOFILE}`
if [[ "$rsize" != "0" ]]; then
echo "Sync Failed T_T"
exit 1
fi
fi
echo "Sync Done ^_-"
exit 0