1
0
mirror of https://github.com/jerikan-network/cmdb.git synced 2024-05-06 04:54:50 +00:00
Files
Vincent Bernat d191613ab8 Initial release
No history. If you have the original history, you can use:

```
git replace THISCOMMIT b0b998bd1c651e308ac71a9158e07e5c3521a281
```
2021-05-15 16:18:03 +02:00

32 lines
775 B
Bash
Executable File

#!/bin/sh
# Check syntax of device using junoser and transform it to the "set" syntax.
url=${JUNOSER_URL:-127.0.0.1:4567}
out=output/"$1"/config-set.txt
status=$(sed -e 's/^ *protect://' -e 's/^ *replace://' -e 's/^ *apply-flags omit;//' output/"$1"/config.txt \
| curl -sS \
-H Expect: --data-binary @- \
-w "%{http_code}" \
-o $out \
$url/format)
! grep -E '^set policy-options policy-statement [^ ]+ from' $out || {
>&2 echo "Policy statement with a 'from' outside a term"
exit 1
}
case $status in
200)
sort -o $out $out
exit 0
;;
422)
>&2 cat $out
exit 1
;;
*)
rm $out
exit 11
;;
esac