You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kamailio/utils/kamctl/generate_version_create_mon...

19 lines
539 B

#!/usr/bin/env sh
OUTPUT_FILE="$1"
JSON_DIR="$2"
# Create the version-create.mongo file
echo "use kamailio;" > "$OUTPUT_FILE"
echo "db.createCollection(\"version\");" >> "$OUTPUT_FILE"
for FILE in "$JSON_DIR"/*.json; do
if [ -f "$FILE" ]; then
if [ "$FILE" != "$JSON_DIR/version.json" ]; then
VN=$(grep '"version":' "$FILE" | grep -o -E '[0-9]+')
FN=$(basename "$FILE" .json)
echo "db.getCollection(\"version\").insert({ table_name: \"$FN\", table_version: NumberInt($VN) });" >> "$OUTPUT_FILE"
fi
fi
done