summarylogtreecommitdiffstats
path: root/ipset-loader
blob: 0d6e439329628efb7c84c0e7af8c7d2663d0d034 (plain)
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
#!/bin/bash
if [ $# -eq 0 ]; then
    echo "usage: $0 <ipset-file>"
    echo "will also try ipset-file.zst if ipset-file does not exist."
fi

if [ ! -f $1 ]; then
    if [ ! -f $1.zst ]; then
        echo "fatal error: neither $1 nor $1.zst is found."
        exit 1
    else
        echo "$1.zst is being loaded..."
        zstdcat $1.zst | ipset restore -!
    fi
else
    if [[ $1 == *.zst ]]; then
        echo "$1 is being loaded..."
        zstdcat $1 | ipset restore -!
    else
        echo "$1 is being loaded..."
        cat $1 | ipset restore -!
    fi
fi

exit $?