KubeOS:update to 1.0.2-2
Update version to 1.0.2-2 Signed-off-by: liyuanr <liyuanrong1@huawei.com>
This commit is contained in:
parent
495b312308
commit
8f0394154c
@ -1,264 +0,0 @@
|
||||
From 0ccbd9d7eba9d600746420d2dd363065f487be17 Mon Sep 17 00:00:00 2001
|
||||
From: liyuanr <liyuanrong1@huawei.com>
|
||||
Date: Sat, 30 Oct 2021 02:50:37 +0000
|
||||
Subject: [PATCH] KubeOS:modify checks in generate.sh and change module path
|
||||
|
||||
The previous disk space check did not consider the case where
|
||||
the disk capacity was TB. In addition,if a path containing
|
||||
/mnt exists,the mount check consider that /mnt has been mounted.
|
||||
|
||||
Add the processing when the disk capacity is TB during disk check,
|
||||
modify mount check and changes module path to openeuler.org/KubeOS.
|
||||
|
||||
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
|
||||
---
|
||||
VERSION | 2 +-
|
||||
cmd/agent/main.go | 6 ++--
|
||||
cmd/agent/server/server.go | 2 +-
|
||||
cmd/operator/controllers/os_controller.go | 6 ++--
|
||||
cmd/operator/main.go | 8 +++---
|
||||
cmd/proxy/controllers/os_controller.go | 14 ++++-----
|
||||
cmd/proxy/main.go | 12 ++++----
|
||||
go.mod | 2 +-
|
||||
hack/releasenote.sh | 35 +++++++++++++++++++++++
|
||||
pkg/agentclient/connection.go | 2 +-
|
||||
scripts/generate.sh | 16 ++++++-----
|
||||
11 files changed, 71 insertions(+), 34 deletions(-)
|
||||
create mode 100755 hack/releasenote.sh
|
||||
|
||||
diff --git a/VERSION b/VERSION
|
||||
index 3eefcb9..7dea76e 100644
|
||||
--- a/VERSION
|
||||
+++ b/VERSION
|
||||
@@ -1 +1 @@
|
||||
-1.0.0
|
||||
+1.0.1
|
||||
diff --git a/cmd/agent/main.go b/cmd/agent/main.go
|
||||
index 8f9485a..aef9e47 100644
|
||||
--- a/cmd/agent/main.go
|
||||
+++ b/cmd/agent/main.go
|
||||
@@ -17,9 +17,9 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
- pb "openeuler.org/saiyan/cmd/agent/api"
|
||||
- "openeuler.org/saiyan/cmd/agent/server"
|
||||
- "openeuler.org/saiyan/pkg/version"
|
||||
+ pb "openeuler.org/KubeOS/cmd/agent/api"
|
||||
+ "openeuler.org/KubeOS/cmd/agent/server"
|
||||
+ "openeuler.org/KubeOS/pkg/version"
|
||||
)
|
||||
|
||||
func main() {
|
||||
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
|
||||
index ef8630b..711e0c8 100644
|
||||
--- a/cmd/agent/server/server.go
|
||||
+++ b/cmd/agent/server/server.go
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
- pb "openeuler.org/saiyan/cmd/agent/api"
|
||||
+ pb "openeuler.org/KubeOS/cmd/agent/api"
|
||||
)
|
||||
|
||||
const (
|
||||
diff --git a/cmd/operator/controllers/os_controller.go b/cmd/operator/controllers/os_controller.go
|
||||
index 5c572fd..a040ef4 100644
|
||||
--- a/cmd/operator/controllers/os_controller.go
|
||||
+++ b/cmd/operator/controllers/os_controller.go
|
||||
@@ -25,9 +25,9 @@ import (
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
|
||||
- "openeuler.org/saiyan/pkg/common"
|
||||
- "openeuler.org/saiyan/pkg/values"
|
||||
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
|
||||
+ "openeuler.org/KubeOS/pkg/common"
|
||||
+ "openeuler.org/KubeOS/pkg/values"
|
||||
)
|
||||
|
||||
// OSReconciler reconciles an OS object
|
||||
diff --git a/cmd/operator/main.go b/cmd/operator/main.go
|
||||
index c8c0530..17b74e1 100644
|
||||
--- a/cmd/operator/main.go
|
||||
+++ b/cmd/operator/main.go
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
|
||||
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
|
||||
- "openeuler.org/saiyan/cmd/operator/controllers"
|
||||
- "openeuler.org/saiyan/pkg/common"
|
||||
- "openeuler.org/saiyan/pkg/version"
|
||||
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
|
||||
+ "openeuler.org/KubeOS/cmd/operator/controllers"
|
||||
+ "openeuler.org/KubeOS/pkg/common"
|
||||
+ "openeuler.org/KubeOS/pkg/version"
|
||||
//+kubebuilder:scaffold:imports
|
||||
)
|
||||
|
||||
diff --git a/cmd/proxy/controllers/os_controller.go b/cmd/proxy/controllers/os_controller.go
|
||||
index 04aed8f..ab9a411 100644
|
||||
--- a/cmd/proxy/controllers/os_controller.go
|
||||
+++ b/cmd/proxy/controllers/os_controller.go
|
||||
@@ -26,10 +26,10 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
|
||||
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
|
||||
- "openeuler.org/saiyan/pkg/agentclient"
|
||||
- "openeuler.org/saiyan/pkg/common"
|
||||
- "openeuler.org/saiyan/pkg/values"
|
||||
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
|
||||
+ "openeuler.org/KubeOS/pkg/agentclient"
|
||||
+ "openeuler.org/KubeOS/pkg/common"
|
||||
+ "openeuler.org/KubeOS/pkg/values"
|
||||
)
|
||||
|
||||
// OSReconciler reconciles a OS object
|
||||
@@ -137,9 +137,9 @@ func evictNode(drainer *drain.Helper, node *corev1.Node) error {
|
||||
}
|
||||
if err := drain.RunNodeDrain(drainer, node.Name); err != nil {
|
||||
log.Error(err, "unable to drain node")
|
||||
- if err := drain.RunCordonOrUncordon(drainer, node, false); err != nil {
|
||||
- log.Error(err, "unable to uncordon node when an error occurs in draining node")
|
||||
- return err
|
||||
+ if terr := drain.RunCordonOrUncordon(drainer, node, false); terr != nil {
|
||||
+ log.Error(terr, "unable to uncordon node when an error occurs in draining node")
|
||||
+ return terr
|
||||
}
|
||||
return err
|
||||
}
|
||||
diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go
|
||||
index 921bd95..ce1f58d 100644
|
||||
--- a/cmd/proxy/main.go
|
||||
+++ b/cmd/proxy/main.go
|
||||
@@ -22,12 +22,12 @@ import (
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
|
||||
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
|
||||
- "openeuler.org/saiyan/cmd/agent/server"
|
||||
- "openeuler.org/saiyan/cmd/proxy/controllers"
|
||||
- "openeuler.org/saiyan/pkg/agentclient"
|
||||
- "openeuler.org/saiyan/pkg/common"
|
||||
- "openeuler.org/saiyan/pkg/version"
|
||||
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
|
||||
+ "openeuler.org/KubeOS/cmd/agent/server"
|
||||
+ "openeuler.org/KubeOS/cmd/proxy/controllers"
|
||||
+ "openeuler.org/KubeOS/pkg/agentclient"
|
||||
+ "openeuler.org/KubeOS/pkg/common"
|
||||
+ "openeuler.org/KubeOS/pkg/version"
|
||||
//+kubebuilder:scaffold:imports
|
||||
)
|
||||
|
||||
diff --git a/go.mod b/go.mod
|
||||
index cdf8ff6..736e6bd 100644
|
||||
--- a/go.mod
|
||||
+++ b/go.mod
|
||||
@@ -1,4 +1,4 @@
|
||||
-module openeuler.org/saiyan
|
||||
+module openeuler.org/KubeOS
|
||||
|
||||
go 1.15
|
||||
|
||||
diff --git a/hack/releasenote.sh b/hack/releasenote.sh
|
||||
new file mode 100755
|
||||
index 0000000..71049a2
|
||||
--- /dev/null
|
||||
+++ b/hack/releasenote.sh
|
||||
@@ -0,0 +1,35 @@
|
||||
+#!/bin/bash
|
||||
+#######################################################################
|
||||
+##- @Copyright (C) Huawei Technologies., Ltd. 2021. All rights reserved.
|
||||
+# - KubeOS 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.
|
||||
+#######################################################################
|
||||
+
|
||||
+#!/bin/bash
|
||||
+
|
||||
+function get_release_notes()
|
||||
+{
|
||||
+ LAST_RELEASE=$(git describe --tags --abbrev=0)
|
||||
+ # Prepare proposed delease notes
|
||||
+ echo "$(date "+%Y-%m-%d") $USER release $1"
|
||||
+ git log --first-parent --oneline $LAST_RELEASE.. | cut -d' ' -f 2- | sed 's/^/ - /'
|
||||
+ echo ""
|
||||
+ echo " dev stats:"
|
||||
+ echo " -$(git diff --shortstat $LAST_RELEASE)"
|
||||
+ echo -n " - contributors: "
|
||||
+ git shortlog -ns --no-merges $LAST_RELEASE..HEAD | cut -d$'\t' -f 2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/, /g'
|
||||
+ echo ""
|
||||
+}
|
||||
+
|
||||
+if [ $# -ne 1 ];then
|
||||
+ echo "Usage:"
|
||||
+ echo "./hack/releasenote.sh v1.0.0"
|
||||
+ exit 0
|
||||
+fi
|
||||
+get_release_notes $1
|
||||
diff --git a/pkg/agentclient/connection.go b/pkg/agentclient/connection.go
|
||||
index 1f28ee4..7d16019 100644
|
||||
--- a/pkg/agentclient/connection.go
|
||||
+++ b/pkg/agentclient/connection.go
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
|
||||
- pb "openeuler.org/saiyan/cmd/agent/api"
|
||||
+ pb "openeuler.org/KubeOS/cmd/agent/api"
|
||||
)
|
||||
|
||||
// Client defines the client stub for OS service
|
||||
diff --git a/scripts/generate.sh b/scripts/generate.sh
|
||||
index 7a57b05..1374894 100644
|
||||
--- a/scripts/generate.sh
|
||||
+++ b/scripts/generate.sh
|
||||
@@ -145,7 +145,7 @@ function check_path() {
|
||||
exit 5
|
||||
fi
|
||||
|
||||
- if mount 2>/dev/null | grep -q "${ISO_PATH}"; then
|
||||
+ if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
|
||||
echo "$ISO_PATH has already been mounted."
|
||||
exit 4
|
||||
fi
|
||||
@@ -153,11 +153,13 @@ function check_path() {
|
||||
|
||||
function check_disk_space() {
|
||||
local disk_ava="$(df ${PWD} -h | awk 'NR==2{print}' | awk '{print $4}')"
|
||||
- if echo "${disk_ava}" | grep -q G$; then
|
||||
- disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
|
||||
- if [ "${disk_ava}" -lt 25 ]; then
|
||||
- echo "The available disk space is not enough, at least 25GB."
|
||||
- exit 6
|
||||
+ if echo "${disk_ava}" | grep -q [GT]$; then
|
||||
+ if echo "${disk_ava}" | grep -q G$; then
|
||||
+ disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
|
||||
+ if [ "${disk_ava}" -lt 25 ]; then
|
||||
+ echo "The available disk space is not enough, at least 25GB."
|
||||
+ exit 6
|
||||
+ fi
|
||||
fi
|
||||
else
|
||||
echo "The available disk space is not enough, at least 25G."
|
||||
@@ -293,7 +295,7 @@ fi
|
||||
set +eE
|
||||
for i in $1 $2 $3
|
||||
do
|
||||
- echo "$i" | grep -v -E ${CHECK_REGEX}
|
||||
+ echo "$i" | grep -v -E -q ${CHECK_REGEX}
|
||||
filterParam=$(echo "$i" | grep -v -E ${CHECK_REGEX})
|
||||
if [[ "${filterParam}" != "$i" ]]; then
|
||||
echo "error: params $i is invalid, please check it."
|
||||
--
|
||||
2.30.0
|
||||
|
||||
479
0001-Write-a-tool-to-support-KubeOS-deployment-on-physica.patch
Normal file
479
0001-Write-a-tool-to-support-KubeOS-deployment-on-physica.patch
Normal file
@ -0,0 +1,479 @@
|
||||
From 236b8ddeb3bc7f35eb817769f117ecd68a59335c Mon Sep 17 00:00:00 2001
|
||||
From: stedylan <836671668@qq.com>
|
||||
Date: Sun, 7 Aug 2022 01:47:14 +0800
|
||||
Subject: [PATCH] Write a tool to support KubeOS deployment on physical
|
||||
machines.
|
||||
|
||||
This tool uses dracut module to make partitions and formatting, set network infomation, get rootfs and set boot options in initramfs before switch to the real root.
|
||||
|
||||
Signed-off-by: stedylan <836671668@qq.com>
|
||||
---
|
||||
scripts/00bootup/Global.cfg | 12 ++
|
||||
scripts/00bootup/module-setup.sh | 28 +++
|
||||
scripts/00bootup/mount.sh | 332 +++++++++++++++++++++++++++++++
|
||||
scripts/create/imageCreate.sh | 4 +-
|
||||
scripts/create/rootfsCreate.sh | 1 +
|
||||
scripts/rpmlist | 10 +-
|
||||
scripts/set_in_chroot.sh | 3 +
|
||||
7 files changed, 387 insertions(+), 3 deletions(-)
|
||||
create mode 100644 scripts/00bootup/Global.cfg
|
||||
create mode 100644 scripts/00bootup/module-setup.sh
|
||||
create mode 100644 scripts/00bootup/mount.sh
|
||||
|
||||
diff --git a/scripts/00bootup/Global.cfg b/scripts/00bootup/Global.cfg
|
||||
new file mode 100644
|
||||
index 0000000..cad4e33
|
||||
--- /dev/null
|
||||
+++ b/scripts/00bootup/Global.cfg
|
||||
@@ -0,0 +1,12 @@
|
||||
+# rootfs file name
|
||||
+rootfs_name=kubeos.tar
|
||||
+
|
||||
+# select the target disk to install kubeOS
|
||||
+disk=/dev/sda
|
||||
+
|
||||
+# address where stores the rootfs on the http server
|
||||
+server_ip=192.168.1.50
|
||||
+
|
||||
+local_ip=192.168.1.100
|
||||
+
|
||||
+route_ip=192.168.1.1
|
||||
\ No newline at end of file
|
||||
diff --git a/scripts/00bootup/module-setup.sh b/scripts/00bootup/module-setup.sh
|
||||
new file mode 100644
|
||||
index 0000000..5460b2b
|
||||
--- /dev/null
|
||||
+++ b/scripts/00bootup/module-setup.sh
|
||||
@@ -0,0 +1,28 @@
|
||||
+#!/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
|
||||
new file mode 100644
|
||||
index 0000000..a04a364
|
||||
--- /dev/null
|
||||
+++ b/scripts/00bootup/mount.sh
|
||||
@@ -0,0 +1,332 @@
|
||||
+#!/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 GetDisk() {
|
||||
+ disks=$(hwinfo --disk --short | grep -vi "^disk" | awk '{print $1}')
|
||||
+ if [ ! -z ${disks} ]; then
|
||||
+ if [ ! -z ${disk} ] && echo "${disks[@]}" | grep -wq "${disk}" ; then
|
||||
+ echo "${disk} exists, start partition" | tee -a ${log}
|
||||
+ else
|
||||
+ echo "disk not exist, choose default disk" | tee -a ${log}
|
||||
+ disk=$(echo ${disks[0]})
|
||||
+ 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..."
|
||||
+ # 获取网卡信息,默认只有一个网卡
|
||||
+ net_name=`ifconfig -a | awk '{print $1}' | grep : | grep '^e' | awk -F: '{print $1}'`
|
||||
+ # dhclient --timeout 60 >> ${log} 2>&1
|
||||
+
|
||||
+ 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 255.255.255.0 >> ${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"
|
||||
+ mkdir /persist
|
||||
+ mount ${disk}4 /persist >> ${log} 2>&1
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ echo "mount persist failed" | tee -a ${log}
|
||||
+ return 1
|
||||
+ fi
|
||||
+ mkdir /persist/{var,etc,etcwork}
|
||||
+ mkdir -p /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 /persist/${rootfs_name} http://${server_ip}/${rootfs_name}
|
||||
+ if [ ! -e "/persist/${rootfs_name}" ]; then
|
||||
+ echo "download rootfs failed" | tee -a ${log}
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ tar -xvf /persist/${rootfs_name} -C /sysroot
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ echo "decompose rootfs failed" | tee -a ${log}
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ rm -rf /persist/${rootfs_name}
|
||||
+
|
||||
+ 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
|
||||
+
|
||||
+ 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
|
||||
+ echo "Mounting root..." | tee -a ${log}
|
||||
+ MountRoot
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ echo "Mounting root failed" | tee -a ${log}
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ # mount persist
|
||||
+ echo "Mounting persisst..." | tee -a ${log}
|
||||
+ MountPersist
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ echo "Mounting persist failed" | tee -a ${log}
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ # mount boot
|
||||
+ 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
|
||||
+
|
||||
+ # set boot
|
||||
+ echo "Setting boot..." | tee -a ${log}
|
||||
+ SetBoot
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ echo "Setting boot 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} /persist
|
||||
+else
|
||||
+ echo "kubeOS install failed, see install.log" | tee -a ${log}
|
||||
+fi
|
||||
+
|
||||
diff --git a/scripts/create/imageCreate.sh b/scripts/create/imageCreate.sh
|
||||
index f8dafbe..95ebcde 100644
|
||||
--- a/scripts/create/imageCreate.sh
|
||||
+++ b/scripts/create/imageCreate.sh
|
||||
@@ -62,12 +62,12 @@ function create_pxe_img() {
|
||||
case $opt in
|
||||
"repo")
|
||||
create_os_tar_from_repo "$@"
|
||||
- tar -xvf os.tar ./boot/initramfs.img
|
||||
+ tar -xvf os.tar ./initramfs.img
|
||||
tar -xvf os.tar ./boot/vmlinuz
|
||||
;;
|
||||
"docker")
|
||||
create_os_tar_from_docker "$@"
|
||||
- tar -xvf os.tar boot/initramfs.img
|
||||
+ tar -xvf os.tar initramfs.img
|
||||
tar -xvf os.tar boot/vmlinuz
|
||||
;;
|
||||
esac
|
||||
diff --git a/scripts/create/rootfsCreate.sh b/scripts/create/rootfsCreate.sh
|
||||
index 8049f09..e5c53d5 100644
|
||||
--- a/scripts/create/rootfsCreate.sh
|
||||
+++ b/scripts/create/rootfsCreate.sh
|
||||
@@ -61,6 +61,7 @@ EOF
|
||||
mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
|
||||
cp grub.cfg "${RPM_ROOT}"/boot/grub2
|
||||
cp grub.cfg "${RPM_ROOT}"/boot/efi/EFI/openEuler
|
||||
+ cp -r ./00bootup ${RPM_ROOT}/usr/lib/dracut/modules.d/
|
||||
cp set_in_chroot.sh "${RPM_ROOT}"
|
||||
ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
|
||||
rm "${RPM_ROOT}/set_in_chroot.sh"
|
||||
diff --git a/scripts/rpmlist b/scripts/rpmlist
|
||||
index 7a9adfa..077a164 100644
|
||||
--- a/scripts/rpmlist
|
||||
+++ b/scripts/rpmlist
|
||||
@@ -13,4 +13,12 @@ socat
|
||||
conntrack-tools
|
||||
ebtables
|
||||
ethtool
|
||||
-rsyslog
|
||||
\ No newline at end of file
|
||||
+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
|
||||
index bacef78..4b061df 100644
|
||||
--- a/scripts/set_in_chroot.sh
|
||||
+++ b/scripts/set_in_chroot.sh
|
||||
@@ -11,3 +11,6 @@ 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.33.0.windows.2
|
||||
|
||||
@ -1,119 +0,0 @@
|
||||
From c652bb6f46ce2e434bd098552abebbba8909a9c0 Mon Sep 17 00:00:00 2001
|
||||
From: linxiaoxu <linxiaoxu@huawei.com>
|
||||
Date: Wed, 8 Dec 2021 02:01:18 +0000
|
||||
Subject: [PATCH] change generate argument from isopath to repopath
|
||||
|
||||
---
|
||||
docs/quick-start.md | 4 ++--
|
||||
scripts/generate.sh | 30 ++++++------------------------
|
||||
2 files changed, 8 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/docs/quick-start.md b/docs/quick-start.md
|
||||
index 098c839..ceb81e5 100644
|
||||
--- a/docs/quick-start.md
|
||||
+++ b/docs/quick-start.md
|
||||
@@ -56,10 +56,10 @@
|
||||
进入scripts目录,执行脚本
|
||||
```
|
||||
cd scripts
|
||||
- bash generate.sh ISO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
|
||||
+ bash generate.sh REPO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
|
||||
```
|
||||
- 参数说明:
|
||||
- - ISO_PATH :全量iso的路径
|
||||
+ - REPO_PATH :全量repo的路径
|
||||
- VERSION :制作的容器OS镜像的版本
|
||||
- AGENT_PATH:构建出来的os-agent的路径
|
||||
- ENCRYPTED_PASSWD:镜像的root用户密码,加密后的带盐值的密码。可以用openssl、kiwi等命令生成
|
||||
diff --git a/scripts/generate.sh b/scripts/generate.sh
|
||||
index 1374894..d5111f1 100644
|
||||
--- a/scripts/generate.sh
|
||||
+++ b/scripts/generate.sh
|
||||
@@ -12,8 +12,7 @@
|
||||
set -e
|
||||
|
||||
NAME=KubeOS
|
||||
-ISO_PATH="/mnt"
|
||||
-ISO=""
|
||||
+REPO=""
|
||||
VERSION=""
|
||||
AGENT_PATH=""
|
||||
PASSWD=""
|
||||
@@ -27,7 +26,7 @@ CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
|
||||
function show_options() {
|
||||
cat << EOF
|
||||
|
||||
-usage example: sh generate.sh isopath osversion agentpath passwd(encrypted)
|
||||
+usage example: sh generate.sh repopath osversion agentpath passwd(encrypted)
|
||||
|
||||
options:
|
||||
-h,--help show help information
|
||||
@@ -114,7 +113,6 @@ function delete_file() {
|
||||
function clean_space() {
|
||||
delete_dir "${RPM_ROOT}"
|
||||
delete_dir "${TMP_MOUNT_PATH}"
|
||||
- unmount_dir "${ISO_PATH}"
|
||||
delete_file os.tar
|
||||
rm -rf "${LOCK}"
|
||||
}
|
||||
@@ -135,8 +133,8 @@ function test_lock() {
|
||||
}
|
||||
|
||||
function check_path() {
|
||||
- if [ ! -f "${ISO}" ];then
|
||||
- echo "ISO path is invalid."
|
||||
+ if [ ! -f "${REPO}" ];then
|
||||
+ echo "REPO path is invalid."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
@@ -144,11 +142,6 @@ function check_path() {
|
||||
echo "there is a rootfs folder. please confirm if rootfs is being used, if not, please remove ${RPM_ROOT} first."
|
||||
exit 5
|
||||
fi
|
||||
-
|
||||
- if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
|
||||
- echo "$ISO_PATH has already been mounted."
|
||||
- exit 4
|
||||
- fi
|
||||
}
|
||||
|
||||
function check_disk_space() {
|
||||
@@ -168,24 +161,13 @@ function check_disk_space() {
|
||||
}
|
||||
|
||||
function prepare_yum() {
|
||||
- mount "${ISO}" "${ISO_PATH}"
|
||||
- if [ ! -d "/mnt/Packages" ]; then
|
||||
- echo "please use ISO file path as ${ISO}."
|
||||
- exit 2
|
||||
- fi
|
||||
-
|
||||
# init rpmdb
|
||||
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"
|
||||
- echo "[base]" >"${iso_repo}"
|
||||
- {
|
||||
- echo "name=ISO base"
|
||||
- echo "baseurl=file://${ISO_PATH}"
|
||||
- echo "enabled=1"
|
||||
- } >>"${iso_repo}"
|
||||
+ cat ${REPO} > ${RPM_ROOT}/etc/yum.repos.d/iso.repo
|
||||
}
|
||||
|
||||
function install_packages() {
|
||||
@@ -304,7 +286,7 @@ do
|
||||
done
|
||||
set -eE
|
||||
|
||||
-ISO=$1
|
||||
+REPO=$1
|
||||
VERSION=$2
|
||||
AGENT_PATH=$3
|
||||
PASSWD=$4
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@ -1,298 +0,0 @@
|
||||
From a19218ad25eac323ead61ec5ff1fbb04a6dc2539 Mon Sep 17 00:00:00 2001
|
||||
From: liyuanr <liyuanrong1@huawei.com>
|
||||
Date: Fri, 3 Dec 2021 11:16:22 +0800
|
||||
Subject: [PATCH] KubeOS:add arm architecture support to the OS image
|
||||
|
||||
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
|
||||
---
|
||||
cmd/agent/server/server.go | 5 +-
|
||||
files/{boot-grub2.mount => boot.mount} | 6 +-
|
||||
scripts/bootloader.sh | 40 +++++++++++++
|
||||
scripts/generate.sh | 83 +++++++++++++++-----------
|
||||
scripts/grub.cfg | 16 ++---
|
||||
scripts/rpmlist | 3 +-
|
||||
scripts/set_in_chroot.sh | 2 +-
|
||||
7 files changed, 107 insertions(+), 48 deletions(-)
|
||||
rename files/{boot-grub2.mount => boot.mount} (92%)
|
||||
create mode 100644 scripts/bootloader.sh
|
||||
|
||||
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
|
||||
index 711e0c8..e4db02e 100644
|
||||
--- a/cmd/agent/server/server.go
|
||||
+++ b/cmd/agent/server/server.go
|
||||
@@ -174,7 +174,10 @@ func install(imagePath string, mainPart string, partB string) error {
|
||||
if side != partB {
|
||||
next = "A"
|
||||
}
|
||||
- return runCommand("grub2-set-default", next)
|
||||
+ if err := runCommand("grub2-set-default", next); err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ return runCommand("cp", "/boot/grub2/grubenv", "/boot/efi/EFI/openEuler")
|
||||
}
|
||||
|
||||
func (s *Server) reboot() error {
|
||||
diff --git a/files/boot-grub2.mount b/files/boot.mount
|
||||
similarity index 92%
|
||||
rename from files/boot-grub2.mount
|
||||
rename to files/boot.mount
|
||||
index a53fff7..a228aae 100644
|
||||
--- a/files/boot-grub2.mount
|
||||
+++ b/files/boot.mount
|
||||
@@ -15,9 +15,9 @@ Conflicts=umount.target
|
||||
Before=local-fs.target umount.target
|
||||
|
||||
[Mount]
|
||||
-What=/dev/disk/by-label/GRUB2
|
||||
-Where=/boot/grub2
|
||||
-Type=ext4
|
||||
+What=/dev/disk/by-label/BOOT
|
||||
+Where=/boot
|
||||
+Type=vfat
|
||||
Options=defaults
|
||||
|
||||
[Install]
|
||||
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
|
||||
new file mode 100644
|
||||
index 0000000..b93c314
|
||||
--- /dev/null
|
||||
+++ b/scripts/bootloader.sh
|
||||
@@ -0,0 +1,40 @@
|
||||
+#!/bin/bash
|
||||
+set -eu
|
||||
+set -o pipefail
|
||||
+set -x
|
||||
+ARCH=`arch`
|
||||
+
|
||||
+function install_grub2_x86 ()
|
||||
+{
|
||||
+ # 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
|
||||
+
|
||||
+ # 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=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
|
||||
+
|
||||
+ mkdir -p /boot/EFI/BOOT/
|
||||
+ cp -f /boot/efi/EFI/openEuler/grubx64.efi /boot/EFI/BOOT/BOOTX64.EFI
|
||||
+}
|
||||
+
|
||||
+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=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
|
||||
+
|
||||
+ mkdir -p /boot/EFI/BOOT/
|
||||
+ cp -f /boot/efi/EFI/openEuler/grubaa64.efi /boot/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/generate.sh b/scripts/generate.sh
|
||||
index 73830ea..c481e30 100644
|
||||
--- a/scripts/generate.sh
|
||||
+++ b/scripts/generate.sh
|
||||
@@ -22,6 +22,7 @@ TMP_MOUNT_PATH="${PWD}/mnt"
|
||||
RPM_ROOT="${PWD}/rootfs"
|
||||
LOCK=./test.lock
|
||||
CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
|
||||
+ARCH=$(arch)
|
||||
|
||||
function show_options() {
|
||||
cat << EOF
|
||||
@@ -76,9 +77,14 @@ function init_part() {
|
||||
offset=$(echo "${offset}*512" | bc)
|
||||
local loop=$(losetup -f)
|
||||
losetup -o "${offset}" --sizelimit "${sizelimit}" "${loop}" system.img
|
||||
- mkfs.ext4 -L "$2" "${loop}"
|
||||
- mount -t ext4 "${loop}" "$3"
|
||||
- rm -rf "$3/lost+found"
|
||||
+ 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() {
|
||||
@@ -183,12 +189,15 @@ function install_packages() {
|
||||
fi
|
||||
|
||||
local rpms=$(cat ./rpmlist | tr "\n" " ")
|
||||
- yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms}
|
||||
- yum -y --installroot="${RPM_ROOT}" clean all
|
||||
+ if [ "${ARCH}" == "x86_64" ]; then
|
||||
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2 grub2-efi-x64-modules grub2-pc-modules
|
||||
+ elif [ "${ARCH}" == "aarch64" ]; then
|
||||
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2-efi-aa64-modules
|
||||
+ fi
|
||||
+ yum -y --installroot="${RPM_ROOT}" clean all
|
||||
}
|
||||
|
||||
function install_misc() {
|
||||
- cp grub.cfg "${RPM_ROOT}/boot/grub2/"
|
||||
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"
|
||||
@@ -204,38 +213,46 @@ EOF
|
||||
mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
|
||||
|
||||
cp set_in_chroot.sh "${RPM_ROOT}"
|
||||
- ROOT_PWD="${PASSWD}" chroot "$RPM_ROOT" bash /set_in_chroot.sh
|
||||
+ ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
|
||||
rm "${RPM_ROOT}/set_in_chroot.sh"
|
||||
}
|
||||
|
||||
function create_img() {
|
||||
rm -f system.img update.img
|
||||
qemu-img create system.img ${IMG_SIZE}G
|
||||
- parted system.img -- mklabel msdos
|
||||
- parted system.img -- mkpart primary ext4 1MiB 20MiB
|
||||
- parted system.img -- mkpart primary ext4 20MiB 2120MiB
|
||||
- parted system.img -- mkpart primary ext4 2120MiB 4220MiB
|
||||
- parted system.img -- mkpart primary ext4 4220MiB 100%
|
||||
-
|
||||
- local device=$(losetup -f)
|
||||
- losetup "${device}" system.img
|
||||
-
|
||||
- mkdir -p "${TMP_MOUNT_PATH}"
|
||||
-
|
||||
- init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
|
||||
- local grub2_path="${TMP_MOUNT_PATH}/boot/grub2"
|
||||
- mkdir -p "${grub2_path}"
|
||||
- init_part system.img1 GRUB2 "${grub2_path}"
|
||||
-
|
||||
- tar -x -C "${TMP_MOUNT_PATH}" -f os.tar
|
||||
- sync
|
||||
-
|
||||
- dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
|
||||
- mount_proc_dev_sys "${TMP_MOUNT_PATH}"
|
||||
- chroot "${TMP_MOUNT_PATH}" grub2-install --modules="biosdisk part_msdos" "${device}"
|
||||
- sync
|
||||
- unmount_dir "${TMP_MOUNT_PATH}"
|
||||
-
|
||||
+ parted system.img -- mklabel msdos
|
||||
+ parted system.img -- mkpart primary fat16 1MiB 60MiB
|
||||
+ parted system.img -- mkpart primary ext4 60MiB 2160MiB
|
||||
+ parted system.img -- mkpart primary ext4 2160MiB 4260MiB
|
||||
+ parted system.img -- 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}"
|
||||
+ local BOOT_PATH=${TMP_MOUNT_PATH}/boot
|
||||
+ mkdir -p ${BOOT_PATH}
|
||||
+ chmod 755 ${BOOT_PATH}
|
||||
+ init_part system.img1 BOOT "${BOOT_PATH}"
|
||||
+
|
||||
+ mv -f ${RPM_ROOT}/boot/* ${BOOT_PATH} || true
|
||||
+ [ -d ${RPM_ROOT}/boot/ ] && rm -rf ${RPM_ROOT}/boot/
|
||||
+ sudo mv -t ${TMP_MOUNT_PATH} ${RPM_ROOT}/* || true
|
||||
+ cp bootloader.sh "${TMP_MOUNT_PATH}"
|
||||
+ mount_proc_dev_sys "${TMP_MOUNT_PATH}"
|
||||
+ DEVICE="${device}" chroot "${TMP_MOUNT_PATH}" bash bootloader.sh
|
||||
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/grub2
|
||||
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/efi/EFI/openEuler
|
||||
+ 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}"
|
||||
|
||||
@@ -251,8 +268,6 @@ function create_os_tar() {
|
||||
install_packages
|
||||
install_misc
|
||||
unmount_dir "${RPM_ROOT}"
|
||||
-
|
||||
- tar -C "${RPM_ROOT}" -cf ./os.tar .
|
||||
}
|
||||
|
||||
test_lock
|
||||
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
|
||||
index d10e4cf..90507c4 100644
|
||||
--- a/scripts/grub.cfg
|
||||
+++ b/scripts/grub.cfg
|
||||
@@ -92,12 +92,12 @@ menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
|
||||
insmod ext2
|
||||
set root='hd0,msdos2'
|
||||
if [ x$feature_platform_search_hint = xy ]; then
|
||||
- search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /boot/vmlinuz
|
||||
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /vmlinuz
|
||||
else
|
||||
- search --no-floppy --file --set=root /boot/vmlinuz
|
||||
+ search --no-floppy --file --set=root /vmlinuz
|
||||
fi
|
||||
- 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
|
||||
+ linux /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 /initramfs.img
|
||||
}
|
||||
|
||||
menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'KubeOS-B' {
|
||||
@@ -108,12 +108,12 @@ menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
|
||||
insmod ext2
|
||||
set root='hd0,msdos3'
|
||||
if [ x$feature_platform_search_hint = xy ]; then
|
||||
- search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /boot/vmlinuz
|
||||
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /vmlinuz
|
||||
else
|
||||
- search --no-floppy --file --set=root /boot/vmlinuz
|
||||
+ search --no-floppy --file --set=root /vmlinuz
|
||||
fi
|
||||
- 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
|
||||
+ linux /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 /initramfs.img
|
||||
}
|
||||
|
||||
### END /etc/grub.d/10_linux ###
|
||||
diff --git a/scripts/rpmlist b/scripts/rpmlist
|
||||
index 93c277c..7a9adfa 100644
|
||||
--- a/scripts/rpmlist
|
||||
+++ b/scripts/rpmlist
|
||||
@@ -1,6 +1,7 @@
|
||||
kernel
|
||||
passwd
|
||||
-grub2
|
||||
+grub2-efi
|
||||
+grub2-tools
|
||||
dhcp
|
||||
NetworkManager
|
||||
openssh-server
|
||||
diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh
|
||||
index 3b8313f..49e3894 100644
|
||||
--- a/scripts/set_in_chroot.sh
|
||||
+++ b/scripts/set_in_chroot.sh
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/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
|
||||
-ln -s /usr/lib/systemd/system/boot-grub2.mount /lib/systemd/system/local-fs.target.wants/boot-grub2.mount
|
||||
+ln -s /usr/lib/systemd/system/boot.mount /lib/systemd/system/local-fs.target.wants/boot.mount
|
||||
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}'`
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
From 1bf97e2943993932dbba997e68a66f66ed1205e0 Mon Sep 17 00:00:00 2001
|
||||
From: liyuanr <liyuanrong1@huawei.com>
|
||||
Date: Thu, 28 Apr 2022 15:37:29 +0800
|
||||
Subject: [PATCH] KubeOS:increase the space of the boot partition
|
||||
|
||||
Since openEuler 22.03-LTS, the space required by grub-related
|
||||
packages is increased. Therefore, the space of the boot partition
|
||||
is not enough. Therefore, the space of the boot partition needs to
|
||||
be increased
|
||||
|
||||
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
|
||||
---
|
||||
scripts/generate.sh | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/scripts/generate.sh b/scripts/generate.sh
|
||||
index e59dd8c..0bfe6c5 100644
|
||||
--- a/scripts/generate.sh
|
||||
+++ b/scripts/generate.sh
|
||||
@@ -221,10 +221,10 @@ function create_img() {
|
||||
rm -f system.img update.img
|
||||
qemu-img create system.img ${IMG_SIZE}G
|
||||
parted system.img -- mklabel msdos
|
||||
- parted system.img -- mkpart primary fat16 1MiB 60MiB
|
||||
- parted system.img -- mkpart primary ext4 60MiB 2160MiB
|
||||
- parted system.img -- mkpart primary ext4 2160MiB 4260MiB
|
||||
- parted system.img -- mkpart primary ext4 4260MiB 100%
|
||||
+ parted system.img -- mkpart primary fat16 1MiB 100MiB
|
||||
+ parted system.img -- mkpart primary ext4 100MiB 2200MiB
|
||||
+ parted system.img -- mkpart primary ext4 2200MiB 4300MiB
|
||||
+ parted system.img -- mkpart primary ext4 4300MiB 100%
|
||||
|
||||
local device=$(losetup -f)
|
||||
losetup "${device}" system.img
|
||||
--
|
||||
2.33.0.windows.2
|
||||
|
||||
52
KubeOS.spec
52
KubeOS.spec
@ -1,14 +1,12 @@
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
|
||||
|
||||
Name: KubeOS
|
||||
Version: 1.0.1
|
||||
Release: 8
|
||||
Version: 1.0.2
|
||||
Release: 2
|
||||
Summary: O&M platform used to update the whole OS as an entirety
|
||||
License: Mulan PSL v2
|
||||
Source0: https://gitee.com/openeuler/KubeOS/repository/archive/v%{version}.tar.gz
|
||||
Patch1: 0001-KubeOS-modify-checks-in-generate.sh-and-change-modul.patch
|
||||
Patch2: 0002-change-generate-argument-from-isopath-to-repopath.patch
|
||||
Patch3: 0003-KubeOS-add-arm-architecture-support-to-the-OS-image.patch
|
||||
Patch1: 0001-Write-a-tool-to-support-KubeOS-deployment-on-physica.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: make
|
||||
BuildRequires: golang >= 1.13
|
||||
@ -17,7 +15,7 @@ This is an O&M platform used to update the whole OS as an entirety,
|
||||
it should be running in kubernetes environment.
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name} -p1
|
||||
%autosetup -n %{name}-v%{version} -p1
|
||||
|
||||
%package scripts
|
||||
Summary: Scripts to build the os image and binaries of os-proxy and os-operator
|
||||
@ -44,13 +42,28 @@ install -p -m 0500 ./bin/operator %{buildroot}/opt/kubeOS/bin
|
||||
#install artifacts
|
||||
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0600 ./scripts/rpmlist %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0500 ./scripts/generate.sh %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0500 ./scripts/kbimg.sh %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0500 ./scripts/set_in_chroot.sh %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0600 ./scripts/grub.cfg %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0500 ./scripts/bootloader.sh %{buildroot}/opt/kubeOS/scripts
|
||||
install -p -m 0500 ./scripts/Dockerfile %{buildroot}/opt/kubeOS/scripts
|
||||
|
||||
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/common
|
||||
install -p -m 0500 ./scripts/common/globalVariables.sh %{buildroot}/opt/kubeOS/scripts/common
|
||||
install -p -m 0500 ./scripts/common/log.sh %{buildroot}/opt/kubeOS/scripts/common
|
||||
install -p -m 0500 ./scripts/common/utils.sh %{buildroot}/opt/kubeOS/scripts/common
|
||||
|
||||
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/create
|
||||
install -p -m 0500 ./scripts/create/imageCreate.sh %{buildroot}/opt/kubeOS/scripts/create
|
||||
install -p -m 0500 ./scripts/create/rootfsCreate.sh %{buildroot}/opt/kubeOS/scripts/create
|
||||
|
||||
install -d -m 0740 %{buildroot}/opt/kubeOS/scripts/00bootup
|
||||
install -p -m 0600 ./scripts/00bootup/Global.cfg %{buildroot}/opt/kubeOS/scripts/00bootup
|
||||
install -p -m 0500 ./scripts/00bootup/module-setup.sh %{buildroot}/opt/kubeOS/scripts/00bootup
|
||||
install -p -m 0500 ./scripts/00bootup/mount.sh %{buildroot}/opt/kubeOS/scripts/00bootup
|
||||
|
||||
install -d -m 0740 %{buildroot}/opt/kubeOS/files
|
||||
install -p -m 0600 ./files/boot.mount %{buildroot}/opt/kubeOS/files
|
||||
install -p -m 0600 ./files/boot-efi.mount %{buildroot}/opt/kubeOS/files
|
||||
install -p -m 0600 ./files/etc.mount %{buildroot}/opt/kubeOS/files
|
||||
install -p -m 0600 ./files/persist.mount %{buildroot}/opt/kubeOS/files
|
||||
install -p -m 0600 ./files/var.mount %{buildroot}/opt/kubeOS/files
|
||||
@ -60,7 +73,7 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
|
||||
%files
|
||||
%attr(0500,root,root) /opt/kubeOS/bin/os-agent
|
||||
%defattr(-,root,root,0500)
|
||||
%attr(0600,root,root) /opt/kubeOS/files/boot.mount
|
||||
%attr(0600,root,root) /opt/kubeOS/files/boot-efi.mount
|
||||
%attr(0600,root,root) /opt/kubeOS/files/etc.mount
|
||||
%attr(0600,root,root) /opt/kubeOS/files/persist.mount
|
||||
%attr(0600,root,root) /opt/kubeOS/files/var.mount
|
||||
@ -72,15 +85,34 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
|
||||
%attr(0500,root,root) /opt/kubeOS/bin/operator
|
||||
%defattr(-,root,root,0500)
|
||||
%attr(0600,root,root) /opt/kubeOS/scripts/rpmlist
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/generate.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/kbimg.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/set_in_chroot.sh
|
||||
%attr(0600,root,root) /opt/kubeOS/scripts/grub.cfg
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/bootloader.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/Dockerfile
|
||||
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/common/globalVariables.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/common/log.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/common/utils.sh
|
||||
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/create/imageCreate.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/create/rootfsCreate.sh
|
||||
|
||||
%attr(0600,root,root) /opt/kubeOS/scripts/00bootup/Global.cfg
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/00bootup/module-setup.sh
|
||||
%attr(0500,root,root) /opt/kubeOS/scripts/00bootup/mount.sh
|
||||
|
||||
|
||||
%clean
|
||||
rm -rfv %{buildroot}
|
||||
|
||||
%changelog
|
||||
* Fri Aug 05 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.2-2
|
||||
- Type:requirement
|
||||
- CVE:NA
|
||||
- SUG:restart
|
||||
- DESC:update to 1.0.2-2
|
||||
|
||||
* Tue Aug 02 2022 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-8
|
||||
- Type:requirement
|
||||
- CVE:NA
|
||||
|
||||
BIN
v1.0.1.tar.gz
BIN
v1.0.1.tar.gz
Binary file not shown.
BIN
v1.0.2.tar.gz
Normal file
BIN
v1.0.2.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user