File: mirrorbits-basic

package info (click to toggle)
mirrorbits 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 984 kB
  • sloc: sh: 675; makefile: 93
file content (83 lines) | stat: -rwxr-xr-x 2,061 bytes parent folder | download | duplicates (2)
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
81
82
83
#!/bin/bash

set -eu

cleanup() {
    if systemctl is-active --quiet mirrorbits; then
        systemctl stop mirrorbits
    fi

    journalctl -u mirrorbits | tail -n 100

    if [ -e /var/log/mirrorbits/daemon.log ]; then
        tail -n 100 /var/log/mirrorbits/daemon.log
    fi

    rm -fr /var/log/mirrorbits
    rm -f  /etc/mirrorbits/mirrorbits.conf

    if [ "$DATADIR" ]; then
        rm -fr "$DATADIR"
    fi
}

trap cleanup EXIT

# Check and remember if a database is installed (we'll make
# use of that later).
DB=""
pkg_installed() {
    dpkg -s "$1" 2>/dev/null | grep -q "ok installed"
}
for db in redis valkey; do
    pkg_installed $db-server || continue
    DB=$db-server && break
done

# Prepare directories --- Note that we run mirrorbits via a
# systemd service, with various hardening settings enabled.
# Thus the mirrorbits daemon has limited access to the root
# filesystem, in particular /tmp is not available. For this
# reason we don't use AUTOPKGTEST_TMP.
DATADIR=$(mktemp -d /srv/mirrorbits-XXXXXX)
chmod 0755 $DATADIR
mkdir $DATADIR/repo

# Prepare mirrorbits config --- Either we have access to the
# GeoIP databases, either we define fallbacks in the config.
# We go for the later for simplicity.
cat <<EOF >/etc/mirrorbits/mirrorbits.conf
Repository: $DATADIR/repo
Fallbacks:
    - URL: http://foobar.example.org
EOF

# Disabled --- Use GeoIP test databases.
if false; then
    gitrepo=https://github.com/maxmind/MaxMind-DB
    path=raw/main/test-data
    for db in ASN City; do
        wget $gitrepo/$path/GeoLite2-$db-Test.mmdb \
            -O $DATADIR/GeoLite2-$db.mmdb
    done
    echo "GeoipDatabasePath: $DATADIR" >> \
        /etc/mirrorbits/mirrorbits.conf
fi

# Start the mirrorbits daemon
systemctl start mirrorbits

# We should be able to print the version
mirrorbits version

# Bail out if there's no database installed
if [ -z "$DB" ]; then
    echo "No database installed, end of the tests"
    exit 0
else
    echo "$DB is installed, keep testing"
fi

# Try a few more commands
mirrorbits refresh
mirrorbits list