Skip to content

Commit bbc228e

Browse files
lirui34wenlingz
authored andcommitted
doc: Add industry argument for auto setup script
Also fix efibootmgr not set correct issue. Signed-off-by: lirui34 <ruix.li@intel.com>
1 parent fd821d5 commit bbc228e

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

doc/getting-started/acrn_quick_setup.sh

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
# Copyright (C) 2019 Intel Corporation.
33
# SPDX-License-Identifier: BSD-3-Clause
44
#
5-
# This script provides a quick and automatic setup of the SOS or UOS.
5+
# This script provides a quick and automatic setup of the Service VM or User VM.
66
# You should run this script with root privilege since it will modify various system parameters.
77
#
88
# Usages:
9-
# Upgrade SOS to 31080 without reboot, it's highly recommended so that you can check configurations after upgrade SOS.
9+
# Upgrade Service VM to 31080 without reboot, it's highly recommended so that you can check configurations after upgrade Service VM.
1010
# sudo <script> -s 31080 -d
11-
# Upgrade SOS to 31080 with specified proxy server
11+
# Upgrade Service VM to 31080 with specified proxy server
1212
# sudo <script> -s 31080 -p <your proxy server>:<port>
13-
# Upgrade UOS to 31080 with specified proxy server
13+
# Upgrade User VM to 31080 with specified proxy server
1414
# sudo <script> -u 31080 -p <your proxy server>:<port>
15-
# Upgrade UOS to 31080 without downloading UOS image, you should put UOS image in /root directory previously.
15+
# Upgrade User VM to 31080 without downloading User VM image, you should put User VM image in /root directory previously.
1616
# sudo <script> -u 31080 -k
1717

