From ea61a6381104e2f6b2426ced28e77a61b57eef10 Mon Sep 17 00:00:00 2001 From: Chriztoffer Date: Mon, 3 Feb 2020 15:18:07 +0100 Subject: [PATCH] Fix minor typos --- lib/functions.php | 19 +++---------------- update.sh | 7 ++++++- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index b0baa1d..db3f174 100755 --- a/lib/functions.php +++ b/lib/functions.php @@ -20,9 +20,7 @@ function checkoutMaster () */ function startsWith ($haystack, $needle, $length = "0") { - if ($length <= 0 || $length > (strlen ($needle))) - $length = strlen ($needle); - + if ($length <= 0 || $length > (strlen ($needle))) $length = strlen ($needle); return (substr ($haystack, 0, $length) === $needle); } @@ -35,10 +33,7 @@ function startsWith ($haystack, $needle, $length = "0") function endsWith ($haystack, $needle) { $length = strlen ($needle); - - if ($length == 0) - return true; - + if ($length == 0) return true; return (substr( $haystack, -$length) === $needle); } @@ -85,8 +80,7 @@ function writeBirdConfig ($roas) $source = $roa["ta"]; $mntby = $roa["mnt-by"]; - $bird_strng = "$prefix max $maxLength as $asn;"; - $bird_strng .= " # $source/$mntby"; + $bird_strng = "$prefix max $maxLength as $asn; # $source/$mntby"; $bird1_strng = "roa $bird_strng\n"; $bird2_strng = "route $bird_strng\n"; @@ -118,11 +112,8 @@ function writeBirdConfig ($roas) function writeRoutinatorExceptionFile ($roas) { $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK); - $fp = fopen('roa/export_rfc8416_dn42.json', 'w'); - fwrite($fp, $json); - fclose($fp); } @@ -135,13 +126,9 @@ function writeExportJSON ($roas) $roas['roas'][$n]['maxLength'] = (int)preg_replace('/\D/', '', $roas['roas'][$n]['maxLength']); // Ensure unquoted integer $n++; } - $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - $fp = fopen ('roa/export_dn42.json', 'w'); - fwrite ($fp, $json); - fclose ($fp); } diff --git a/update.sh b/update.sh index c4754f1..e724c04 100755 --- a/update.sh +++ b/update.sh @@ -12,6 +12,11 @@ git -C ../registry/ checkout master --quiet git checkout master --quiet git pull origin master:master --quiet --rebase +if ! [ -d roa/ ] ; then mkdir -p roa ; fi +for file in README.md {bird,bird4,bird6}_{route,roa}_dn42.conf export{_rfc8416,}_dn42.json ; do + if ! [ -f roa/$file ] ; then touch roa/$file ; fi +done + # Do the same for sub-repo if exists if [ -d roa/.git/ ] ; then git -C roa/ checkout master --quiet @@ -28,7 +33,7 @@ php rfc8416.php if [ ! -d roa/ ] ; then mkdir roa ; fi if [ ! -f roa/.git/config ] ; then git -C roa/ init - if [ ! -f roa/README.md ; then + if [ ! -f roa/README.md ] ; then touch roa/README.md echo '## roas' | tee roa/README.md ; fi git -C roa/ commit --allow-empty -m "Initial commit"