Optimized sed

This commit is contained in:
Kevin Veen-Birkenbach 2020-06-12 10:57:58 +02:00
parent faf8239918
commit f51eaa12e6

View File

@ -423,7 +423,7 @@ if [ "$encrypt_system" == "y" ]
crypttab_rescue_path="$crypttab_path$rescue_suffix"
boot_txt_path="/boot/boot.txt"
boot_txt_rescue_path="/boot/boot.txt$rescue_suffix"
boot_txt_uncomment_line="part uuid ${devtype} ${devnum}:2 uuid"
boot_txt_delete_line=$(echo "part uuid \${devtype} \${devnum}:2 uuid" | sed -e 's/[]\/$*.^[]/\\&/g')
boot_txt_setenv_origin=$(echo "setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=\${uuid} rw rootwait smsc95xx.macaddr=\"\${usbethaddr}\"" | sed -e 's/[]\/$*.^[]/\\&/g')
boot_txt_setenv_replace=$(echo "setenv bootargs console=ttyS1,115200 console=tty0 ip=::::$target_hostname:eth0:dhcp cryptdevice=$encrypted_partition_path:root root=$root_mapper_path rw rootwait smsc95xx.macaddr=\"\${usbethaddr}\""| sed -e 's/[\/&]/\\&/g')
info "Setup encryption..." &&
@ -444,11 +444,14 @@ if [ "$encrypt_system" == "y" ]
echo "rsync --info=progress2 -axHAX / /mnt/"
echo "cp -v $fstab_path $fstab_rescue_path"
echo "echo '$root_mapper_path / ext4 defaults,noatime 0 1' >> $fstab_path"
echo "echo \"$fstab_path:\" && cat \"$fstab_path\""
echo "cp -v $crypttab_path $crypttab_rescue_path"
echo "echo 'root $encrypted_partition_path none luks' >> $crypttab_path"
echo "echo \"$crypttab_path:\" && cat \"$crypttab_path\""
echo "cp -v $boot_txt_path $boot_txt_rescue_path"
echo "sed -i 's/$boot_txt_uncomment_line/#$boot_txt_uncomment_line/g' $boot_txt_path" #@todo doesn't work yet
echo "sed -i 's/$boot_txt_delete_line//g' $boot_txt_path" #@todo doesn't work yet
echo "sed -i 's/$boot_txt_setenv_origin/$boot_txt_setenv_replace/g' $boot_txt_path" #@todo doesn't work yet
echo "echo \"$boot_txt_path:\" && cat \"$boot_txt_path\""
echo "cd /boot/ && ./mkscr"
echo "exit"
) | chroot "$root_mount_path" /bin/bash || error