2
2
# Copyright (C) 2019 Intel Corporation.
3
3
# SPDX-License-Identifier: BSD-3-Clause
4
4
#
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 .
6
6
# You should run this script with root privilege since it will modify various system parameters.
7
7
#
8
8
# 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 .
10
10
# sudo <script> -s 31080 -d
11
- # Upgrade SOS to 31080 with specified proxy server
11
+ # Upgrade Service VM to 31080 with specified proxy server
12
12
# 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
14
14
# 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.
16
16
# sudo <script> -u 31080 -k
17
17
18
18
function print_help()
19
19
{
20
20
echo " Usage:"
21
21
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 "
24
24
echo -e " \t-p to specify a proxy server (HTTPS)"
25
25
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"
28
29
echo -e " \t-e to specify EFI System Partition (ESP), default: /dev/sda1"
29
30
echo -e " \n\t<Note>:"
30
31
echo -e " \tThis script is using /dev/sda1 as default EFI System Partition (ESP)."
@@ -36,7 +37,7 @@ function print_help()
36
37
37
38
# get clear linux version previously
38
39
source /etc/os-release
39
- # switcher for download UOS function
40
+ # switcher for download User VM function
40
41
skip_download_uos=0
41
42
# switcher for disabling reboot device
42
43
disable_reboot=0
@@ -46,11 +47,11 @@ acrn_efi_path=/usr/lib/acrn/acrn.nuc6cayh.sdc.efi
46
47
47
48
function upgrade_sos()
48
49
{
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
51
52
[[ $VERSION_ID -gt $sos_ver ]] && echo " You're trying to install an older version of Clear Linux." && exit 1
52
53
53
- echo " Upgrading SOS ..."
54
+ echo " Upgrading Service VM ..."
54
55
55
56
# setup mirror and proxy url while specified with m and p options
56
57
[[ -n $mirror ]] && echo " Setting swupd mirror to: $mirror " && swupd mirror -s $mirror
@@ -63,9 +64,9 @@ function upgrade_sos()
63
64
echo " Disable auto update..."
64
65
swupd autoupdate --disable 2> /dev/null
65
66
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.
67
68
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 ..."
69
70
else
70
71
echo " Upgrading Clear Linux version from $VERSION_ID to $sos_ver ..."
71
72
swupd repair --picky -V $sos_ver 2> /dev/null
@@ -87,9 +88,21 @@ function upgrade_sos()
87
88
fi
88
89
cp -a $acrn_efi_path /mnt/EFI/acrn/acrn.efi
89
90
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
+
90
103
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
93
106
echo " Clean all ACRN efi boot event"
94
107
efibootmgr | grep ACRN | cut -d' *' -f1 | cut -d' t' -f2 | xargs -i efibootmgr -b {} -B > /dev/null
95
108
fi
@@ -103,21 +116,10 @@ function upgrade_sos()
103
116
echo " Add new ACRN efi boot event"
104
117
efibootmgr -c -l " \EFI\acrn\acrn.efi" -d $partition -p 1 -L " ACRN" > /dev/null
105
118
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
-
117
119
echo " Service OS setup done!"
118
120
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:"
121
123
echo " swupd update -V $sos_ver "
122
124
exit 1
123
125
fi
@@ -129,29 +131,29 @@ function upgrade_sos()
129
131
130
132
function upgrade_uos()
131
133
{
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
134
136
135
- echo " Upgrading UOS ..."
137
+ echo " Upgrading User VM ..."
136
138
137
- # UOS download link
139
+ # User VM download link
138
140
uos_image_link=" https://download.clearlinux.org/releases/$uos_ver /clear/clear-$uos_ver -kvm.img.xz"
139
141
140
142
# Set proxy if needed.
141
143
[[ -n $proxy ]] && echo " Setting proxy to: $proxy " && export https_proxy=$proxy
142
144
# Corrupt script if /mnt is already mounted.
143
145
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 ."
145
147
exit 1
146
148
fi
147
149
148
- # Do upgrade UOS process.
150
+ # Do upgrade User VM process.
149
151
if [[ $skip_download_uos != 1 ]]; then
150
152
cd ~
151
- echo " Downloading UOS image: $uos_image_link "
153
+ echo " Downloading User VM image: $uos_image_link "
152
154
curl $uos_image_link -o clear-$uos_ver -kvm.img.xz
153
155
if [[ $? -ne 0 ]]; then
154
- echo " Download UOS failed."
156
+ echo " Download User VM failed."
155
157
rm clear-$uos_ver -kvm.img.xz
156
158
exit 1
157
159
fi
@@ -161,19 +163,19 @@ function upgrade_uos()
161
163
uos_img=$( find ~ / -name clear-$uos_ver -kvm.img)
162
164
if [[ -f $uos_img ]] && [[ -f $uos_img .xz ]]; then echo " Moving $uos_img to $uos_img .old." ; mv $uos_img $uos_img .old; fi
163
165
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
165
167
fi
166
168
if [[ -f $uos_img_xz ]]; then
167
- echo " Unxz UOS file: $uos_img_xz "
169
+ echo " Unxz User VM file: $uos_img_xz "
168
170
unxz $uos_img_xz
169
171
uos_img=` echo $uos_img_xz | sed ' s/.xz$//g' `
170
172
fi
171
173
172
- echo " Get UOS image: $uos_img "
174
+ echo " Get User VM image: $uos_img "
173
175
uos_loop_device=` losetup -f -P --show $uos_img `
174
176
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; }
177
179
178
180
echo " Install kernel-iot-lts2018 to $uos_img "
179
181
swupd bundle-add --path=/mnt kernel-iot-lts2018 || { echo " Fail to install kernel-iot-lts2018" && exit 1; }
@@ -190,14 +192,14 @@ function upgrade_uos()
190
192
cp -r /usr/share/acrn/samples/nuc/launch_uos.sh ~ /launch_uos_$uos_ver .sh
191
193
sed -i " s/\(virtio-blk.*\)\/home\/clear\/uos\/uos.img/\1$( echo $uos_img | sed " s/\//\\\\ \//g" ) /" ~ /launch_uos_$uos_ver .sh
192
194
[[ -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 ..."
195
197
echo " sudo /root/launch_uos_$uos_ver .sh"
196
198
exit
197
199
}
198
200
199
201
# Set script options.
200
- while getopts " s:u:p:m:e:kdh " opt
202
+ while getopts " s:u:p:m:e:kdhi " opt
201
203
do
202
204
case " $opt " in
203
205
s) sos_ver=" $OPTARG "
216
218
;;
217
219
h) print_help
218
220
;;
221
+ i) acrn_efi_path=/usr/lib/acrn/acrn.kbl-nuc-i7.industry.efi
222
+ ;;
219
223
? ) print_help
220
224
;;
221
225
esac
225
229
[[ $EUID -ne 0 ]] && echo " You have to run script as root." && exit 1
226
230
[[ -z $1 ]] && print_help
227
231
[[ -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
229
233
[[ -n $uos_ver ]] && upgrade_uos || upgrade_sos
0 commit comments