#!/bin/bash
set -ev

# generate filters and configs
./peering_filters all

if [ "$(python -c "import yaml,sys;a = yaml.safe_load(sys.stdin); print a['rpki']['validation'];" < vars/generic.yml)" == "True" ]; then
    rtrsub --afi ipv4 < ./templates/bird-rpki.j2 > /opt/routefilters/rpki/rpki-ipv4.conf
    rtrsub --afi ipv6 < ./templates/bird-rpki.j2 > /opt/routefilters/rpki/rpki-ipv6.conf

    ./gentool -4 -y vars/generic.yml -t templates/rpkiwhitelist.j2 -o /opt/routefilters/rpki/rpkiwhitelist-ipv4.conf
    ./gentool -6 -y vars/generic.yml -t templates/rpkiwhitelist.j2 -o /opt/routefilters/rpki/rpkiwhitelist-ipv6.conf
else
    rm -f /opt/routefilters/rpki/rpki-ipv4.conf
    rm -f /opt/routefilters/rpki/rpki-ipv6.conf
fi

#!/bin/bash
set -ev

# generate filters and configs
./peering_filters all

if [ "$(python -c "import yaml,sys;a = yaml.safe_load(sys.stdin); print a['rpki']['validation'];" < vars/generic.yml)" == "True" ]; then
    if [ ! -d /opt/routefilters/rpki ] ; then
        mkdir /opt/routefilters/rpki
    fi
    
    rtrsub --afi ipv4 < ./templates/bird-rpki.j2 > /opt/routefilters/rpki/rpki-ipv4.conf
    rtrsub --afi ipv6 < ./templates/bird-rpki.j2 > /opt/routefilters/rpki/rpki-ipv6.conf

    ./gentool -4 -y vars/generic.yml -t templates/rpkiwhitelist.j2 -o /opt/routefilters/rpki/rpkiwhitelist-ipv4.conf
    ./gentool -6 -y vars/generic.yml -t templates/rpkiwhitelist.j2 -o /opt/routefilters/rpki/rpkiwhitelist-ipv6.conf
else
    rm -f /opt/routefilters/rpki/rpki-ipv4.conf
    rm -f /opt/routefilters/rpki/rpki-ipv6.conf
fi

Add a check to create the rpki output dir
Add a check to create the rpki output dir

The 'rpki' output dir wasn't created if it doesn't exist, causing the job to fail if it doesn't exist. This is fixed now.