Merge ~alextu/pc-enablement/+git/oem-scripts:recovery-from-iso-inject-stella-on-somverville-img into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
- Git
- lp:~alextu/pc-enablement/+git/oem-scripts
- recovery-from-iso-inject-stella-on-somverville-img
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | e42da8a4375e891c496dec28057f4c75a22607fc |
Proposed branch: | ~alextu/pc-enablement/+git/oem-scripts:recovery-from-iso-inject-stella-on-somverville-img |
Merge into: | ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master |
Diff against target: |
132 lines (+70/-3) 1 file modified
recovery-from-iso.sh (+70/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
jeremyszu (community) | Approve | ||
Andy Chi | Approve | ||
OEM Solutions Group: Engineers | Pending | ||
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jeremyszu (os369510) wrote : | # |
Hi Alex,
What's different between
dell-bto-
dell-bto-
dell-bto-
dell-bto-
dell-bto-
?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jeremyszu (os369510) wrote : | # |
I still need to try it in physical machine but I need the information from previous comment.
And one thing needs to be fixed at least.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andy Chi (andch) wrote : | # |
Cannot enter recovery partition.
error: file 'casper/vmlinuz' not found
error: you need to load kernel first
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
comment inline
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
just also verified on HP laptop (202103-28767) with the patch 22c3478
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andy Chi (andch) wrote : | # |
Test pass with 202104-28974. One question of dell-bto-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jeremyszu (os369510) wrote : | # |
> Hi Alex,
>
> What's different between
>
> dell-bto-
> dell-bto-
> dell-bto-
> dell-bto-
> dell-bto-
>
> ?
the answer is here
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alex Tu (alextu) wrote : | # |
> Test pass with 202104-28974. One question of dell-bto-
> init-X170-
> u and ubuntu both exist. When OS startup, I observe u as login user.
> `user_on_target` expects "ubuntu".
`u` is used for original usb dev flow and I'm trying to make `ubuntu` as default if no one is concerning on that change.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andy Chi (andch) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jeremyszu (os369510) wrote : | # |
Hi Alex,
I can not install "dell-bto-
The error shows in dell-recovery. "this recovery media only function on Dell..."
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jeremyszu (os369510) wrote : | # |
Verified by
1. installing dell-bto-
2. recovery-
3. recovery-
All passed.
Preview Diff
1 | diff --git a/recovery-from-iso.sh b/recovery-from-iso.sh | |||
2 | index a6f4439..3b42656 100755 | |||
3 | --- a/recovery-from-iso.sh | |||
4 | +++ b/recovery-from-iso.sh | |||
5 | @@ -4,6 +4,7 @@ set -ex | |||
6 | 4 | jenkins_job_for_iso="" | 4 | jenkins_job_for_iso="" |
7 | 5 | jenkins_job_build_no="lastSuccessfulBuild" | 5 | jenkins_job_build_no="lastSuccessfulBuild" |
8 | 6 | script_on_target_machine="inject_recovery_from_iso.sh" | 6 | script_on_target_machine="inject_recovery_from_iso.sh" |
9 | 7 | additional_grub_for_ubuntu_recovery="99_ubuntu_recovery" | ||
10 | 7 | user_on_target="ubuntu" | 8 | user_on_target="ubuntu" |
11 | 8 | SSH="ssh -o StrictHostKeyChecking=no" | 9 | SSH="ssh -o StrictHostKeyChecking=no" |
12 | 9 | SCP="scp -o StrictHostKeyChecking=no" | 10 | SCP="scp -o StrictHostKeyChecking=no" |
13 | @@ -91,6 +92,7 @@ ubiquity ubuntu-recovery/recovery_type string dev | |||
14 | 91 | git clone --depth 1 -b maas-focal lp:~lyoncore-team/lyoncore/+git/somerville-maas-override maas_deps | 92 | git clone --depth 1 -b maas-focal lp:~lyoncore-team/lyoncore/+git/somerville-maas-override maas_deps |
15 | 92 | cd maas_deps | 93 | cd maas_deps |
16 | 93 | git rev-parse --short HEAD | 94 | git rev-parse --short HEAD |
17 | 95 | rm -f maas-pkgs/oem-fix-misc-cnl-maas-helper* | ||
18 | 94 | cd .. | 96 | cd .. |
19 | 95 | cp -r maas_deps/maas-pkgs/*.deb . | 97 | cp -r maas_deps/maas-pkgs/*.deb . |
20 | 96 | find . | 98 | find . |
21 | @@ -116,6 +118,61 @@ apt-get install -fy | |||
22 | 116 | # get pkgs for ssh key and skip disk checking. | 118 | # get pkgs for ssh key and skip disk checking. |
23 | 117 | $GIT clone https://git.launchpad.net/~oem-solutions-engineers/pc-enablement/+git/oem-fix-misc-cnl-misc-for-automation --depth 1 misc_for_automation | 119 | $GIT clone https://git.launchpad.net/~oem-solutions-engineers/pc-enablement/+git/oem-fix-misc-cnl-misc-for-automation --depth 1 misc_for_automation |
24 | 118 | 120 | ||
25 | 121 | if [ "${ubr}" == "yes" ]; then | ||
26 | 122 | mkdir -p "$temp_folder"/preseed | ||
27 | 123 | cat <<EOF1 > "$temp_folder/preseed/$additional_grub_for_ubuntu_recovery" | ||
28 | 124 | #!/bin/bash -e | ||
29 | 125 | source /usr/lib/grub/grub-mkconfig_lib | ||
30 | 126 | cat <<EOF | ||
31 | 127 | menuentry "ubuntu-recovery restore" --hotkey f9 { | ||
32 | 128 | search --no-floppy --hint '(hd0,gpt2)' --set --fs-uuid UUID_OF_RECOVERY_PARTITION | ||
33 | 129 | if [ -s /boot/grub/common.cfg ]; then | ||
34 | 130 | source /boot/grub/common.cfg | ||
35 | 131 | else | ||
36 | 132 | set options="boot=casper automatic-ubiquity noprompt quiet splash" | ||
37 | 133 | fi | ||
38 | 134 | |||
39 | 135 | if [ "\\\${grub_platform}" != "efi" ]; then | ||
40 | 136 | if [ -f \\\${prefix}/nomodesetlist.txt ]; then | ||
41 | 137 | if hwmatch \\\${prefix}/nomodesetlist.txt 3; then | ||
42 | 138 | if [ \\\${match} != 0 ]; then | ||
43 | 139 | set options="nomodeset \\\$options" | ||
44 | 140 | fi | ||
45 | 141 | fi | ||
46 | 142 | fi | ||
47 | 143 | fi | ||
48 | 144 | |||
49 | 145 | #Support starting from a loopback mount (Only support ubuntu.iso for filename) | ||
50 | 146 | if [ -f /ubuntu.iso ]; then | ||
51 | 147 | loopback loop /ubuntu.iso | ||
52 | 148 | set root=(loop) | ||
53 | 149 | set options="\\\$options iso-scan/filename=/ubuntu.iso" | ||
54 | 150 | fi | ||
55 | 151 | if [ -n "\\\${lang}" ]; then | ||
56 | 152 | set options="\\\$options locale=\\\$lang" | ||
57 | 153 | fi | ||
58 | 154 | |||
59 | 155 | linux /casper/vmlinuz ubuntu-recovery/recovery_type=hdd \\\$options | ||
60 | 156 | initrd /casper/initrd | ||
61 | 157 | } | ||
62 | 158 | EOF | ||
63 | 159 | EOF1 | ||
64 | 160 | cat <<EOF > "$temp_folder/preseed/set_env_for_ubuntu_recovery" | ||
65 | 161 | #!/bin/bash -ex | ||
66 | 162 | # replace the grub entry which ubuntu_recovery expected | ||
67 | 163 | recover_p=\$(lsblk -l | grep efi | cut -d ' ' -f 1 | sed 's/.$/2'/) | ||
68 | 164 | UUID_OF_RECOVERY_PARTITION=\$(ls -l /dev/disk/by-uuid/ | grep \$recover_p | awk '{print \$9}') | ||
69 | 165 | echo partition = \$UUID_OF_RECOVERY_PARTITION | ||
70 | 166 | sed -i "s/UUID_OF_RECOVERY_PARTITION/\$UUID_OF_RECOVERY_PARTITION/" push_preseed/preseed/$additional_grub_for_ubuntu_recovery | ||
71 | 167 | sudo rm -f /etc/grub.d/99_dell_recovery || true | ||
72 | 168 | chmod 766 push_preseed/preseed/$additional_grub_for_ubuntu_recovery | ||
73 | 169 | sudo cp push_preseed/preseed/$additional_grub_for_ubuntu_recovery /etc/grub.d/ | ||
74 | 170 | |||
75 | 171 | # Force changing the recovery partition label to PQSERVICE for ubuntu-recovery | ||
76 | 172 | sudo fatlabel /dev/\$recover_p PQSERVICE | ||
77 | 173 | EOF | ||
78 | 174 | fi | ||
79 | 175 | |||
80 | 119 | return 0 | 176 | return 0 |
81 | 120 | } | 177 | } |
82 | 121 | push_preseed() { | 178 | push_preseed() { |
83 | @@ -152,12 +209,19 @@ inject_preseed() { | |||
84 | 152 | download_preseed && \ | 209 | download_preseed && \ |
85 | 153 | push_preseed | 210 | push_preseed |
86 | 154 | scp -o StrictHostKeyChecking=no "$user_on_target"@"$target_ip":/cdrom/SUCCSS_push_preseed "$temp_folder" || usage | 211 | scp -o StrictHostKeyChecking=no "$user_on_target"@"$target_ip":/cdrom/SUCCSS_push_preseed "$temp_folder" || usage |
87 | 212 | |||
88 | 213 | if [ "${ubr}" == "yes" ]; then | ||
89 | 214 | $SSH "$user_on_target"@"$target_ip" bash \$HOME/push_preseed/preseed/set_env_for_ubuntu_recovery || usage | ||
90 | 215 | fi | ||
91 | 155 | $SSH "$user_on_target"@"$target_ip" touch /tmp/SUCCSS_inject_preseed | 216 | $SSH "$user_on_target"@"$target_ip" touch /tmp/SUCCSS_inject_preseed |
92 | 156 | } | 217 | } |
93 | 157 | 218 | ||
94 | 158 | inject_recovery_iso() { | 219 | inject_recovery_iso() { |
95 | 159 | if [ -n "$local_iso" ]; then | 220 | if [ -n "$local_iso" ]; then |
96 | 160 | img_name="$(basename "$local_iso")" | 221 | img_name="$(basename "$local_iso")" |
97 | 222 | if [ -z "${img_name##*stella*}" ]; then | ||
98 | 223 | ubr="yes" | ||
99 | 224 | fi | ||
100 | 161 | if [ "${ubr}" == "yes" ]; then | 225 | if [ "${ubr}" == "yes" ]; then |
101 | 162 | rsync_opts="--exclude=efi --delete --temp-dir=/var/tmp/rsync" | 226 | rsync_opts="--exclude=efi --delete --temp-dir=/var/tmp/rsync" |
102 | 163 | else | 227 | else |
103 | @@ -172,7 +236,8 @@ cat <<EOF > "$temp_folder/$script_on_target_machine" | |||
104 | 172 | set -ex | 236 | set -ex |
105 | 173 | sudo umount /cdrom /mnt || true | 237 | sudo umount /cdrom /mnt || true |
106 | 174 | sudo mount -o loop $img_name /mnt && \ | 238 | sudo mount -o loop $img_name /mnt && \ |
108 | 175 | sudo mount /dev/\$(lsblk -l | grep efi | cut -d ' ' -f 1 | sed 's/.$/2'/) /cdrom && \ | 239 | recover_p=\$(lsblk -l | grep efi | cut -d ' ' -f 1 | sed 's/.$/2'/) && \ |
109 | 240 | sudo mount /dev/\$recover_p /cdrom && \ | ||
110 | 176 | df | grep "cdrom\|mnt" | awk '{print \$2" "\$6}' | sort | tail -n1 | grep -q cdrom && \ | 241 | df | grep "cdrom\|mnt" | awk '{print \$2" "\$6}' | sort | tail -n1 | grep -q cdrom && \ |
111 | 177 | sudo mkdir -p /var/tmp/rsync && \ | 242 | sudo mkdir -p /var/tmp/rsync && \ |
112 | 178 | sudo rsync -alv /mnt/ /cdrom/ $rsync_opts && \ | 243 | sudo rsync -alv /mnt/ /cdrom/ $rsync_opts && \ |
113 | @@ -188,7 +253,7 @@ EOF | |||
114 | 188 | img_name="$(wget -q "$img_jenkins_out_url/" -O - | grep -o 'href=.*iso"' | awk -F/ '{print $NF}' | tr -d \")" | 253 | img_name="$(wget -q "$img_jenkins_out_url/" -O - | grep -o 'href=.*iso"' | awk -F/ '{print $NF}' | tr -d \")" |
115 | 189 | pushd "$temp_folder" || usage | 254 | pushd "$temp_folder" || usage |
116 | 190 | wget "$img_jenkins_out_url/$img_name".md5sum | 255 | wget "$img_jenkins_out_url/$img_name".md5sum |
118 | 191 | md5sum -c "$img_name".md5sum || wget "$img_jenkins_out_url"/"$img_name" | 256 | md5sum -c "$img_name".md5sum || wget "$img_jenkins_out_url"/"$img_name" 2> /dev/null |
119 | 192 | md5sum -c "$img_name".md5sum || usage | 257 | md5sum -c "$img_name".md5sum || usage |
120 | 193 | local_iso="$PWD/$img_name" | 258 | local_iso="$PWD/$img_name" |
121 | 194 | popd | 259 | popd |
122 | @@ -212,7 +277,9 @@ poll_recovery_status() { | |||
123 | 212 | 277 | ||
124 | 213 | do_recovery() { | 278 | do_recovery() { |
125 | 214 | if [ "${ubr}" == "yes" ]; then | 279 | if [ "${ubr}" == "yes" ]; then |
127 | 215 | echo GRUB_DEFAULT=3 | $SSH "$user_on_target"@"$target_ip" -T "sudo tee -a /etc/default/grub.d/automatic-oem-config.cfg" | 280 | echo GRUB_DEFAULT='"ubuntu-recovery restore"' | $SSH "$user_on_target"@"$target_ip" -T "sudo tee -a /etc/default/grub.d/automatic-oem-config.cfg" |
128 | 281 | echo GRUB_TIMEOUT_STYLE=menu | $SSH "$user_on_target"@"$target_ip" -T "sudo tee -a /etc/default/grub.d/automatic-oem-config.cfg" | ||
129 | 282 | echo GRUB_TIMEOUT=5 | $SSH "$user_on_target"@"$target_ip" -T "sudo tee -a /etc/default/grub.d/automatic-oem-config.cfg" | ||
130 | 216 | $SSH "$user_on_target"@"$target_ip" sudo update-grub | 283 | $SSH "$user_on_target"@"$target_ip" sudo update-grub |
131 | 217 | $SSH "$user_on_target"@"$target_ip" sudo reboot & | 284 | $SSH "$user_on_target"@"$target_ip" sudo reboot & |
132 | 218 | else | 285 | else |
test steps: /job/dell- bto-focal- fossa-edge- alloem_ dev_jenkins_ remote_ trigger/ on VM
1. install iso from http://{jenkins}
2. recovery- from-iso. sh --local-iso {stella iso} --ubr -t {ip of target machine}
=> the target can done recovery with target iso.