blob: f04be095e3c368dbc321b80865d66b31c8208d6f [file] [log] [blame]
Patrick Williams064f0392022-12-03 06:29:12 -06001#!/bin/sh
Tom Joseph9a61b4f2016-07-11 06:56:11 -05002
3# Ensure some files have been passed.
Patrick Williams064f0392022-12-03 06:29:12 -06004if [ -z "$*" ]; then
Tom Joseph9a61b4f2016-07-11 06:56:11 -05005 echo "Usage: $0 [whitelist_files+]" >&2
Patrick Williams064f0392022-12-03 06:29:12 -06006 exit 1
Tom Joseph9a61b4f2016-07-11 06:56:11 -05007fi
8
9cat << EOF
Matt Simmering68d9d402023-11-09 14:22:11 -080010#include <ipmiallowlist.hpp>
Tom Joseph9a61b4f2016-07-11 06:56:11 -050011
Konstantin Aladyshevdeeceae2025-01-28 17:22:47 +030012const std::vector<netfncmd_pair> allowlist = {
Tom Joseph9a61b4f2016-07-11 06:56:11 -050013
14EOF
15
16# Output each row of whitelist vector.
17# Concatenate all the passed files.
18# Remove comments and empty lines.
19# Sort the list [numerically].
20# Remove any duplicates.
21# Turn "a:b //<NetFn>:<Command>" -> "{ a, b }, //<NetFn>:<Command>"
Patrick Williams064f0392022-12-03 06:29:12 -060022sed "s/#.*//" "$*" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \
Tom Joseph9a61b4f2016-07-11 06:56:11 -050023 sed "s/\:\(....\)\(.*\)/ , \1 }, \2/"
24
25cat << EOF
26};
27EOF