From f51eaa12e61ac4f6917286c5f52d93d750f398cc Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Fri, 12 Jun 2020 10:57:58 +0200 Subject: [PATCH] Optimized sed --- scripts/image/setup.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/image/setup.sh b/scripts/image/setup.sh index acdc767..c95487d 100644 --- a/scripts/image/setup.sh +++ b/scripts/image/setup.sh @@ -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..." && @@ -443,12 +443,15 @@ if [ "$encrypt_system" == "y" ] echo "mount $root_mapper_path /mnt" 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 '$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