File: use-system-ieee-data.sh

package info (click to toggle)
ipv6calc 4.1.0-0.2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,676 kB
  • sloc: ansic: 101,567; sh: 6,796; perl: 3,867; xml: 1,475; makefile: 908
file content (34 lines) | stat: -rwxr-xr-x 1,075 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
#!/bin/sh

set -e

if [ $# -eq 0 ]; then
    echo "Usage: $0 <regenerate|restore>"
    exit 1
fi

for dir in databases/ieee-*; do
    database=${dir#*-}
    (
        cd "$dir"
        if [ "$1" = "regenerate" ]; then
            if [ ! -f "/var/lib/ieee-data/${database}.csv" ]; then
                # known to happen for OUI-28 with ieee-data 20220827.1
                echo "Skipping database ${database} as a CSV for it doesn't exist."
		continue
            fi
            if [ ! -f "dbieee_${database}.h.orig" ]; then
                # keep a copy of the original "source" file
		# but only if we haven't done so already to make this idempotent
                mv "dbieee_${database}.h" "dbieee_${database}.h.orig"
            fi
            cp --preserve=timestamps "/var/lib/ieee-data/${database}.csv" .
            make create
        elif [ "$1" = "restore" ]; then
            if [ -f "dbieee_${database}.h.orig" ]; then
                mv "dbieee_${database}.h.orig" "dbieee_${database}.h"
            fi
            rm -f "${database}.csv"
        fi
    )
done