1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-22 01:00:41 +08:00

update scripts

This commit is contained in:
Septs 2020-07-21 00:19:10 +08:00
parent 7ad5607418
commit 62b2090cc9
12 changed files with 60 additions and 49 deletions

View file

@ -21,39 +21,15 @@ jobs:
shell: bash
run: |
sudo apt update -qq
sudo apt install -y python3 git openssh-client \
python3-toml python3-tabulate
sudo apt install -y python3 git openssh-client
- name: Run roa script
- name: Run ROA script
shell: bash
run: |
maxlen4=29
maxlen6=64
mkdir -p roa_dir
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -o roa_dir/roa46_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -4 -o roa_dir/roa4_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -6 -o roa_dir/roa6_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -j -o roa_dir/roa46.json
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -e -o roa_dir/neonetwork.json
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -r -o roa_dir/rfc8416.json
python3 scripts/roa.py --summary --output roa_dir/README.txt
run: .scripts/generate-roa.sh
- name: Upload files
env:
SSHPRIVKEY: ${{ secrets.KEY }}
shell: bash
run: |
cd roa_dir
[ -n "$SSHPRIVKEY" ] || (echo SSHPRIVKEY is not set; exit 1)
( set -e;
mkdir -p ~/.ssh
echo "$SSHPRIVKEY" | base64 -d > ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/id_ed25519
ssh -o StrictHostKeyChecking=no git@github.com || true
git init && git add .
git config user.name "neonet roa bot"
git config user.email "bot@github.com"
git commit -m "Generated at $(TZ='UTC' date +%Y%m%d-%H%M%S.%N)"
git push --force --quiet "git@github.com:NeoCloud/NeoNetwork-ROA.git" HEAD:master
) || (shred ~/.ssh/id_ed25519; exit 1)
shred ~/.ssh/id_ed25519
- name: Push to NeoCloud/NeoNetwork-ROA
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: generated
repository: NeoCloud/NeoNetwork-ROA

View file

@ -21,19 +21,8 @@ jobs:
shell: bash
run: |
sudo apt update -qq
sudo apt install -y python3 git openssh-client \
python3-toml python3-tabulate
sudo apt install -y python3 git openssh-client
- name: Run roa script
- name: Run ROA script
shell: bash
run: |
maxlen4=29
maxlen6=64
mkdir -p roa_dir
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -o roa_dir/roa46_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -4 -o roa_dir/roa4_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -6 -o roa_dir/roa6_bird2.conf
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -j -o roa_dir/roa46.json
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -e -o roa_dir/neonetwork.json
python3 scripts/roa.py -m ${maxlen4} -M ${maxlen6} -r -o roa_dir/rfc8416.json
python3 scripts/roa.py --summary --output roa_dir/README.txt
run: .scripts/generate-roa.sh

1
.scripts/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/.venv

23
.scripts/generate-roa.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -xeuo pipefail
IFS=$'\n\t'
export MAX_LEN_4=29
export MAX_LEN_6=64
if [ ! -d .venv ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
mkdir -p "generated"
pushed generated
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -o roa46_bird2.conf
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -4 -o roa4_bird2.conf
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -6 -o roa6_bird2.conf
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -j -o roa46.json
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -e -o neonetwork.json
.scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -r -o rfc8416.json
.scripts/roa.py --summary --output README.txt

18
.scripts/push-to-roa.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -xeuo pipefail
IFS=$'\n\t'
pushed roa_dir
if [ -n "$SSHPRIVKEY" ]; then
echo SSHPRIVKEY is not set
exit 1
fi
mkdir -p "$HOME/.ssh"
echo "$SSHPRIVKEY" | base64 -d >"$HOME/.ssh/id_ed25519"
chmod 0600 "$HOME/.ssh/id_ed25519"
ssh -o StrictHostKeyChecking=no git@github.com || true
git init && git add .
git config user.name "neonet roa bot"
git config user.email "bot@github.com"
git commit -m "Generated at $(TZ='UTC' date +%Y%m%d-%H%M%S.%N)"
git push --force --quiet "git@github.com:NeoCloud/NeoNetwork-ROA.git" HEAD:master

View file

@ -0,0 +1,2 @@
tabulate==0.8.7
toml==0.10.1

View file

@ -11,6 +11,7 @@ from itertools import combinations
from pathlib import Path
import toml
from tabulate import tabulate
NEO_NETWORK_POOL = [ip_network("10.127.0.0/16"), ip_network("fd10:127::/32")]
@ -238,8 +239,6 @@ def make_roa_records(roa4, roa6):
def make_summary():
from tabulate import tabulate
entities = dict(load_entities())
asn_table = dict(load_asn(entities))
node_table = node_to_asn(set(asn_table.keys()))

View file

@ -1,4 +1,7 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"python.formatting.provider": "black"
}