update pypi.sh and termux.sh

This commit is contained in:
Justin Wong 2016-05-03 01:00:21 +08:00
parent 5406a0bc92
commit 5975d7c5d5
2 changed files with 35 additions and 4 deletions

34
pypi.sh
View File

@ -1,9 +1,37 @@
#!/bin/bash #!/bin/bash
BANDERSNATCH=${BANDERSNATCH:-"/usr/local/bin/bandersnatch"}
CONF="/tmp/bandersnatch.conf"
INIT=${INIT:-"0"}
if [ ! -d "$TUNASYNC_WORKING_DIR" ]; then if [ ! -d "$TUNASYNC_WORKING_DIR" ]; then
echo "Directory not exists, fail" mkdir -p $TUNASYNC_WORKING_DIR
exit 1 INIT="1"
fi fi
echo "Syncing to $TUNASYNC_WORKING_DIR" echo "Syncing to $TUNASYNC_WORKING_DIR"
/usr/bin/timeout -s INT 3600 /home/tuna/.virtualenvs/bandersnatch/bin/bandersnatch -c /etc/bandersnatch.conf mirror || exit 1 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 || exit 1
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 || exit 1
fi

View File

@ -7,10 +7,13 @@ _here=`dirname $(realpath $0)`
BASE_PATH="${TUNASYNC_WORKING_DIR}" BASE_PATH="${TUNASYNC_WORKING_DIR}"
base_url="http://apt.termux.com" base_url=${TUNASYNC_UPSTREAM_URL:-"http://termux.net"}
ARCHES=("aarch64" "all" "arm" "i686") ARCHES=("aarch64" "all" "arm" "i686")
for arch in ${ARCHES[@]}; do for arch in ${ARCHES[@]}; do
echo "start syncing: ${arch}" echo "start syncing: ${arch}"
apt-download-binary "${base_url}" "stable" "main" "${arch}" "${BASE_PATH}" || true apt-download-binary "${base_url}" "stable" "main" "${arch}" "${BASE_PATH}" || true
done done
echo "finished" echo "finished"