diff --git a/scripts/base.sh b/scripts/base.sh index c4dfba0..eed883a 100644 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -102,7 +102,7 @@ overwrite_device() { info "Overwriting entire device..." && dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwriting $device_path failed." ;; - N) + N|'') info "Skipping Overwriting..." ;; ''|*[!0-9]*) diff --git a/scripts/image/base.sh b/scripts/image/base.sh index 260fc78..734cd6b 100644 --- a/scripts/image/base.sh +++ b/scripts/image/base.sh @@ -38,7 +38,7 @@ make_mount_folders(){ } make_working_folder(){ - working_folder_path="/tmp/raspberry-pi-tools-$(date +%s)/" && + working_folder_path="/tmp/linux-image-manager-$(date +%s)/" && info "Create temporary working folder in $working_folder_path" && mkdir -v "$working_folder_path" || error @@ -48,7 +48,7 @@ decrypt_root(){ if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ] then root_partition_uuid=$(blkid "$root_partition_path" -s UUID -o value) && - root_mapper_name="arch-root-$root_partition_uuid" && + root_mapper_name="linux-image-manager-$root_partition_uuid" && root_mapper_path="/dev/mapper/$root_mapper_name" && info "Decrypting of $root_partition_path is neccessary..." && sudo cryptsetup -v luksOpen "$root_partition_path" "$root_mapper_name" || error diff --git a/scripts/image/setup.sh b/scripts/image/setup.sh index 7adeb37..08bb66a 100644 --- a/scripts/image/setup.sh +++ b/scripts/image/setup.sh @@ -401,30 +401,24 @@ if [ "$distribution" != "manjaro" ] target_user_home_folder_path="$target_home_path$target_username/" && target_user_ssh_folder_path="$target_user_home_folder_path"".ssh/" && target_authorized_keys="$target_user_ssh_folder_path""authorized_keys" && - question "Should the ssh-key be copied to the image?(y/N)" && read -r copy_ssh_key || error - if [ "$copy_ssh_key" == "y" ] + question "Enter the path to the SSH key to be added to the image (default: none):" && read -r origin_user_rsa_pub || error + if [ -z "$origin_user_rsa_pub" ] then - correct_ssh_key_path=false; - while [ "$correct_ssh_key_path" != true ] - do - question "Whats the absolut path to the ssh key:" && read -r origin_user_rsa_pub || error - if [ -f "$origin_user_rsa_pub" ] - then - correct_ssh_key_path=true; - else - warning "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist." - fi - done - info "Copy ssh key to target..." - mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created." - cat "$origin_user_rsa_pub" > "$target_authorized_keys" && - target_authorized_keys_content=$(cat "$target_authorized_keys") && - info "$target_authorized_keys contains the following: $target_authorized_keys_content" && - chown -vR 1000 "$target_user_ssh_folder_path" && - chmod -v 700 "$target_user_ssh_folder_path" && - chmod -v 600 "$target_authorized_keys" || error - else info "Skipped SSH-key copying.." + else + if [ -f "$origin_user_rsa_pub" ] + then + info "Copy ssh key to target..." + mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created." + cat "$origin_user_rsa_pub" > "$target_authorized_keys" && + target_authorized_keys_content=$(cat "$target_authorized_keys") && + info "$target_authorized_keys contains the following: $target_authorized_keys_content" && + chown -vR 1000 "$target_user_ssh_folder_path" && + chmod -v 700 "$target_user_ssh_folder_path" && + chmod -v 600 "$target_authorized_keys" || error + else + error "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist." + fi fi info "Start chroot procedures..." @@ -530,8 +524,10 @@ if [ "$distribution" != "manjaro" ] mkinitcpio_search_binaries="BINARIES=()" && mkinitcpio_replace_binaries=$(echo "BINARIES=(/usr/lib/libgcc_s.so.1)"| sed -e 's/[\/&]/\\&/g') && mkinitcpio_encrypt_hooks="sleep netconf dropbear encryptssh" && - mkinitcpio_search_hooks="HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck)" && - mkinitcpio_replace_hooks="HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block $mkinitcpio_encrypt_hooks block filesystems fsck)" && + mkinitcpio_hooks_prefix="base udev autodetect microcode modconf kms keyboard keymap consolefont block" + mkinitcpio_hooks_suffix="filesystems fsck" + mkinitcpio_search_hooks="HOOKS=($mkinitcpio_hooks_prefix $mkinitcpio_hooks_suffix)" && + mkinitcpio_replace_hooks="HOOKS=($mkinitcpio_hooks_prefix $mkinitcpio_encrypt_hooks $mkinitcpio_hooks_suffix)" && replace_in_file "$mkinitcpio_search_modules" "$mkinitcpio_replace_modules" "$mkinitcpio_path" && replace_in_file "$mkinitcpio_search_binaries" "$mkinitcpio_replace_binaries" "$mkinitcpio_path" && replace_in_file "$mkinitcpio_search_hooks" "$mkinitcpio_replace_hooks" "$mkinitcpio_path" && @@ -586,7 +582,7 @@ if [ "$distribution" != "manjaro" ] info "Running system specific procedures..." if [ "$distribution" = "retropie" ] then - if [ "$copy_ssh_key" == "y" ] + if [ -n "$origin_user_rsa_pub" ] then ssh_file="$boot_mount_path""ssh" && echo "" > "$ssh_file"