mirror of
https://git.dn42.dev/dn42/registry.git
synced 2025-07-19 00:46:59 +08:00
Merge pull request 'update dn42_schema.py to work locally without registry.dn42.us + run shellcheck on included scripts' (#3599) from lare/registry:update-check-pol into master
Reviewed-on: https://git.dn42.dev/dn42/registry/pulls/3599 Reviewed-by: schema-checker <schema-checker@noreply.dn42.dev>
This commit is contained in:
commit
d120be1ca5
6 changed files with 1479 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail
|
set -o pipefail
|
||||||
|
|
||||||
if [ $# -eq 0 ]
|
if [ $# -eq 0 ]
|
||||||
then
|
then
|
||||||
|
@ -11,8 +11,8 @@ BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.r
|
||||||
BASE="$(dirname "$BASE")"
|
BASE="$(dirname "$BASE")"
|
||||||
cd "$BASE" || exit 1
|
cd "$BASE" || exit 1
|
||||||
|
|
||||||
git diff --name-only $1 | while IFS='/' read -ra LINE; do
|
git diff --name-only "$1" | while IFS='/' read -ra LINE; do
|
||||||
if [[ "${LINE[0]}" = "data" && -n "${LINE[2]}" ]]; then
|
if [[ "${LINE[0]}" = "data" && -n "${LINE[2]}" ]]; then
|
||||||
utils/schema-check/dn42-schema.py -v policy ${LINE[1]} ${LINE[2]} $2
|
utils/schema-check/dn42-schema.py -v policy "${LINE[1]}" "${LINE[2]}" "$2"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
18
check-pol2
Executable file
18
check-pol2
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 COMMIT YOUR-MNT"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")"
|
||||||
|
BASE="$(dirname "$BASE")"
|
||||||
|
cd "$BASE" || exit 1
|
||||||
|
|
||||||
|
git diff --name-only "$1" | while IFS='/' read -ra LINE; do
|
||||||
|
if [[ "${LINE[0]}" = "data" && -n "${LINE[2]}" ]]; then
|
||||||
|
utils/schema-check/dn42_schema_local.py -v policy "${LINE[1]}" "${LINE[2]}" "$2"
|
||||||
|
fi
|
||||||
|
done
|
|
@ -9,4 +9,7 @@ fi
|
||||||
BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")"
|
BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")"
|
||||||
BASE="$(dirname "$BASE")"
|
BASE="$(dirname "$BASE")"
|
||||||
|
|
||||||
grep -lrE "(\s|:)$1(\s|\$)" "$BASE/data/" | while read line; do utils/schema-check/dn42-schema.py fmt -i "$line"; done
|
grep -lrE "(\s|:)$1(\s|\$)" "$BASE/data/" | while read -r line; do
|
||||||
|
utils/schema-check/dn42-schema.py fmt -i "$line"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@ done
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# check for dn42registry remote, and add if missing
|
# check for dn42registry remote, and add if missing
|
||||||
git remote -v | grep dn42registry > /dev/null 2>&1
|
if ! git remote -v | grep dn42registry > /dev/null 2>&1
|
||||||
if [ "$?" -ne 0 ]
|
|
||||||
then
|
then
|
||||||
|
|
||||||
# was the URL specified directly ?
|
# was the URL specified directly ?
|
||||||
|
@ -81,8 +80,7 @@ then
|
||||||
if [ -z "$reg_proto" ]
|
if [ -z "$reg_proto" ]
|
||||||
then
|
then
|
||||||
# if the proto wasn't forced, try to guess it
|
# if the proto wasn't forced, try to guess it
|
||||||
git remote -v | grep 'https' > /dev/null 2>&1
|
if git remote -v | grep 'https' > /dev/null 2>&1
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
then
|
||||||
reg_proto='https'
|
reg_proto='https'
|
||||||
else
|
else
|
||||||
|
@ -112,8 +110,7 @@ fi
|
||||||
|
|
||||||
# ensure the local branch is up to date
|
# ensure the local branch is up to date
|
||||||
echo "Fetching dn42registry master"
|
echo "Fetching dn42registry master"
|
||||||
git fetch dn42registry master
|
if ! git fetch dn42registry master
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
then
|
||||||
echo 'ERROR: Failed to fetch registry master branch'
|
echo 'ERROR: Failed to fetch registry master branch'
|
||||||
echo 'Hint: you can use --ssh/--https to force use of ssh or https'
|
echo 'Hint: you can use --ssh/--https to force use of ssh or https'
|
||||||
|
@ -123,8 +120,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# find number of local commits
|
# find number of local commits
|
||||||
count=$(git rev-list --count HEAD ^dn42registry/master)
|
if ! count=$(git rev-list --count HEAD ^dn42registry/master)
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
then
|
||||||
echo "ERROR: Failed to find the number of local commits"
|
echo "ERROR: Failed to find the number of local commits"
|
||||||
echo "Please report this as a bug to the registry maintainters"
|
echo "Please report this as a bug to the registry maintainters"
|
||||||
|
@ -160,7 +156,7 @@ $(git log --oneline HEAD ^dn42registry/master)"
|
||||||
|
|
||||||
# and finally squash
|
# and finally squash
|
||||||
git reset --soft dn42registry/master
|
git reset --soft dn42registry/master
|
||||||
git commit $do_sign -m "$comment"
|
git commit "$do_sign" -m "$comment"
|
||||||
|
|
||||||
# show what happened
|
# show what happened
|
||||||
echo '---'
|
echo '---'
|
||||||
|
|
|
@ -14,8 +14,8 @@ fix_dns() {
|
||||||
{
|
{
|
||||||
set -e
|
set -e
|
||||||
echo "domain: ${DST}"
|
echo "domain: ${DST}"
|
||||||
cat "${TMP}" | grep -E '^(remarks):' || true
|
grep -E '^(remarks):' "${TMP}" || true
|
||||||
cat "data/dns/${SRC}" | grep '^nserver:' | tr -s " " | cut -d' ' -f2 | sort | uniq | xargs -i echo 'nserver: {}'
|
grep '^nserver:' "data/dns/${SRC}" | tr -s " " | cut -d' ' -f2 | sort | uniq | xargs -I{} echo 'nserver: {}'
|
||||||
drill -t "${DST}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
drill -t "${DST}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
||||||
echo 'org: ORG-DN42'
|
echo 'org: ORG-DN42'
|
||||||
echo 'mnt-by: DN42-MNT'
|
echo 'mnt-by: DN42-MNT'
|
||||||
|
@ -35,7 +35,7 @@ fix_inetnum() {
|
||||||
sed -r -i '/^(nserver|ds-rdata|status|org|policy|mnt-by|source|admin-c|tech-c):.*$/d' "data/${CLASS}/${DST}"
|
sed -r -i '/^(nserver|ds-rdata|status|org|policy|mnt-by|source|admin-c|tech-c):.*$/d' "data/${CLASS}/${DST}"
|
||||||
{
|
{
|
||||||
set -e
|
set -e
|
||||||
cat "data/dns/${SRC}" | grep '^nserver:' | tr -s " " | cut -d' ' -f2 | sort | uniq | xargs -i echo 'nserver: {}'
|
grep '^nserver:' "data/dns/${SRC}" | tr -s " " | cut -d' ' -f2 | sort | uniq | xargs -I{} echo 'nserver: {}'
|
||||||
drill -t "${DNS_NAME}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
drill -t "${DNS_NAME}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
||||||
echo 'status: ALLOCATED'
|
echo 'status: ALLOCATED'
|
||||||
echo "policy: ${POLICY}"
|
echo "policy: ${POLICY}"
|
||||||
|
@ -54,7 +54,7 @@ fix_dns_ds_only() {
|
||||||
{
|
{
|
||||||
set -e
|
set -e
|
||||||
echo "domain: ${DST}"
|
echo "domain: ${DST}"
|
||||||
cat "${TMP}" | grep -E '^(nserver|remarks):' || true
|
grep -E '^(nserver|remarks):' "${TMP}" || true
|
||||||
drill -t "${DST}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
drill -t "${DST}" "@${DS_NSERVER}" DNSKEY -s | grep sha256 | cut -d: -f2 | sed -E 's/^ [^\t ]+\t900\tIN\tDS\t/ds-rdata: /g' | grep -E "${KSK_PATTERN}"
|
||||||
echo 'org: ORG-DN42'
|
echo 'org: ORG-DN42'
|
||||||
echo 'mnt-by: DN42-MNT'
|
echo 'mnt-by: DN42-MNT'
|
1445
utils/schema-check/dn42_schema_local.py
Executable file
1445
utils/schema-check/dn42_schema_local.py
Executable file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue