KubeOS/0022-KubeOS-delete-scripts-except-admin-container.patch
Yuhang Wei 1d36b74685 KubeOS:sync code from source master branch
Signed-off-by: Yuhang Wei <weiyuhang3@huawei.com>
2024-02-26 09:54:27 +08:00

1672 lines
49 KiB
Diff

From aaf7a75f0feacafcfcccd8c3812b1654694c26c0 Mon Sep 17 00:00:00 2001
From: Yuhang Wei <weiyuhang3@huawei.com>
Date: Mon, 28 Aug 2023 18:01:42 +0800
Subject: [PATCH 5/5] KubeOS: delete scripts except admin container
Signed-off-by: Yuhang Wei <weiyuhang3@huawei.com>
---
scripts/00bootup/Global.cfg | 16 --
scripts/00bootup/module-setup.sh | 28 --
scripts/00bootup/mount.sh | 341 ------------------------
scripts/Dockerfile | 3 -
scripts/admin-container/Dockerfile | 28 --
scripts/bootloader.sh | 42 ---
scripts/common/globalVariables.sh | 22 --
scripts/common/log.sh | 20 --
scripts/common/utils.sh | 191 --------------
scripts/create/imageCreate.sh | 122 ---------
scripts/create/rootfsCreate.sh | 105 --------
scripts/grub.cfg | 173 -------------
scripts/kbimg.sh | 402 -----------------------------
scripts/rpmlist | 22 --
scripts/set_in_chroot.sh | 20 --
15 files changed, 1535 deletions(-)
delete mode 100644 scripts/00bootup/Global.cfg
delete mode 100644 scripts/00bootup/module-setup.sh
delete mode 100644 scripts/00bootup/mount.sh
delete mode 100644 scripts/Dockerfile
delete mode 100644 scripts/admin-container/Dockerfile
delete mode 100644 scripts/bootloader.sh
delete mode 100644 scripts/common/globalVariables.sh
delete mode 100644 scripts/common/log.sh
delete mode 100644 scripts/common/utils.sh
delete mode 100644 scripts/create/imageCreate.sh
delete mode 100644 scripts/create/rootfsCreate.sh
delete mode 100644 scripts/grub.cfg
delete mode 100644 scripts/kbimg.sh
delete mode 100644 scripts/rpmlist
delete mode 100644 scripts/set_in_chroot.sh
diff --git a/scripts/00bootup/Global.cfg b/scripts/00bootup/Global.cfg
deleted file mode 100644
index dd78617..0000000
--- a/scripts/00bootup/Global.cfg
+++ /dev/null
@@ -1,16 +0,0 @@
-# rootfs file name
-rootfs_name=kubeos.tar
-
-# select the target disk to install kubeOS
-disk=/dev/sda
-
-# pxe server ip address where stores the rootfs on the http server
-server_ip=192.168.1.50
-# target machine ip
-local_ip=192.168.1.100
-# target machine route
-route_ip=192.168.1.1
-# target machine netmask
-netmask=255.255.255.0
-# target machine netDevice name
-net_name=eth0
diff --git a/scripts/00bootup/module-setup.sh b/scripts/00bootup/module-setup.sh
deleted file mode 100644
index 5460b2b..0000000
--- a/scripts/00bootup/module-setup.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-check() {
- return 0
-}
-
-depends() {
- echo systemd
-}
-
-install() {
- inst_multiple -o grub2-mkimage mkfs.ext4 mkfs.vfat lsblk tar cpio gunzip lspci parted dhclient ifconfig curl hwinfo head tee arch df awk route
- inst_hook mount 00 "$moddir/mount.sh"
- inst_simple "$moddir/mount.sh" "/mount.sh"
- inst_simple "$moddir/Global.cfg" "/Global.cfg"
-}
-
-installkernel() {
- hostonly='' \
- instmods \
- =drivers/ata \
- =drivers/nvme \
- =drivers/scsi \
- =drivers/net \
- =fs/fat \
- =fs/nls
-}
-
diff --git a/scripts/00bootup/mount.sh b/scripts/00bootup/mount.sh
deleted file mode 100644
index 7f00fd6..0000000
--- a/scripts/00bootup/mount.sh
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/bin/bash
-arch=$(arch)
-min_size=8
-log=/install.log
-
-source /Global.cfg
-
-function CheckSpace() {
- local disk_ava="$(parted -l | grep ${disk} | awk '{print $3}')"
- if echo "${disk_ava}" | grep [GT]B$; then
- if echo "${disk_ava}" | grep GB$; then
- disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
- if [ "${disk_ava}" -lt ${min_size} ]; then
- echo "The available disk space is not enough, at least ${min_size}GB." | tee -a ${log}
- return 1
- fi
- fi
- else
- echo "The available disk space is not enough, at least ${min_size}G." | tee -a ${log}
- return 1
- fi
-
- return 0
-}
-
-function mount_proc_dev_sys() {
- local tmp_root=$1
- mount -t proc none "${tmp_root}/proc"
- mount --bind /dev "${tmp_root}/dev"
- mount --bind /dev/pts "${tmp_root}/dev/pts"
- mount -t sysfs none "${tmp_root}/sys"
-}
-
-function GetDisk() {
- disks=(`hwinfo --disk --short 2>&1 | grep -vi "^disk" | awk '{print $1}'`)
- if [ ${#disks[*]} -gt 0 ]; then
- if [ -n "${disk}" ] && echo "${disks[@]}" | grep -wq "${disk}" ; then
- echo "${disk} exists, start partition" | tee -a ${log}
- else
- echo "disk not exist, please choose correct disk" | tee -a ${log}
- fi
- else
- echo "no disk found" | tee -a ${log}
- return 1
- fi
- CheckSpace
- if [ $? -ne 0 ]; then
- echo "no enough space on ${disk}" | tee -a ${log}
- return 1
- fi
-
- return 0
-}
-
-function PartitionAndFormatting() {
- echo "Partitioning and formatting disk $disk..."
- # partition and format
- parted ${disk} -s mklabel gpt >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- parted ${disk} -s mkpart primary fat16 1M 100M >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- parted ${disk} -s mkpart primary ext4 100M 2600M >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- parted ${disk} -s mkpart primary ext4 2600M 5100M >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- parted ${disk} -s mkpart primary ext4 5100M 100% >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- parted ${disk} -s set 1 boot on >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "partition failed" | tee -a ${log}
- return 1
- fi
-
- mkfs.vfat -n "BOOT" ${disk}1 >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "format failed" | tee -a ${log}
- return 1
- fi
-
- mkfs.ext4 -L "ROOT-A" ${disk}2 >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "format failed" | tee -a ${log}
- return 1
- fi
-
- mkfs.ext4 -L "ROOT-B" ${disk}3 >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "format failed" | tee -a ${log}
- return 1
- fi
-
- mkfs.ext4 -L "PERSIST" ${disk}4 >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "format failed" | tee -a ${log}
- return 1
- fi
-
- return 0
-}
-
-function InitNetwork() {
- echo "Initializing network..."
- netNames=(`ifconfig -a | awk '{print $1}' | grep : | grep '^e' | awk -F: '{print $1}'`)
- if [ ${#netNames[*]} -gt 0 ]; then
- if [ -n "${net_name}" ] && echo "${netNames[@]}" | grep -wq "${net_name}" ; then
- echo "${net_name} exists, start set ip" | tee -a ${log}
- else
- echo "net_name not exist, choose default net" | tee -a ${log}
- net_name=${netNames[0]}
- fi
- else
- echo "no net Device found" | tee -a ${log}
- return 1
- fi
-
- ifconfig ${net_name} up
- if [ $? -ne 0 ]; then
- echo "load net card failed" | tee -a ${log}
- return 1
- fi
- sleep 3
-
- ifconfig ${net_name} ${local_ip} netmask ${netmask} >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "ip set failed" | tee -a ${log}
- return 1
- fi
- sleep 3
-
- route add default gw ${route_ip} >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "add route failed" | tee -a ${log}
- return 1
- fi
- sleep 3
- return 0
-}
-
-function MountRoot() {
- echo "Mounting rootfs..."
- # mount rootfs
- mount ${disk}2 /sysroot >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "mount rootfs failed" | tee -a ${log}
- return 1
- fi
-
- return 0
-}
-
-function MountPersist() {
- echo "Mounting persist"
- mount ${disk}4 /sysroot/persist >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "mount persist failed" | tee -a ${log}
- return 1
- fi
- mkdir /sysroot/persist/{var,etc,etcwork}
- mkdir -p /sysroot/persist/etc/KubeOS/certs
- return 0
-}
-
-function MountBoot() {
- echo "Mounting boot"
- mkdir -p /sysroot/boot/efi
- mount ${disk}1 /sysroot/boot/efi >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "mount boot failed" | tee -a ${log}
- return 1
- fi
- return 0
-}
-
-function GetRootfs() {
- echo "Downloading rootfs..."
-
- curl -o /${rootfs_name} http://${server_ip}/${rootfs_name}
- if [ ! -e "/${rootfs_name}" ]; then
- echo "download rootfs failed" | tee -a ${log}
- return 1
- fi
-
- tar -xf /${rootfs_name} -C /sysroot
- if [ $? -ne 0 ]; then
- echo "decompose rootfs failed" | tee -a ${log}
- return 1
- fi
-
- rm -rf /${rootfs_name}
- mount -o remount,ro ${disk}2 /sysroot >> ${log} 2>&1
- return 0
-}
-
-function Inst_Grub2_x86() {
- # copy the files that boot need
- cp -r /sysroot/usr/lib/grub/x86_64-efi /sysroot/boot/efi/EFI/openEuler
- eval "grub2-mkimage -d /sysroot/usr/lib/grub/x86_64-efi -O x86_64-efi --output=/sysroot/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux" >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "grub2-mkimage on x86 failed" | tee -a ${log}
- return 1
- fi
-
- mkdir -p /sysroot/boot/efi/EFI/BOOT/
- cp -f /sysroot/boot/efi/EFI/openEuler/grubx64.efi /sysroot/boot/efi/EFI/BOOT/BOOTX64.EFI
-
- return 0
-}
-
-function Inst_Grub2_aarch64() {
- cp -r /sysroot/usr/lib/grub/arm64-efi /sysroot/boot/efi/EFI/openEuler/
- eval "grub2-mkimage -d /sysroot/usr/lib/grub/arm64-efi -O arm64-efi --output=/sysroot/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux" >> ${log} 2>&1
- if [ $? -ne 0 ]; then
- echo "grub2-mkimage on aarch64 failed" | tee -a ${log}
- return 1
- fi
-
- mkdir -p /sysroot/boot/efi/EFI/BOOT/
- cp -f /sysroot/boot/efi/EFI/openEuler/grubaa64.efi /sysroot/boot/efi/EFI/BOOT/BOOTAA64.EFI
-
- return 0
-}
-
-function SetBoot() {
- # mount boot
- echo "Setting boot"
-
- if [ $arch == "x86_64" ]; then
- Inst_Grub2_x86
- if [ $? -ne 0 ]; then
- echo "install grub on x86 failed" | tee -a ${log}
- return 1
- fi
- fi
-
- if [ $arch == "aarch64" ]; then
- Inst_Grub2_aarch64
- if [ $? -ne 0 ]; then
- echo "install grub on aarch64 failed" | tee -a ${log}
- return 1
- fi
- fi
- sed -i 's#/dev/sda#'${disk}'#g' /sysroot/boot/efi/EFI/openEuler/grub.cfg
-
- return 0
-}
-
-function Bootup_Main() {
- # get disk
- echo "Checking disk info..." | tee -a ${log}
- GetDisk
- if [ $? -ne 0 ]; then
- echo "Checking disk info failed" | tee -a ${log}
- return 1
- fi
-
- # partition and format disk
- echo "Partion and formatting..." | tee -a ${log}
- PartitionAndFormatting
- if [ $? -ne 0 ]; then
- echo "Partition and formatting disk failed" | tee -a ${log}
- return 1
- fi
-
- # init network
- echo "Initializing network..." | tee -a ${log}
- InitNetwork
- if [ $? -ne 0 ]; then
- echo "Initializing network failed" | tee -a ${log}
- return 1
- fi
-
- # mount partitions
-
- # mount boot
- echo "Mounting root..." | tee -a ${log}
- MountRoot
- if [ $? -ne 0 ]; then
- echo "Mounting root failed" | tee -a ${log}
- return 1
- fi
-
- echo "Mounting boot..." | tee -a ${log}
- MountBoot
- if [ $? -ne 0 ]; then
- echo "Mounting boot failed" | tee -a ${log}
- return 1
- fi
-
- # download rootfs
- echo "Downloading rootfs..." | tee -a ${log}
- GetRootfs
- if [ $? -ne 0 ]; then
- echo "Downloading rootfs failed" | tee -a ${log}
- return 1
- fi
- mount_proc_dev_sys /sysroot
- # set boot
- echo "Setting boot..." | tee -a ${log}
- SetBoot
- if [ $? -ne 0 ]; then
- echo "Setting boot failed" | tee -a ${log}
- return 1
- fi
- # mount persist
- echo "Mounting persist..." | tee -a ${log}
- MountPersist
- if [ $? -ne 0 ]; then
- echo "Mounting persist failed" | tee -a ${log}
- return 1
- fi
- return 0
-}
-
-Bootup_Main
-ret=$?
-if [ ${ret} -eq 0 ]; then
- echo "kubeOS install success! switch to root" | tee -a ${log}
- cp ${log} /sysroot/persist
-else
- echo "kubeOS install failed, see install.log" | tee -a ${log}
-fi
diff --git a/scripts/Dockerfile b/scripts/Dockerfile
deleted file mode 100644
index 3da4708..0000000
--- a/scripts/Dockerfile
+++ /dev/null
@@ -1,3 +0,0 @@
-FROM scratch
-COPY os.tar /
-CMD ["/bin/sh"]
diff --git a/scripts/admin-container/Dockerfile b/scripts/admin-container/Dockerfile
deleted file mode 100644
index d4ddd06..0000000
--- a/scripts/admin-container/Dockerfile
+++ /dev/null
@@ -1,28 +0,0 @@
-## Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-FROM openeuler-22.03-lts
-MAINTAINER <shenyangyang4@huawei.com>
-
-RUN yum -y install openssh-clients util-linux
-
-
-ADD ./sysmaster-0.2.3-1.oe2203.aarch64.rpm /home
-RUN rpm -ivh /home/sysmaster-0.2.3-1.oe2203.aarch64.rpm
-
-COPY ./hostshell /usr/bin/
-COPY ./set-ssh-pub-key.sh /usr/local/bin
-COPY ./set-ssh-pub-key.service /usr/lib/sysmaster
-
-EXPOSE 22
-# set sshd.service and set-ssh-pub-key.service pulled up by default
-RUN sed -i 's/sysinit.target/sysinit.target;sshd.service;set-ssh-pub-key.service/g' /usr/lib/sysmaster/basic.target
-
-CMD ["/usr/lib/sysmaster/init"]
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
deleted file mode 100644
index 75096a3..0000000
--- a/scripts/bootloader.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-set -eu
-set -o pipefail
-set -x
-ARCH=`arch`
-
-function install_grub2_x86 ()
-{
- if [ "$BOOT_MODE" = "legacy" ]; then
- # make boot.img/core.img and setup, to support legacy boot mode
- GRUBNAME=$(which grub2-install)
- echo "Installing GRUB2..."
- GRUB_OPTS=${GRUB_OPTS:-"--force"}
- GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
-
- $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $DEVICE
- else
- # make efi file, and save in FAT16 partition, to support UEFI boot mode
- cp -r /usr/lib/grub/x86_64-efi boot/efi/EFI/openEuler
- eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux"
-
- mkdir -p /boot/EFI/BOOT/
- cp -f /boot/efi/EFI/openEuler/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
- fi
-}
-
-function install_grub2_efi ()
-{
- cp -r /usr/lib/grub/arm64-efi /boot/efi/EFI/openEuler/
- eval "grub2-mkimage -d /usr/lib/grub/arm64-efi -O arm64-efi --output=/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,gpt1)/EFI/openEuler' fat part_gpt part_msdos linux"
-
- mkdir -p /boot/EFI/BOOT/
- cp -f /boot/efi/EFI/openEuler/grubaa64.efi /boot/efi/EFI/BOOT/BOOTAA64.EFI
-}
-
-if [ $ARCH == "x86_64" ]; then
- install_grub2_x86
-fi
-
-if [ $ARCH == "aarch64" ]; then
- install_grub2_efi
-fi
diff --git a/scripts/common/globalVariables.sh b/scripts/common/globalVariables.sh
deleted file mode 100644
index 95af9c8..0000000
--- a/scripts/common/globalVariables.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-IMG_SIZE=20
-PWD="$(pwd)"
-TMP_MOUNT_PATH="${PWD}/mnt"
-RPM_ROOT="${PWD}/rootfs"
-ARCH=$(arch)
-
-export IMG_SIZE
-export PWD
-export TMP_MOUNT_PATH
-export RPM_ROOT
-export ARCH
diff --git a/scripts/common/log.sh b/scripts/common/log.sh
deleted file mode 100644
index 4d3ed2b..0000000
--- a/scripts/common/log.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-function log_error_print(){
- local logmsg="[ ERROR ] - ""`date "+%b %d %Y %H:%M:%S"`"" $1"
- echo $logmsg
-}
-
-function log_info_print(){
- local logmsg="[ INFO ] - ""`date "+%b %d %Y %H:%M:%S"`"" $1"
- echo $logmsg
-}
diff --git a/scripts/common/utils.sh b/scripts/common/utils.sh
deleted file mode 100644
index ec244b7..0000000
--- a/scripts/common/utils.sh
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
-
-function mount_proc_dev_sys() {
- local tmp_root=$1
- mount -t proc none "${tmp_root}/proc"
- mount --bind /dev "${tmp_root}/dev"
- mount --bind /dev/pts "${tmp_root}/dev/pts"
- mount -t sysfs none "${tmp_root}/sys"
-}
-
-function unmount_dir() {
- local dir=$1
-
- if [ -L "${dir}" ] || [ -f "${dir}" ]; then
- log_error_print "${dir} is not a directory, please check it."
- return 1
- fi
-
- if [ ! -d "${dir}" ]; then
- return 0
- fi
-
- local real_dir=$(readlink -e "${dir}")
- local mnts=$(awk '{print $2}' < /proc/mounts | grep "^${real_dir}" | sort -r)
- for m in ${mnts}; do
- log_info_print "Unmount ${m}"
- umount -f "${m}" || true
- done
-
- return 0
-}
-
-function init_part() {
- local offset=$(fdisk -l system.img | grep $1 | awk '{print $2}')
- local sizelimit=$(fdisk -l system.img | grep $1 | awk '{print $3}')
- sizelimit=$(echo "($sizelimit - $offset)*512" | bc)
- offset=$(echo "${offset}*512" | bc)
- local loop=$(losetup -f)
- losetup -o "${offset}" --sizelimit "${sizelimit}" "${loop}" system.img
- if [ $2 == "BOOT" ];then
- mkfs.vfat -n "$2" "${loop}"
- mount -t vfat "${loop}" "$3"
- else
- mkfs.ext4 -L "$2" "${loop}"
- mount -t ext4 "${loop}" "$3"
- rm -rf "$3/lost+found"
- fi
-}
-
-function delete_dir() {
- local ret=0
- local dir="$1"
- unmount_dir "${dir}"
- ret=$?
- if [ "${ret}" -eq 0 ]; then
- rm -rf "${dir}"
- return 0
- else
- log_error_print "${dir} is failed to unmount , can not delete $dir."
- return 1
- fi
-}
-
-function delete_file() {
- local file="$1"
- if [ ! -e "${file}" ]; then
- return 0
- fi
-
- if [ ! -f "${file}" ]; then
- log_error_print "${file} is not a file."
- return 1
- fi
-
- rm -f "${file}"
- return 0
-}
-
-function check_file_valid() {
- local file="$1"
- local mesg="$2"
- if [ ! -e "${file}" ]; then
- log_error_print "${mesg} is not exist."
- exit 3
- fi
- if [ ! -f "${file}" ];then
- log_error_print "${mesg} is not a file."
- exit 3
- fi
-}
-
-function check_conf_valid() {
- local conf_path="${PWD}/00bootup/Global.cfg"
- check_file_valid ${conf_path} "Globab.cfg"
- if [ $# != 7 ];then
- log_error_print "configure configured in Global.cfg is empty."
- exit 3
- fi
- for addr in ${server_ip} ${local_ip} ${route_ip} ${netmask}; do
- check_ip_valid $addr
- done
-}
-
-function check_ip_valid() {
- local ipaddr="$1";
- if [[ ! $ipaddr =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] ; then
- log_error_print "ip address configured in Global.cfg is not valid."
- exit 3;
- fi
- for quad in $(echo "${ipaddr//./ }"); do
- if [ $quad -ge 0 ] && [ $quad -le 255 ];then
- continue
- fi
- log_error_print "ip address configured in Global.cfg is not valid."
- exit 3;
- done
-
-}
-
-function check_binary_exist() {
- check_file_valid "$1" "os-agent binary"
-}
-
-function check_repo_path() {
- check_file_valid $1 "REPO file"
- if [ -d "${RPM_ROOT}" ]; then
- log_error_print "there is a rootfs folder. please confirm if rootfs is being used, if not, please remove ${RPM_ROOT} first."
- exit 5
- fi
-}
-
-function check_disk_space() {
- local disk_ava="$(df ${PWD} | awk 'NR==2{print}' | awk '{print $4}')"
- case $1 in
- docker)
- local maxsize=$((6*1024*1024))
- if [ "${disk_ava}" -lt "${maxsize}" ]; then
- log_error_print "The available disk space is not enough, at least 6GiB."
- exit 6
- fi
- ;;
- vm)
- local maxsize=$((25*1024*1024))
- if [ "${disk_ava}" -lt "${maxsize}" ]; then
- log_error_print "The available disk space is not enough, at least 25GiB."
- exit 6
- fi
- ;;
- pxe)
- local maxsize=$((5*1024*1024))
- if [ "${disk_ava}" -lt "${maxsize}" ]; then
- log_error_print "The available disk space is not enough, at least 5GiB."
- exit 6
- fi
- ;;
- esac
-}
-
-function check_param() {
- set +eE
- local arg=$1
- echo "${arg}" | grep -v -E -q ${CHECK_REGEX}
- filterParam=$(echo "${arg}" | grep -v -E ${CHECK_REGEX})
- if [[ "${filterParam}" != "${arg}" ]]; then
- log_error_print "params ${arg} is invalid, please check it."
- exit 3
- fi
- set -eE
-}
-
-function check_docker_exist() {
- if [[ "$(docker images -q $1 2> /dev/null)" == "" ]]; then
- log_error_print "docker is not exist please pull $1 first "
- exit 9
- fi
-}
-
-function check_docker_file() {
- check_file_valid $1 "admin-container Dockerfile"
-}
\ No newline at end of file
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
deleted file mode 100644
index 4d02f9d..0000000
--- a/scripts/create/imageCreate.sh
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-TMP_MOUNT_PATH="${PWD}/mnt"
-RPM_ROOT="${PWD}/rootfs"
-IMG_SIZE=20
-PWD="$(pwd)"
-function create_img() {
- local BOOT_MODE=$1
- rm -f system.img update.img
- qemu-img create system.img ${IMG_SIZE}G
- if [ "$BOOT_MODE" = "legacy" ]; then
- local BOOT_PATH=${TMP_MOUNT_PATH}/boot/grub2
- parted system.img -s mklabel msdos
- parted system.img -s mkpart primary ext4 1MiB 60MiB
- else
- local BOOT_PATH=${TMP_MOUNT_PATH}/boot/efi
- parted system.img -s mklabel gpt
- parted system.img -s mkpart primary fat32 1MiB 60MiB
- fi
- parted system.img -s mkpart primary ext4 60MiB 2160MiB
- parted system.img -s mkpart primary ext4 2160MiB 4260MiB
- parted system.img -s mkpart primary ext4 4260MiB 100%
- local device=$(losetup -f)
- losetup "${device}" system.img
-
- mkdir -p "${TMP_MOUNT_PATH}"
-
- init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
-
- mkdir -p ${BOOT_PATH}
- chmod 755 ${BOOT_PATH}
- if [ "$BOOT_MODE" = "legacy" ]; then
- init_part system.img1 GRUB2 "${BOOT_PATH}"
- else
- init_part system.img1 BOOT "${BOOT_PATH}"
- fi
- tar -x -C ${TMP_MOUNT_PATH} -f os.tar
- if [ "$BOOT_MODE" = "legacy" ]; then
- sed -i "s/insmod part_gpt/insmod part_msdos/g; \
-s/set root='hd0,gpt2'/set root='hd0,msdos2'/g; \
-s/set root='hd0,gpt3'/set root='hd0,msdos3'/g" \
-"${TMP_MOUNT_PATH}"/boot/grub2/grub.cfg
- fi
- sync
- cp bootloader.sh "${TMP_MOUNT_PATH}"
- mount_proc_dev_sys "${TMP_MOUNT_PATH}"
- DEVICE="${device}" BOOT_MODE="${BOOT_MODE}" chroot "${TMP_MOUNT_PATH}" bash bootloader.sh
- rm -rf "${TMP_MOUNT_PATH}/bootloader.sh"
- sync
-
- dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
- sync
- unmount_dir "${TMP_MOUNT_PATH}"
- init_part system.img3 ROOT-B "${TMP_MOUNT_PATH}"
- umount "${TMP_MOUNT_PATH}"
-
- init_part system.img4 PERSIST "${TMP_MOUNT_PATH}"
- mkdir ${TMP_MOUNT_PATH}/{var,etc,etcwork}
- mkdir -p ${TMP_MOUNT_PATH}/etc/KubeOS/certs
- umount "${TMP_MOUNT_PATH}"
-
- losetup -D
- parted system.img -- set 1 boot on
- qemu-img convert system.img -O qcow2 system.qcow2
-}
-
-function create_pxe_img() {
- rm -rf initramfs.img kubeos.tar
- local opt=$1
- shift
- case $opt in
- "repo")
- create_os_tar_from_repo "$@"
- ;;
- "docker")
- create_os_tar_from_docker "$@"
- ;;
- esac
- tar -xvf os.tar ./initramfs.img
- mv os.tar kubeos.tar
-}
-
-function create_docker_image() {
- local DOCKER_IMG="$6"
- create_os_tar_from_repo "$@"
- docker build -t ${DOCKER_IMG} -f ./Dockerfile .
-}
-
-function create_vm_img() {
- local opt=$1
- shift
- local BOOT_MODE=$5
- case $opt in
- "repo")
- create_os_tar_from_repo "$@"
- create_img "${BOOT_MODE}"
- ;;
- "docker")
- create_os_tar_from_docker "$@"
- create_img "${BOOT_MODE}"
- ;;
- esac
-
-}
-
-function create_admin_img() {
- local DOCKERFILE="$1"
- local DOCKER_IMG="$2"
- local ADMIN_CONTAINER_DIR="$3"
- cp ../bin/hostshell ${ADMIN_CONTAINER_DIR}
- docker build -t ${DOCKER_IMG} -f ${DOCKERFILE} ${ADMIN_CONTAINER_DIR}
- rm -rf ${ADMIN_CONTAINER_DIR}/hostshell
-}
\ No newline at end of file
diff --git a/scripts/create/rootfsCreate.sh b/scripts/create/rootfsCreate.sh
deleted file mode 100644
index 377cbf8..0000000
--- a/scripts/create/rootfsCreate.sh
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-function prepare_yum() {
- # init rpmdb
- local REPO=$1
- rpm --root "${RPM_ROOT}" --initdb
- mkdir -p "${RPM_ROOT}"{/etc/yum.repos.d,/persist,/proc,/dev/pts,/sys}
- mount_proc_dev_sys "${RPM_ROOT}"
- # init yum repo
- local iso_repo="${RPM_ROOT}/etc/yum.repos.d/iso.repo"
- cat "${REPO}" > ${RPM_ROOT}/etc/yum.repos.d/iso.repo
-}
-
-function install_packages() {
- local REPO=$1
- local BOOT_MODE=$2
- prepare_yum ${REPO}
-
- echo "install package.."
-
- local filesize=$(stat -c "%s" ./rpmlist)
- local maxsize=$((1024*1024))
- if [ "${filesize}" -gt "${maxsize}" ]; then
- echo "please check if rpmlist is too big or something wrong"
- exit 7
- fi
-
- local rpms=$(cat ./rpmlist | tr "\n" " ")
- if [ "${ARCH}" == "x86_64" ]; then
- if [ "${BOOT_MODE}" = "legacy" ]; then
- rpms+=" grub2"
- else
- rpms+=" grub2-efi grub2-tools grub2-efi-x64-modules grub2-pc-modules"
- fi
- yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms}
- elif [ "${ARCH}" == "aarch64" ]; then
- yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2-efi grub2-tools grub2-efi-aa64-modules
- fi
- yum -y --installroot="${RPM_ROOT}" clean all
-}
-
-function install_misc() {
- local VERSION=$1
- local AGENT_PATH=$2
- local PASSWD=$3
- local BOOT_MODE=$4
- local DNS_CONF="${PWD}/resolv.conf"
- cp ../files/*mount ../files/os-agent.service "${RPM_ROOT}/usr/lib/systemd/system/"
- cp ../files/os-release "${RPM_ROOT}/usr/lib/"
- cp "${AGENT_PATH}" "${RPM_ROOT}/usr/bin"
- rm "${RPM_ROOT}/etc/os-release"
-
- cat <<EOF > "${RPM_ROOT}/usr/lib/os-release"
-NAME=${NAME}
-ID=${NAME}
-EOF
- echo "PRETTY_NAME=\"${NAME} ${VERSION}\"" >> "${RPM_ROOT}/usr/lib/os-release"
- echo "VERSION_ID=${VERSION}" >> "${RPM_ROOT}/usr/lib/os-release"
- mv "${RPM_ROOT}"/boot/vmlinuz* "${RPM_ROOT}/boot/vmlinuz"
- mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
- if [ "$BOOT_MODE" = "legacy" ]; then
- cp grub.cfg "${RPM_ROOT}"/boot/grub2
- sed -i "s/insmod part_gpt/insmod part_msdos/g; \
-s/set root='hd0,gpt2'/set root='hd0,msdos2'/g; \
-s/set root='hd0,gpt3'/set root='hd0,msdos3'/g" \
-"${RPM_ROOT}"/boot/grub2/grub.cfg
- else
- cp grub.cfg "${RPM_ROOT}"/boot/efi/EFI/openEuler
- fi
- cp -r ./00bootup ${RPM_ROOT}/usr/lib/dracut/modules.d/
- cp set_in_chroot.sh "${RPM_ROOT}"
- ROOT_PWD="${PASSWD}" BOOT_MODE="${BOOT_MODE}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
- rm "${RPM_ROOT}/set_in_chroot.sh"
- if [ -e "${DNS_CONF}" ]; then
- cp "${DNS_CONF}" "${RPM_ROOT}/etc/resolv.conf"
- fi
-}
-
-function create_os_tar_from_repo() {
- local REPO=$1
- local VERSION=$2
- local AGENT_PATH=$3
- local PASSWD=$4
- local BOOT_MODE=$5
- install_packages ${REPO} ${BOOT_MODE}
- install_misc ${VERSION} ${AGENT_PATH} ${PASSWD} ${BOOT_MODE}
- unmount_dir "${RPM_ROOT}"
- tar -C "$RPM_ROOT" -cf ./os.tar .
-}
-function create_os_tar_from_docker() {
- local DOCKER_IMG=$1
- container_id=$(docker create ${DOCKER_IMG})
- echo "$container_id"
- docker cp $container_id:/os.tar ./
- docker rm $container_id
-}
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
deleted file mode 100644
index 984b161..0000000
--- a/scripts/grub.cfg
+++ /dev/null
@@ -1,173 +0,0 @@
-## Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
- # KubeOS is licensed under the Mulan PSL v2.
- # You can use this software according to the terms and conditions of the Mulan PSL v2.
- # You may obtain a copy of Mulan PSL v2 at:
- # http://license.coscl.org.cn/MulanPSL2
- # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
- # IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
- # PURPOSE.
-## See the Mulan PSL v2 for more details.
-set pager=1
-
-if [ -f ${config_directory}/grubenv ]; then
- load_env -f ${config_directory}/grubenv
-elif [ -s $prefix/grubenv ]; then
- load_env
-fi
-if [ "${next_entry}" ] ; then
- set default="${next_entry}"
- set next_entry=
- save_env next_entry
- set boot_once=true
-else
- set default="${saved_entry}"
-fi
-
-if [ x"${feature_menuentry_id}" = xy ]; then
- menuentry_id_option="--id"
-else
- menuentry_id_option=""
-fi
-
-export menuentry_id_option
-
-if [ "${prev_saved_entry}" ]; then
- set saved_entry="${prev_saved_entry}"
- save_env saved_entry
- set prev_saved_entry=
- save_env prev_saved_entry
- set boot_once=true
-fi
-
-function savedefault {
- if [ -z "${boot_once}" ]; then
- saved_entry="${chosen}"
- save_env saved_entry
- fi
-}
-
-function load_video {
- if [ x$feature_all_video_module = xy ]; then
- insmod all_video
- else
- insmod efi_gop
- insmod efi_uga
- insmod ieee1275_fb
- insmod vbe
- insmod vga
- insmod video_bochs
- insmod video_cirrus
- fi
-}
-
-terminal_output console
-if [ x$feature_timeout_style = xy ] ; then
- set timeout_style=menu
- set timeout=5
-# Fallback normal timeout code in case the timeout_style feature is
-# unavailable.
-else
- set timeout=5
-fi
-set superusers="root"
-### END /etc/grub.d/00_header ###
-
-### BEGIN /etc/grub.d/01_users ###
-if [ -f ${prefix}/user.cfg ]; then
- source ${prefix}/user.cfg
- if [ -n "${GRUB2_PASSWORD}" ]; then
- set superusers="root"
- export superusers
- password_pbkdf2 root ${GRUB2_PASSWORD}
- fi
-fi
-### END /etc/grub.d/01_users ###
-
-### BEGIN /etc/grub.d/10_linux ###
-menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'KubeOS-A' {
- load_video
- set gfxpayload=keep
- insmod gzio
- insmod part_gpt
- insmod ext2
- set root='hd0,gpt2'
- linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
-}
-
-menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'KubeOS-B' {
- load_video
- set gfxpayload=keep
- insmod gzio
- insmod part_gpt
- insmod ext2
- set root='hd0,gpt3'
- linux /boot/vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
-}
-
-### END /etc/grub.d/10_linux ###
-
-### BEGIN /etc/grub.d/10_reset_boot_success ###
-# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
-if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
- set menu_hide_ok=1
-else
- set menu_hide_ok=0
-fi
-# Reset boot_indeterminate after a successful boot
-if [ "${boot_success}" = "1" ] ; then
- set boot_indeterminate=0
-# Avoid boot_indeterminate causing the menu to be hidden more then once
-elif [ "${boot_indeterminate}" = "1" ]; then
- set boot_indeterminate=2
-fi
-# Reset boot_success for current boot
-set boot_success=0
-save_env boot_success boot_indeterminate
-### END /etc/grub.d/10_reset_boot_success ###
-
-### BEGIN /etc/grub.d/12_menu_auto_hide ###
-if [ x$feature_timeout_style = xy ] ; then
- if [ "${menu_show_once}" ]; then
- unset menu_show_once
- save_env menu_show_once
- set timeout_style=menu
- set timeout=60
- elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
- set orig_timeout_style=${timeout_style}
- set orig_timeout=${timeout}
- if [ "${fastboot}" = "1" ]; then
- # timeout_style=menu + timeout=0 avoids the countdown code keypress check
- set timeout_style=menu
- set timeout=0
- else
- set timeout_style=hidden
- set timeout=1
- fi
- fi
-fi
-### END /etc/grub.d/12_menu_auto_hide ###
-
-### BEGIN /etc/grub.d/20_linux_xen ###
-### END /etc/grub.d/20_linux_xen ###
-
-### BEGIN /etc/grub.d/20_ppc_terminfo ###
-### END /etc/grub.d/20_ppc_terminfo ###
-
-### BEGIN /etc/grub.d/30_uefi-firmware ###
-### END /etc/grub.d/30_uefi-firmware ###
-
-### BEGIN /etc/grub.d/40_custom ###
-# This file provides an easy way to add custom menu entries. Simply type the
-# menu entries you want to add after this comment. Be careful not to change
-# the 'exec tail' line above.
-### END /etc/grub.d/40_custom ###
-
-### BEGIN /etc/grub.d/41_custom ###
-if [ -f ${config_directory}/custom.cfg ]; then
- source ${config_directory}/custom.cfg
-elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
- source $prefix/custom.cfg;
-fi
-### END /etc/grub.d/41_custom ###
diff --git a/scripts/kbimg.sh b/scripts/kbimg.sh
deleted file mode 100644
index 0f75f0d..0000000
--- a/scripts/kbimg.sh
+++ /dev/null
@@ -1,402 +0,0 @@
-#!/bin/bash
-## Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
-# KubeOS is licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-## See the Mulan PSL v2 for more details.
-
-set -e
-
-NAME=KubeOS
-REPO=""
-VERSION=""
-AGENT_PATH=""
-PASSWD=""
-DOCKER_IMG=""
-DOCKERFILE=""
-LOCK=./test.lock
-ADMIN_CONTAINER_DIR=./admin-container
-BOOT_MODE=efi
-
-source common/globalVariables.sh &>/dev/null
-source common/log.sh &>/dev/null
-source common/utils.sh &>/dev/null
-source create/rootfsCreate.sh &>/dev/null
-source create/imageCreate.sh &>/dev/null
-source 00bootup/Global.cfg &>/dev/null
-
-function show_options() {
- cat << EOF
-
-Usage : sh kbimg [COMMAND] [OPTIONS]
-
-kbimg is a tool used to handle KubeOS image , like create KubeOS images
-
-Commands:
- create create KubeOS images
-Options:
- -h,--help show help information
-
-Run 'kbimg COMMAND --help' for more information on a command.
-EOF
-}
-
-function show_create_usage() {
- cat << EOF
-
-Usage : kbimg create [COMMAND] [OPTIONS]
-
-commands:
- upgrade-image create KubeOS OCI image used for installation and upgrade
- vm-image create KubeOS virtual machine image
- pxe-image create images required for KubeOS PXE installation on physical machines
- admin-image create KubeOS admin container OCI image used for debug of worker nodes in clusters
-options:
- -h,--help show help information
-
-Run 'kbimg create COMMAND --help' for more information on a command.
-EOF
-}
-
-function show_upgrade_image_usage() {
- cat << EOF
-
-Usage : kbimg create upgrade-image -p isopath -v osversion -b osagentdir -e ospassword -d repository/name:tag
-
-options:
- -p repo path
- -v KubeOS version
- -b directory of os-agent binary
- -e os encrypted password
- -d docker image like repository/name:tag
- -l boot to legacy BIOS mode, if not specify, then UEFI mode
- -h,--help show help information
-EOF
-}
-
-function show_vm_pxe_image_usage() {
- cat << EOF
-
-Usage : kbimg create [vm-image|pxe-image] -p iso-path -v os-version -b os-agent-dir -e os-password
- or
- kbimg create [vm-image|pxe-image] -d repository/name:tag
-
-options:
- -p repo path
- -v KubeOS version
- -b directory of os-agent binary
- -e os encrypted password
- -d docker image like repository/name:tag
- -l boot to legacy BIOS mode, if not specify, then UEFI mode
- -h,--help show help information
-EOF
-}
-
-function show_admin_image_usage() {
- cat << EOF
-
-Usage : kbimg create admin-image -f dockerfile-path -d repository/name:tag
-
-options:
- -f Dockerfile path
- -d admin container image like repository/name:tag
- -h,--help show help information
-EOF
-}
-
-function file_lock() {
- local lock_file=$1
- exec {lock_fd}>"${lock_file}"
- flock -xn "${lock_fd}"
-}
-
-function test_lock() {
- file_lock "${LOCK}"
- if [ $? -ne 0 ]; then
- log_error_print "There is already an generate process running."
- exit 203
- fi
-}
-
-function clean_space() {
- delete_dir "${RPM_ROOT}"
- delete_dir "${TMP_MOUNT_PATH}"
- delete_file os.tar
- rm -rf "${LOCK}"
- delete_file ${ADMIN_CONTAINER_DIR}/hostshell
-}
-
-function clean_img() {
- delete_file system.img
- delete_file update.img
- delete_file initramfs.img
- delete_file kubeos.tar
-}
-
-function verify_upgrade_image_input() {
- set +eE
- for i in "p" "v" "b" "e" "d"
- do
- echo "$@" | grep -q "\-$i "
- if [ "$?" -ne 0 ];then
- log_error_print "option -$i is mandatory, please check input"
- show_upgrade_image_usage
- exit 3
- fi
- done
- set -eE
- while getopts "p:v:e:b:d:l" opt
- do
- case $opt in
- p)
- check_param $OPTARG
- REPO="$OPTARG"
- ;;
- v)
- check_param $OPTARG
- VERSION="$OPTARG"
- ;;
- b)
- check_param $OPTARG
- AGENT_PATH="$OPTARG"
- ;;
- e)
- # encrypted password contains special characters.,not verify.
- PASSWD="$OPTARG"
- ;;
- d)
- check_param $OPTARG
- DOCKER_IMG="$OPTARG"
- ;;
- l)
- BOOT_MODE=legacy
- ;;
- *)
- log_error_print "option $opt not found"
- show_upgrade_image_usage
- exit 3
- ;;
- esac
- done
-}
-
-function verify_repo_input() {
- set +eE
- for i in "p" "v" "b" "e"
- do
- echo "$@" | grep -q "\-$i "
- if [ "$?" -ne 0 ];then
- log_error_print "option -$i is mandatory, please check input"
- show_vm_pxe_image_usage
- exit 3
- fi
- done
- set -eE
- while getopts "p:v:e:b:l" opt
- do
- case $opt in
- p)
- check_param $OPTARG
- REPO="$OPTARG"
- ;;
- v)
- check_param $OPTARG
- VERSION="$OPTARG"
- ;;
- b)
- check_param $OPTARG
- AGENT_PATH="$OPTARG"
- ;;
- e)
- # encrypted password contains special characters.,not verify.
- PASSWD="$OPTARG"
- ;;
- l)
- BOOT_MODE=legacy
- ;;
- *)
- log_error_print "option $opt not found"
- show_vm_pxe_image_usage
- exit 3
- ;;
- esac
- done
-}
-
-function verify_docker_input() {
- if [ $1 != "-d" ]; then
- log_error_print "option $1 not found"
- show_vm_pxe_image_usage
- exit 3
- fi
- check_param $2
- DOCKER_IMG=$2
-}
-
-function verify_admin_input() {
- set +eE
- for i in "f" "d"
- do
- echo "$@" | grep -q "\-$i "
- if [ "$?" -ne 0 ];then
- log_error_print "option -$i is mandatory, please check input"
- show_admin_image_usage
- exit 3
- fi
- done
- set -eE
- while getopts "f:d:" opt
- do
- case $opt in
- f)
- check_param $OPTARG
- DOCKERFILE="$OPTARG"
- ;;
- d)
- check_param $OPTARG
- DOCKER_IMG="$OPTARG"
- ;;
- *)
- log_error_print "option $opt not found"
- show_admin_image_usage
- exit 3
- ;;
- esac
- done
-}
-
-function verify_create_input() {
- local ret=
- local cmd=$1
- case $1 in
- "upgrade-image")
- shift
- if [ $# -eq 1 ]; then
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_upgrade_image_usage
- exit 0
- fi
- fi
- if [[ $# -ne 10 && $# -ne 11 ]]; then
- log_error_print "the number of parameters is incorrect, please check it."
- show_upgrade_image_usage
- exit 3
- fi
- check_disk_space "docker"
- verify_upgrade_image_input "$@"
- check_repo_path "${REPO}"
- check_binary_exist "${AGENT_PATH}"
- create_docker_image "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}" "${BOOT_MODE}" "${DOCKER_IMG}"
- ;;
- "vm-image")
- shift
- if [ $# -eq 1 ]; then
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_vm_pxe_image_usage
- exit 0
- fi
- fi
- check_disk_space "vm"
- if [[ $# -eq 8 || $# -eq 9 ]]; then
- verify_repo_input "$@"
- check_repo_path "${REPO}"
- check_binary_exist "${AGENT_PATH}"
- create_vm_img "repo" "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}" "${BOOT_MODE}"
- elif [ $# -eq 2 ]; then
- verify_docker_input "$@"
- check_docker_exist "${DOCKER_IMG}"
- create_vm_img "docker" "${DOCKER_IMG}"
- else
- log_error_print "the number of parameters is incorrect, please check it."
- show_vm_pxe_image_usage
- exit 3
- fi
- ;;
- "pxe-image")
- shift
- if [ $# -eq 1 ]; then
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_vm_pxe_image_usage
- exit 0
- fi
- fi
- check_disk_space "pxe"
- check_conf_valid ${rootfs_name} ${disk} ${server_ip} ${local_ip} ${route_ip} ${netmask} ${net_name}
- if [ $# -eq 8 ]; then
- verify_repo_input "$@"
- check_repo_path "${REPO}"
- check_binary_exist "${AGENT_PATH}"
- create_pxe_img "repo" "${REPO}" "${VERSION}" "${AGENT_PATH}" "${PASSWD}"
- elif [ $# -eq 2 ]; then
- verify_docker_input "$@"
- check_docker_exist "${DOCKER_IMG}"
- create_pxe_img "docker" "${DOCKER_IMG}"
- else
- log_error_print "the number of parameters is incorrect, please check it."
- show_vm_pxe_image_usage
- exit 3
- fi
- ;;
- "admin-image")
- shift
- if [ $# -eq 1 ]; then
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- show_admin_image_usage
- exit 0
- fi
- fi
- if [ $# -ne 4 ]; then
- log_error_print "the number of parameters is incorrect, please check it."
- show_admin_image_usage
- exit 3
- fi
- verify_admin_input "$@"
- check_docker_file "${DOCKERFILE}"
- create_admin_img "${DOCKERFILE}" "${DOCKER_IMG}" "${ADMIN_CONTAINER_DIR}"
- ;;
- "-h"|"--help")
- show_create_usage
- ;;
- *)
- log_error_print "error command $1 not found"
- show_create_usage
- exit 3
- esac
-}
-
-function kubeos_image_main() {
- local ret=
- local cmd=$1
- if [ "$#" -eq 1 ]; then
- case $1 in
- -h|--help)
- show_options
- exit 0;;
- *)
- log_error_print "params is invalid,please check it."
- show_options
- exit 3;;
- esac
- fi
- case $cmd in
- create)
- shift
- verify_create_input "$@"
- ;;
- *)
- log_error_print "command $1 not found"
- show_options
- exit 3
- ;;
- esac
-}
-
-test_lock
-trap clean_space EXIT
-trap clean_img ERR
-
-kubeos_image_main "$@"
diff --git a/scripts/rpmlist b/scripts/rpmlist
deleted file mode 100644
index fb6f238..0000000
--- a/scripts/rpmlist
+++ /dev/null
@@ -1,22 +0,0 @@
-kernel
-passwd
-dhcp
-NetworkManager
-openssh-server
-docker
-kubernetes-kubeadm
-kubernetes-kubelet
-containernetworking-plugins
-socat
-conntrack-tools
-ebtables
-ethtool
-rsyslog
-vi
-net-tools
-hwinfo
-dracut
-coreutils
-gawk
-parted
-dosfstools
\ No newline at end of file
diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh
deleted file mode 100644
index 80b5a91..0000000
--- a/scripts/set_in_chroot.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-ln -s /usr/lib/systemd/system/os-agent.service /usr/lib/systemd/system/multi-user.target.wants/os-agent.service
-ln -s /usr/lib/systemd/system/kubelet.service /usr/lib/systemd/system/multi-user.target.wants/kubelet.service
-if [ "$BOOT_MODE" = "legacy" ]; then
- ln -s /usr/lib/systemd/system/boot-grub2.mount /lib/systemd/system/local-fs.target.wants/boot-grub2.mount
-else
- ln -s /usr/lib/systemd/system/boot-efi.mount /lib/systemd/system/local-fs.target.wants/boot-efi.mount
-fi
-ln -s /usr/lib/systemd/system/etc.mount /lib/systemd/system/local-fs.target.wants/etc.mount
-
-str=`sed -n '/^root:/p' /etc/shadow | awk -F "root:" '{print $2}'`
-umask 0666
-mv /etc/shadow /etc/shadow_bak
-sed -i '/^root:/d' /etc/shadow_bak
-echo "root:"${ROOT_PWD}${str:1} > /etc/shadow
-cat /etc/shadow_bak >> /etc/shadow
-rm -rf /etc/shadow_bak
-
-dracut -f -v --add bootup /initramfs.img --kver `ls /lib/modules`
-rm -rf /usr/lib/dracut/modules.d/00bootup
\ No newline at end of file
--
2.39.0