Skip to content

Commit

Permalink
Add tsumugu (#99)
Browse files Browse the repository at this point in the history
* Add tsumugu

* tsumugu: add parser option

* tsumugu: add threads option
  • Loading branch information
taoky authored Jul 23, 2023
1 parent 6add795 commit 6a48b0d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [rsync](#rsync)
- [rubygems](#rubygems)
- [stackage](#stackage)
- [tsumugu](#tsumugu)
- [winget-source](#winget-source)
- [yum-sync](#yum-sync)
- [License](#license)
Expand Down Expand Up @@ -413,6 +414,24 @@ Stackage doesn't need to specify upstream, but this mirror use cabal to install

Read the [user guide](https://www.haskell.org/cabal/users-guide/installing-packages.html#repository-specification) before writing preferred mirror to `config`

## tsumugu

[![tsumugu](https://img.shields.io/docker/image-size/ustcmirror/tsumugu/latest)](https://hub.docker.com/r/ustcmirror/tsumugu "tsumugu")
[![stackage](https://img.shields.io/docker/pulls/ustcmirror/tsumugu)](https://hub.docker.com/r/ustcmirror/tsumugu "tsumugu")

An alternative HTTP(S) syncing tool, replacing `rclone` and `lftp` in some cases. See [usage](https://github.com/taoky/tsumugu#usage).

| Parameter | Description |
| ---------------------- | --------------------------------------------------------------------------------------------------- |
| `UPSTREAM` | Sets the url of upstream. |
| `TSUMUGU_MAXDELETE` | Maximum number of files that can be removed. Defaults to `1000`. |
| `TSUMUGU_TIMEZONEFILE` | The file URL for guessing remote server timezone. |
| `TSUMUGU_EXCLUDE` | Files to be excluded. Value example: `"--exclude '^temp'"` |
| `TSUMUGU_USERAGENT` | The user agent of `tsumugu` syncing program. Defaults to `Tsumugu Syncing Tool/$(tsumugu_version)`. |
| `TSUMUGU_PARSER` | HTML parser used to parse index page. Defaults to `nginx`. |
| `TSUMUGU_THREADS` | Number of threads to use to download in parallel. Defaults to 2. |
| `TSUMUGU_EXTRA` | Extra options. Defaults to empty. |

### winget-source

[![winget-source](https://img.shields.io/docker/image-size/ustcmirror/winget-source/latest)](https://hub.docker.com/r/ustcmirror/winget-source "winget-source")
Expand Down
10 changes: 10 additions & 0 deletions tsumugu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ustcmirror/base:alpine
LABEL maintainer "Keyu Tao <taoky AT ustclug.org>"

RUN apk add --no-cache wget ca-certificates && \
cd /tmp/ && wget -q "https://github.com/taoky/tsumugu/releases/download/20230722/tsumugu" && \
mv /tmp/tsumugu /usr/local/bin/ && \
chmod +x /usr/local/bin/tsumugu && \
rm -rf /tmp/* && apk del wget

ADD sync.sh /
42 changes: 42 additions & 0 deletions tsumugu/sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

## EXPORTED IN entry.sh
#TO=

## SET IN ENVIRONMENT VARIABLES
#BIND_ADDRESS=
#TSUMUGU_MAXDELETE=
#TSUMUGU_TIMEZONEFILE=
#TSUMUGU_EXCLUDE=
#TSUMUGU_USERAGENT=
#TSUMUGU_PARSER=
#TSUMUGU_THREADS=
#TSUMUGU_EXTRA=

set -eu
[[ $DEBUG = true ]] && set -x


BIND_ADDRESS=${BIND_ADDRESS:-}
TSUMUGU_MAXDELETE=${TSUMUGU_MAXDELETE:-1000}
TSUMUGU_TIMEZONEFILE=${TSUMUGU_TIMEZONEFILE:-}
TSUMUGU_EXCLUDE=${TSUMUGU_EXCLUDE:-}
TSUMUGU_USERAGENT=${TSUMUGU_USERAGENT:-"tsumugu HTTP Syncing Tool/"$(tsumugu --version | cut -d' ' -f2)}
TSUMUGU_PARSER=${TSUMUGU_PARSER:-"nginx"}
TSUMUGU_THREADS=${TSUMUGU_THREADS:-"2"}
TSUMUGU_EXTRA=${TSUMUGU_EXTRA:-}

if [[ -n $TSUMUGU_TIMEZONEFILE ]]; then
TSUMUGU_TIMEZONEFILE="--timezone-file $TSUMUGU_TIMEZONEFILE"
fi

if [[ $DEBUG = true ]]; then
export RUST_LOG="tsumugu=debug"
fi

exec tsumugu sync $TSUMUGU_TIMEZONEFILE \
--user-agent "$TSUMUGU_USERAGENT" \
--max-delete "$TSUMUGU_MAXDELETE" \
--parser "$TSUMUGU_PARSER" \
--threads "$TSUMUGU_THREADS" \
$TSUMUGU_EXCLUDE $TSUMUGU_EXTRA "$UPSTREAM" "$TO"

0 comments on commit 6a48b0d

Please sign in to comment.