<commit_before>#!/bin/bash

CERANA_BOOTCFG=/tmp/cerana-bootcfg
CERANA_PREFIX="cerana"
CMDLINE=$(cat /proc/cmdline)

# Parse the kernel boot arguments and look for our arguments and
# pick out their values.
function parse_boot_args() {
    >$CERANA_BOOTCFG

    [[ ${CMDLINE} =~ ${CERANA_PREFIX} ]] || return

    for kopt in $CMDLINE; do
        IFS='=' read -r k v <<<"$kopt"
        case $k in
            $CERANA_PREFIX.zfs_config)
                echo "CERANA_ZFS_CONFIG=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.cluster_ips)
                echo "CERANA_CLUSTER_IPS=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.cluster_bootstrap)
                # No argument expected. If present, just set to 1.
                echo "CERANA_CLUSTER_BOOTSTRAP=1" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.rescue)
                # No argument expected. If present, just set to 1.
                echo "CERANA_RESCUE=1" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_mac)
                echo "CERANA_MGMT_MAC=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_ip)
                echo "CERANA_MGMT_IP=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_gw)
                echo "CERANA_MGMT_GW=$v" >>$CERANA_BOOTCFG
                ;;
        esac
    done
}

#if manually invoked with argument "test" do a quick sanity check to stdout
if [[ "test" == "$1" ]]; then
    CERANA_BOOTCFG=/dev/stdout
    CMDLINE="cerana.zfs_config=auto cerana.cluster_ips=10.2.3.4,10.2.3.5 cerana.cluster_bootstrap cerana.rescue cerana.mgmt_mac=00:00:00:00 cerana.mgmt_ip=10.2.3.6/24 cerana.mgmt_gw=10.2.3.1"
fi

parse_boot_args<commit_msg>parse bootserver kernel command line arguments for platform download<commit_after>#!/bin/bash

CERANA_BOOTCFG=/tmp/cerana-bootcfg
CERANA_PREFIX="cerana"
CMDLINE=$(cat /proc/cmdline)

# Parse the kernel boot arguments and look for our arguments and
# pick out their values.
function parse_boot_args() {
    >$CERANA_BOOTCFG

    [[ ${CMDLINE} =~ ${CERANA_PREFIX} ]] || return

    for kopt in $CMDLINE; do
        IFS='=' read -r k v <<<"$kopt"
        case $k in
            $CERANA_PREFIX.zfs_config)
                echo "CERANA_ZFS_CONFIG=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.cluster_ips)
                echo "CERANA_CLUSTER_IPS=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.cluster_bootstrap)
                # No argument expected. If present, just set to 1.
                echo "CERANA_CLUSTER_BOOTSTRAP=1" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.rescue)
                # No argument expected. If present, just set to 1.
                echo "CERANA_RESCUE=1" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_mac)
                echo "CERANA_MGMT_MAC=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_ip)
                echo "CERANA_MGMT_IP=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.mgmt_gw)
                echo "CERANA_MGMT_GW=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.initrd_hash)
                echo "CERANA_INITRD_HASH=$v" >>$CERANA_BOOTCFG
                ;;
            $CERANA_PREFIX.boot_server)
                echo "CERANA_BOOT_SERVER=$v" >>$CERANA_BOOTCFG
                ;;
        esac
    done
}

#if manually invoked with argument "test" do a quick sanity check to stdout
if [[ "test" == "$1" ]]; then
    CERANA_BOOTCFG=/dev/stdout
    CMDLINE="cerana.zfs_config=auto cerana.cluster_ips=172.16.10.4,172.16.10.5 cerana.cluster_bootstrap cerana.rescue cerana.mgmt_mac=00:00:00:00 cerana.mgmt_ip=172.16.10.6/24 cerana.mgmt_gw=172.16.10.1 cerana.initrd_hash=sha256-748c35c5de02f473339867aa5fae1ab8d7893be3798041d03fade7c67896541b cerana.boot_server=http://172.16.10.4/"
fi

parse_boot_args
{'fraction_non_alphanumeric': 0.10938692444670567, 'fraction_numerical': 0.03434240651233783, 'mean_word_length': 2.1206349206349207, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '493043', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1408, 'n_words': 247}