集成ONIE启动模式变更脚本。
This commit is contained in:
@@ -20,6 +20,9 @@ mkdir -p /var/log/journal
|
||||
rm -rf /boot/grub2
|
||||
ln -sf /boot/grub /boot/grub2
|
||||
|
||||
# treat grub2* as grub*
|
||||
ln -sf /usr/bin/grub2-editenv /usr/bin/grub-editenv
|
||||
|
||||
# Setup o/s mount points
|
||||
(cat <<EOF2
|
||||
tmpfs /tmp tmpfs defaults 0 0
|
||||
@@ -29,6 +32,7 @@ sysfs /sys sysfs defaults 0 0
|
||||
proc /proc proc defaults 0 0
|
||||
${1} / ext4 defaults 1 1
|
||||
/dev/sda4 /data ext4 defaults 1 1
|
||||
/dev/sda2 /mnt/onie-boot/ ext4 defaults 1 1
|
||||
overlay /etc overlay x-systemd.requires=/,x-systemd.requires=/data,lowerdir=/etc,upperdir=/data/overlay/rootfs_etc/rw,workdir=/data/overlay/rootfs_etc/work 0 0
|
||||
overlay /var overlay x-systemd.requires=/,x-systemd.requires=/data,lowerdir=/var,upperdir=/data/overlay/rootfs_var/rw,workdir=/data/overlay/rootfs_var/work 0 0
|
||||
EOF2
|
||||
|
||||
@@ -22,6 +22,7 @@ builddir:
|
||||
mkdir -p $(TARGET_BUILD_DIR)
|
||||
|
||||
installer: builddir
|
||||
rm -rf $(TARGET_INSTALLER_DIR)
|
||||
mkdir -p $(TARGET_INSTALLER_DIR)
|
||||
cp $(INSTALLERDIR)/install.sh $(TARGET_INSTALLER_DIR)/install.sh
|
||||
cp $(INSTALLERDIR)/distro-setup.sh $(TARGET_INSTALLER_DIR)/distro-setup.sh
|
||||
|
||||
13
rootconf/sysroot-bin/onie-reboot-embed
Executable file
13
rootconf/sysroot-bin/onie-reboot-embed
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014-2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
. /lib/onie/common-blkdev
|
||||
|
||||
echo "Rebooting into ONIE embed mode..."
|
||||
|
||||
set_onie_next_boot
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o embed
|
||||
reboot
|
||||
14
rootconf/sysroot-bin/onie-reboot-fwpkg
Executable file
14
rootconf/sysroot-bin/onie-reboot-fwpkg
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# This script is just a simple wrapper around 'onie-fwpkg' from the
|
||||
# onie-tools package.
|
||||
|
||||
# "Rebrand" the output of the ONIE tool program to match the name of
|
||||
# this script.
|
||||
|
||||
export ONIE_FWPKG_PROGRAM_NAME=$(basename $(realpath $0))
|
||||
/mnt/onie-boot/onie/tools/bin/onie-fwpkg "$@"
|
||||
13
rootconf/sysroot-bin/onie-reboot-install
Executable file
13
rootconf/sysroot-bin/onie-reboot-install
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014-2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
. /lib/onie/common-blkdev
|
||||
|
||||
echo "Rebooting into ONIE (re)install mode..."
|
||||
|
||||
set_onie_next_boot
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o install
|
||||
reboot
|
||||
13
rootconf/sysroot-bin/onie-reboot-rescue
Executable file
13
rootconf/sysroot-bin/onie-reboot-rescue
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014-2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
. /lib/onie/common-blkdev
|
||||
|
||||
echo "Rebooting into ONIE rescue mode..."
|
||||
|
||||
set_onie_next_boot
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o rescue
|
||||
reboot
|
||||
13
rootconf/sysroot-bin/onie-reboot-uninstall
Executable file
13
rootconf/sysroot-bin/onie-reboot-uninstall
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014-2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
. /lib/onie/common-blkdev
|
||||
|
||||
echo "Rebooting into OS uninstall mode..."
|
||||
|
||||
set_onie_next_boot
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o uninstall
|
||||
reboot
|
||||
13
rootconf/sysroot-bin/onie-reboot-update
Executable file
13
rootconf/sysroot-bin/onie-reboot-update
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014-2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
. /lib/onie/common-blkdev
|
||||
|
||||
echo "Rebooting into ONIE updater mode..."
|
||||
|
||||
set_onie_next_boot
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o update
|
||||
reboot
|
||||
38
rootconf/sysroot-lib/onie/common-blkdev
Normal file
38
rootconf/sysroot-lib/onie/common-blkdev
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- shell-script -*-
|
||||
|
||||
# Copyright (C) 2015 Curt Brune <curt@cumulusnetworks.com>
|
||||
# Copyright (C) 2015-2016 david_yang <david_yang@accton.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# Common block device definitions for the DEMO OS
|
||||
|
||||
demo_mnt="/boot"
|
||||
|
||||
# Configure UEFI / Boot Loader to load ONIE GRUB at the next boot.
|
||||
# This is a one-shot event, reverting to the regular boot after one
|
||||
# iteration.
|
||||
set_onie_next_boot()
|
||||
{
|
||||
if [ ! -d "$demo_mnt/grub" ] ; then
|
||||
# Do nothing if no GRUB installed in demo partition
|
||||
return 0
|
||||
fi
|
||||
if [ -d "/sys/firmware/efi/efivars" ] ; then
|
||||
# For the UEFI case we set the UEFI variable "BootNext" to
|
||||
# select ONIE as the next OS to boot. The "BootNext" variable
|
||||
# is only used once by the firmware, after which the permanent
|
||||
# "BootOrder" variable is used.
|
||||
local boot_num=$(efibootmgr | grep "ONIE:" | awk '{ print $1 }')
|
||||
boot_num=${boot_num#Boot}
|
||||
# Remove trailing '*'
|
||||
boot_num=${boot_num%\*}
|
||||
if [ -n "$boot_num" ] ; then
|
||||
efibootmgr --quiet --bootnext $boot_num && return
|
||||
echo "ERROR: Problems setting UEFI BootNext variable"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fall back to using GRUB chainload method
|
||||
grub-reboot --boot-directory="$demo_mnt" ONIE
|
||||
}
|
||||
@@ -15,7 +15,8 @@ set -ex
|
||||
|
||||
package_to_install="@base @core @debugging @directory-client @guest-agents
|
||||
@hardware-monitoring @network-file-system-client @performance @remote-system-management
|
||||
grub2 epel-release ansible yum-utils ipmitool docker-ce docker-ce-cli containerd.io"
|
||||
grub2 epel-release efibootmgr ansible yum-utils ipmitool docker-ce docker-ce-cli containerd.io"
|
||||
|
||||
locak_package_to_install="$projectdir/package/kernel-lt-$kernel_version.rpm
|
||||
$projectdir/package/kernel-lt-devel-$kernel_version.rpm"
|
||||
|
||||
@@ -55,6 +56,10 @@ cp -a /dev/zero $target/dev/
|
||||
cp -a /dev/urandom $target/dev/
|
||||
cp -a /dev/random $target/dev/
|
||||
|
||||
# install ONIE helpers
|
||||
cp -rf $projectdir/rootconf/sysroot-bin/* $target/bin/
|
||||
cp -rf $projectdir/rootconf/sysroot-lib/* $target/lib/
|
||||
|
||||
# ansible-playbook -i tsg-9140-scripts/install_config/tsg_9140_host tsg-9140-scripts/tsg_9140_deploy.yml
|
||||
yum -c "$yum_config" --installroot="$target" -y --setopt=$setopt clean all
|
||||
|
||||
|
||||
Reference in New Issue
Block a user