1818
function print_help()
1919
{
2020
echo "Usage:"
2121
echo "Launch this script as: sudo $0 -s 31080"
22-
echo -e "\t-s to upgrade SOS"
23-
echo -e "\t-u to upgrade UOS"
22+
echo -e "\t-s to upgrade Service VM"
23+
echo -e "\t-u to upgrade User VM"
2424
echo -e "\t-p to specify a proxy server (HTTPS)"
2525
echo -e "\t-m to use swupd mirror url"
26-
echo -e "\t-k to skip downloading UOS; if enabled, you have to download UOS img firstly before upgrading, default is off"
27-
echo -e "\t-d to disable reboot device so that you can check the configurations after upgrading SOS"
26+
echo -e "\t-k to skip downloading User VM; if enabled, you have to download User VM img firstly before upgrading, default is off"
27+
echo -e "\t-d to disable reboot device so that you can check the configurations after upgrading Service VM"
28+
echo -e "\t-i to set up Service VM with industry scenario"
2829
echo -e "\t-e to specify EFI System Partition (ESP), default: /dev/sda1"
2930
echo -e "\n\t<Note>:"
3031
echo -e "\tThis script is using /dev/sda1 as default EFI System Partition (ESP)."
@@ -36,7 +37,7 @@ function print_help()
3637

3738
# get clear linux version previously
3839
source /etc/os-release
39-
# switcher for download UOS function
40+
# switcher for download User VM function
4041
skip_download_uos=0
4142
# switcher for disabling reboot device
4243
disable_reboot=0
@@ -46,11 +47,11 @@ acrn_efi_path=/usr/lib/acrn/acrn.nuc6cayh.sdc.efi
4647

4748
function upgrade_sos()
4849
{
49-
# Check SOS version
50-
[[ `echo $sos_ver | awk '{print length($0)}'` -ne 5 ]] && echo "Please input right SOS version to upgrade" && exit 1
50+
# Check Service VM version
51+
[[ `echo $sos_ver | awk '{print length($0)}'` -ne 5 ]] && echo "Please input right Service VM version to upgrade" && exit 1
5152
[[ $VERSION_ID -gt $sos_ver ]] && echo "You're trying to install an older version of Clear Linux." && exit 1
5253

53-
echo "Upgrading SOS..."
54+
echo "Upgrading Service VM..."
5455

5556
# setup mirror and proxy url while specified with m and p options
5657
[[ -n $mirror ]] && echo "Setting swupd mirror to: $mirror" && swupd mirror -s $mirror
@@ -63,9 +64,9 @@ function upgrade_sos()
6364
echo "Disable auto update..."
6465
swupd autoupdate --disable 2>/dev/null
6566

66-
# Compare with current clear linux and skip upgrade SOS if get the same version.
67+
# Compare with current clear linux and skip upgrade Service VM if get the same version.
6768
if [[ $VERSION_ID -eq $sos_ver ]]; then
68-
echo "Clear Linux version $sos_ver is already installed. Continuing to setup SOS..."
69+
echo "Clear Linux version $sos_ver is already installed. Continuing to setup Service VM..."
6970
else
7071
echo "Upgrading Clear Linux version from $VERSION_ID to $sos_ver ..."
7172
swupd repair --picky -V $sos_ver 2>/dev/null
@@ -87,9 +88,21 @@ function upgrade_sos()
8788
fi
8889
cp -a $acrn_efi_path /mnt/EFI/acrn/acrn.efi
8990
if [[ $? -ne 0 ]]; then echo "Fail to copy $acrn_efi_path" && exit 1; fi
91+
92+
new_kernel=`ls /mnt/EFI/org.clearlinux/*sos* -tl | grep kernel | head -n1 | awk -F'/' '{print $5}'`
93+
new_kernel=${new_kernel#kernel-}
94+
echo "Getting latest Service OS kernel version: $new_kernel"
95+
96+
echo "Add default (5 seconds) boot wait time."
97+
clr-boot-manager set-timeout 5 || { echo "Faild to add default boot wait time" && exit 1; }
98+
clr-boot-manager update
99+
100+
echo "Set $new_kernel as default boot kernel."
101+
clr-boot-manager set-kernel $new_kernel || { echo "Fail to set $new_kernel as default boot kernel." && exit 1; }
102+
90103
echo "Check ACRN efi boot event"
91-
check_acrn_bootefi=`efibootmgr | grep ACRN`
92-
if [[ "$check_acrn_bootefi" -ge "ACRN" ]]; then
104+
check_acrn_bootefi=`efibootmgr | grep ACRN | wc -l`
105+
if [[ "$check_acrn_bootefi" -ge 1 ]]; then
93106
echo "Clean all ACRN efi boot event"
94107
efibootmgr | grep ACRN | cut -d'*' -f1 | cut -d't' -f2 | xargs -i efibootmgr -b {} -B >/dev/null
95108
fi
@@ -103,21 +116,10 @@ function upgrade_sos()
103116
echo "Add new ACRN efi boot event"
104117
efibootmgr -c -l "\EFI\acrn\acrn.efi" -d $partition -p 1 -L "ACRN" >/dev/null
105118

106-
new_kernel=`ls /mnt/EFI/org.clearlinux/*sos* -tl | grep kernel | head -n1 | awk -F'/' '{print $5}'`
107-
new_kernel=${new_kernel#kernel-}
108-
echo "Getting latest Service OS kernel version: $new_kernel"
109-
110-
echo "Add default (5 seconds) boot wait time."
111-
clr-boot-manager set-timeout 5 || { echo "Faild to add default boot wait time" && exit 1; }
112-
clr-boot-manager update
113-
114-
echo "Set $new_kernel as default boot kernel."
115-
clr-boot-manager set-kernel $new_kernel || { echo "Fail to set $new_kernel as default boot kernel." && exit 1; }
116-
117119
echo "Service OS setup done!"
118120
else
119-
echo "Fail to upgrade SOS to $sos_ver."
120-
echo "Please try upgrade SOS with this command:"
121+
echo "Fail to upgrade Service VM to $sos_ver."
122+
echo "Please try upgrade Service VM with this command:"
121123
echo "swupd update -V $sos_ver"
122124
exit 1
123125
fi
@@ -129,29 +131,29 @@ function upgrade_sos()
129131

130132
function upgrade_uos()
131133
{
132-
# Check UOS version
133-
[[ `echo $uos_ver | awk '{print length($0)}'` -ne 5 ]] && echo "Please input right UOS version to upgrade" && exit 1
134+
# Check User VM version
135+
[[ `echo $uos_ver | awk '{print length($0)}'` -ne 5 ]] && echo "Please input right User VM version to upgrade" && exit 1
134136

135-
echo "Upgrading UOS..."
137+
echo "Upgrading User VM..."
136138

137-
# UOS download link
139+
# User VM download link
138140
uos_image_link="https://download.clearlinux.org/releases/$uos_ver/clear/clear-$uos_ver-kvm.img.xz"
139141

140142
# Set proxy if needed.
141143
[[ -n $proxy ]] && echo "Setting proxy to: $proxy" && export https_proxy=$proxy
142144
# Corrupt script if /mnt is already mounted.
143145
if [[ ! -z `findmnt /mnt -n` ]]; then
144-
echo "/mnt is already mounted, please unmount it if you want to continue upgrade UOS."
146+
echo "/mnt is already mounted, please unmount it if you want to continue upgrade User VM."
145147
exit 1
146148
fi
147149

148-
# Do upgrade UOS process.
150+
# Do upgrade User VM process.
149151
if [[ $skip_download_uos != 1 ]]; then
150152
cd ~
151-
echo "Downloading UOS image: $uos_image_link"
153+
echo "Downloading User VM image: $uos_image_link"
152154
curl $uos_image_link -o clear-$uos_ver-kvm.img.xz
153155
if [[ $? -ne 0 ]]; then
154-
echo "Download UOS failed."
156+
echo "Download User VM failed."
155157
rm clear-$uos_ver-kvm.img.xz
156158
exit 1
157159
fi
@@ -161,19 +163,19 @@ function upgrade_uos()
161163
uos_img=$(find ~/ -name clear-$uos_ver-kvm.img)
162164
if [[ -f $uos_img ]] && [[ -f $uos_img.xz ]]; then echo "Moving $uos_img to $uos_img.old."; mv $uos_img $uos_img.old; fi
163165
if [[ ! -f $uos_img_xz ]] && [[ ! -f $uos_img ]]; then
164-
echo "You should download UOS clear-$uos_ver-kvm.img.xz file firstly." && exit 1
166+
echo "You should download User VM clear-$uos_ver-kvm.img.xz file firstly." && exit 1
165167
fi
166168
if [[ -f $uos_img_xz ]]; then
167-
echo "Unxz UOS file: $uos_img_xz"
169+
echo "Unxz User VM file: $uos_img_xz"
168170
unxz $uos_img_xz
169171
uos_img=`echo $uos_img_xz | sed 's/.xz$//g'`
170172
fi
171173

172-
echo "Get UOS image: $uos_img"
174+
echo "Get User VM image: $uos_img"
173175
uos_loop_device=`losetup -f -P --show $uos_img`
174176

175-
mount ${uos_loop_device}p3 /mnt || { echo "Fail to mount UOS rootfs partition" && exit 1; }
176-
mount ${uos_loop_device}p1 /mnt/boot || { echo "Fail to mount UOS EFI partition" && exit 1; }
177+
mount ${uos_loop_device}p3 /mnt || { echo "Fail to mount User VM rootfs partition" && exit 1; }
178+
mount ${uos_loop_device}p1 /mnt/boot || { echo "Fail to mount User VM EFI partition" && exit 1; }
177179

178180
echo "Install kernel-iot-lts2018 to $uos_img"
179181
swupd bundle-add --path=/mnt kernel-iot-lts2018 || { echo "Fail to install kernel-iot-lts2018" && exit 1; }
@@ -190,14 +192,14 @@ function upgrade_uos()
190192
cp -r /usr/share/acrn/samples/nuc/launch_uos.sh ~/launch_uos_$uos_ver.sh
191193
sed -i "s/\(virtio-blk.*\)\/home\/clear\/uos\/uos.img/\1$(echo $uos_img | sed "s/\//\\\\\//g")/" ~/launch_uos_$uos_ver.sh
192194
[[ -z `grep $uos_img ~/launch_uos_$uos_ver.sh` ]] && echo "Fail to replace uos image in launch script: ~/launch_uos_$uos_ver.sh" && exit 1
193-
echo "Upgrade UOS done..."
194-
echo "Now you can run this command to start UOS..."
195+
echo "Upgrade User VM done..."
196+
echo "Now you can run this command to start User VM..."
195197
echo "sudo /root/launch_uos_$uos_ver.sh"
196198
exit
197199
}
198200

199201
# Set script options.
200-
while getopts "s:u:p:m:e:kdh" opt
202+
while getopts "s:u:p:m:e:kdhi" opt
201203
do
202204
case "$opt" in
203205
s) sos_ver="$OPTARG"
@@ -216,6 +218,8 @@ do
216218
;;
217219
h) print_help
218220
;;
221+
i) acrn_efi_path=/usr/lib/acrn/acrn.kbl-nuc-i7.industry.efi
222+
;;
219223
?) print_help
220224
;;
221225
esac
@@ -225,5 +229,5 @@ done
225229
[[ $EUID -ne 0 ]] && echo "You have to run script as root." && exit 1
226230
[[ -z $1 ]] && print_help
227231
[[ -z $efi_partition ]] && efi_partition=/dev/sda1 || echo "Setting EFI System partition to: $efi_partition..."
228-
[[ -n $sos_ver && -n $uos_ver ]] && echo "You should select upgrading SOS or UOS" && exit 1
232+
[[ -n $sos_ver && -n $uos_ver ]] && echo "You should select upgrading Service VM or User VM" && exit 1
229233
[[ -n $uos_ver ]] && upgrade_uos || upgrade_sos

0 commit comments

Comments
 (0)