Skip to content

Commit

Permalink
machine.conf: generated automatically during ONIE booting
Browse files Browse the repository at this point in the history
In commit 3cbcb9e, it introduced a new machanism to identify machines
with common CPU module.  The machine.conf was changed to source
other configuration files to calculate the real `onie_machine` and
`onie_platform` at ONIE runtime.

Some NOSes such as SONiC would copy machine.conf to its partition and use
it at its runtime.  The new machine.conf needs other files and has to be
put in /etc directory or it cannot be sourced correctly.

Besides SONiC other NOSes also have similar issues.

The patch intends to expand all variables from machine-build.conf and
machine-live.conf to machine.conf directly.  That would be like the
previous one:

    ONIE:/ # cat /etc/machine.conf
    # /etc/machine.conf for onie

    #  Copyright (C) 2017 Curt Brune <curt@cumulusnetworks.com>
    #  Copyright (C) 2017 david_yang <david_yang@accton.com>
    #
    #  SPDX-License-Identifier:     GPL-2.0

    onie_version=2017.12.12.20-dirty
    onie_vendor_id=259
    onie_build_machine=accton_as7712_32x
    onie_machine_rev=0
    onie_arch=x86_64
    onie_build_platform=x86_64-accton_as7712_32x-r0
    onie_config_version=1
    onie_build_date="2017-12-20T13:43+0800"
    onie_partition_type=gpt
    onie_kernel_version=4.1.38
    onie_firmware=auto
    onie_switch_asic=bcm
    onie_skip_ethmgmt_macs=no
    onie_grub_image_name=grubx64.efi
    onie_machine=accton_as7712_32x
    onie_platform="x86_64-accton_as7712_32x-r0"
    ONIE:/ #

This patch has been tested on Accton AS7712_32X with SONiC environment.

Signed-off-by: Curt Brune <curt@cumulusnetworks.com>
  • Loading branch information
david56 authored and Curt Brune committed Dec 22, 2017
1 parent 3515f3c commit fe5b096
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
37 changes: 36 additions & 1 deletion rootconf/default/etc/init.d/gen-config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

# Copyright (C) 2017 Curt Brune <curt@cumulusnetworks.com>
# Copyright (C) 2017 david_yang <david_yang@accton.com>
#
# SPDX-License-Identifier: GPL-2.0

Expand All @@ -17,9 +18,43 @@ gen_live_config()

[ -r /lib/onie/gen-config-platform ] && . /lib/onie/gen-config-platform

gen_machine_config()
{
local build_conf=/etc/machine-build.conf
local live_conf=/etc/machine-live.conf
local machine_conf=/etc/machine.conf

gen_live_config > $live_conf

cat <<EOF > $machine_conf
# /etc/machine.conf for onie
# Copyright (C) 2017 Curt Brune <curt@cumulusnetworks.com>
# Copyright (C) 2017 david_yang <david_yang@accton.com>
#
# SPDX-License-Identifier: GPL-2.0
EOF

cat $build_conf $live_conf >> $machine_conf
sed -i -e '/onie_machine=/d' $machine_conf
sed -i -e '/onie_platform=/d' $machine_conf

# Use onie_machine if set, otherwise use build_machine
. $build_conf
. $live_conf
local onie_machine=${onie_machine:-$onie_build_machine}
local onie_platform="${onie_arch}-${onie_machine}-r${onie_machine_rev}"
cat <<EOF >> $machine_conf
onie_machine=$onie_machine
onie_platform="$onie_platform"
EOF

}

case $cmd in
start)
gen_live_config > /etc/machine-live.conf
gen_machine_config
;;
*)

Expand Down
16 changes: 0 additions & 16 deletions rootconf/default/etc/machine.conf

This file was deleted.

0 comments on commit fe5b096

Please sign in to comment.