File: fetch_sequence.sh

package info (click to toggle)
lebiniou 3.67.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,456 kB
  • sloc: ansic: 28,674; makefile: 1,276; sh: 602; awk: 432; xml: 261; javascript: 23
file content (31 lines) | stat: -rwxr-xr-x 615 bytes parent folder | download
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
#!/usr/bin/env bash
#
# Fetch the current sequence on [<host> [:<port>]] (default: localhost:30542)
# and stores it in ~/.lebiniou/sequences
#
# Requires: curl, jq
#
CURL=curl
JQ=jq

for cmd in $CURL $JQ; do
    command -v $cmd >/dev/null 2>&1 || { echo >&2 "$cmd not found, aborting."; exit 1; }
done

HOST=localhost
PORT=30542

if (( $# > 0 )); then
    HOST=$1
    if (( $# > 1 )); then
        PORT=$2
    fi
fi

FILE=$(mktemp)
$CURL --silent --output $FILE http://$HOST:$PORT/sequence
# extract sequence id
ID=`$JQ '.id' $FILE`
OUTPUT="$HOME/.lebiniou/sequences/$ID.json"
mv $FILE $OUTPUT
echo "Wrote $OUTPUT"