Optimized variable order

This commit is contained in:
Kevin Veen-Birkenbach 2020-10-02 15:30:47 +02:00
parent 16d868b3d9
commit 1b6bf9ff9e

View File

@ -298,18 +298,18 @@ if mount | grep -q "$boot_partition_path"
fi fi
fi fi
info "Define target paths..." info "Define target paths..." &&
target_home_path="$root_mount_path""home/"; target_home_path="$root_mount_path""home/" &&
target_username=$(ls "$target_home_path"); target_username=$(ls "$target_home_path") &&
target_user_home_folder_path="$target_home_path$target_username/"; target_user_home_folder_path="$target_home_path$target_username/" &&
question "Should the ssh-key be copied to the image?(y/N)" && read -r copy_ssh_key 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" ] if [ "$copy_ssh_key" == "y" ]
then then
info "Copy ssh key to target..." info "Copy ssh key to target..." &&
target_user_ssh_folder_path="$target_user_home_folder_path"".ssh/" origin_user_rsa_pub="$origin_user_home"".ssh/id_rsa.pub" || error
target_authorized_keys="$target_user_ssh_folder_path""authorized_keys"
origin_user_rsa_pub="$origin_user_home"".ssh/id_rsa.pub";
if [ -f "$origin_user_rsa_pub" ] if [ -f "$origin_user_rsa_pub" ]
then then
mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created." mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created."
@ -318,8 +318,7 @@ if [ "$copy_ssh_key" == "y" ]
info "$target_authorized_keys contains the following: $target_authorized_keys_content" && info "$target_authorized_keys contains the following: $target_authorized_keys_content" &&
chown -vR 1000 "$target_user_ssh_folder_path" && chown -vR 1000 "$target_user_ssh_folder_path" &&
chmod -v 700 "$target_user_ssh_folder_path" && chmod -v 700 "$target_user_ssh_folder_path" &&
chmod -v 600 "$target_authorized_keys" || chmod -v 600 "$target_authorized_keys" || error
error
else else
warning "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist." warning "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist."
fi fi