Compare commits

..

No commits in common. "e37d57d569110e85500661d9c00d34be8661a269" and "e8581cb44846e71a0ffbaf7d373334243c4c953f" have entirely different histories.

4 changed files with 28 additions and 40 deletions

View File

@ -19,22 +19,6 @@ To install a Linux distribution execute:
sudo bash ./scripts/image/setup.sh sudo bash ./scripts/image/setup.sh
``` ```
### Cleanup
To cleanup the image setup execute:
```bash
fuser -k /dev/mapper/linux-image-manager-*;
umount -f /dev/mapper/linux-image-manager-*;
fuser -k /tmp/linux-image-manager-*;
umount -f /tmp/linux-image-manager-*;
```
Additional you can unmount the device with a command like
```bash
umount -f /dev/sd*;
```
## Chroot ## Chroot
To chroot into a Linux distribution on a storage execute: To chroot into a Linux distribution on a storage execute:

View File

@ -102,7 +102,7 @@ overwrite_device() {
info "Overwriting entire device..." && info "Overwriting entire device..." &&
dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwriting $device_path failed." dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwriting $device_path failed."
;; ;;
N|'') N)
info "Skipping Overwriting..." info "Skipping Overwriting..."
;; ;;
''|*[!0-9]*) ''|*[!0-9]*)

View File

@ -38,7 +38,7 @@ make_mount_folders(){
} }
make_working_folder(){ make_working_folder(){
working_folder_path="/tmp/linux-image-manager-$(date +%s)/" && working_folder_path="/tmp/raspberry-pi-tools-$(date +%s)/" &&
info "Create temporary working folder in $working_folder_path" && info "Create temporary working folder in $working_folder_path" &&
mkdir -v "$working_folder_path" || mkdir -v "$working_folder_path" ||
error error
@ -48,7 +48,7 @@ decrypt_root(){
if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ] if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ]
then then
root_partition_uuid=$(blkid "$root_partition_path" -s UUID -o value) && root_partition_uuid=$(blkid "$root_partition_path" -s UUID -o value) &&
root_mapper_name="linux-image-manager-$root_partition_uuid" && root_mapper_name="arch-root-$root_partition_uuid" &&
root_mapper_path="/dev/mapper/$root_mapper_name" && root_mapper_path="/dev/mapper/$root_mapper_name" &&
info "Decrypting of $root_partition_path is neccessary..." && info "Decrypting of $root_partition_path is neccessary..." &&
sudo cryptsetup -v luksOpen "$root_partition_path" "$root_mapper_name" || error sudo cryptsetup -v luksOpen "$root_partition_path" "$root_mapper_name" || error

View File

@ -401,13 +401,20 @@ if [ "$distribution" != "manjaro" ]
target_user_home_folder_path="$target_home_path$target_username/" && target_user_home_folder_path="$target_home_path$target_username/" &&
target_user_ssh_folder_path="$target_user_home_folder_path"".ssh/" && target_user_ssh_folder_path="$target_user_home_folder_path"".ssh/" &&
target_authorized_keys="$target_user_ssh_folder_path""authorized_keys" && target_authorized_keys="$target_user_ssh_folder_path""authorized_keys" &&
question "Enter the path to the SSH key to be added to the image (default: none):" && read -r origin_user_rsa_pub || error question "Should the ssh-key be copied to the image?(y/N)" && read -r copy_ssh_key || error
if [ -z "$origin_user_rsa_pub" ] if [ "$copy_ssh_key" == "y" ]
then then
info "Skipped SSH-key copying.." correct_ssh_key_path=false;
else 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" ] if [ -f "$origin_user_rsa_pub" ]
then 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..." 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." 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" && cat "$origin_user_rsa_pub" > "$target_authorized_keys" &&
@ -417,8 +424,7 @@ if [ "$distribution" != "manjaro" ]
chmod -v 700 "$target_user_ssh_folder_path" && chmod -v 700 "$target_user_ssh_folder_path" &&
chmod -v 600 "$target_authorized_keys" || error chmod -v 600 "$target_authorized_keys" || error
else else
error "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist." info "Skipped SSH-key copying.."
fi
fi fi
info "Start chroot procedures..." info "Start chroot procedures..."
@ -524,10 +530,8 @@ if [ "$distribution" != "manjaro" ]
mkinitcpio_search_binaries="BINARIES=()" && mkinitcpio_search_binaries="BINARIES=()" &&
mkinitcpio_replace_binaries=$(echo "BINARIES=(/usr/lib/libgcc_s.so.1)"| sed -e 's/[\/&]/\\&/g') && mkinitcpio_replace_binaries=$(echo "BINARIES=(/usr/lib/libgcc_s.so.1)"| sed -e 's/[\/&]/\\&/g') &&
mkinitcpio_encrypt_hooks="sleep netconf dropbear encryptssh" && mkinitcpio_encrypt_hooks="sleep netconf dropbear encryptssh" &&
mkinitcpio_hooks_prefix="base udev autodetect microcode modconf kms keyboard keymap consolefont block" mkinitcpio_search_hooks="HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck)" &&
mkinitcpio_hooks_suffix="filesystems fsck" mkinitcpio_replace_hooks="HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block $mkinitcpio_encrypt_hooks block 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_modules" "$mkinitcpio_replace_modules" "$mkinitcpio_path" &&
replace_in_file "$mkinitcpio_search_binaries" "$mkinitcpio_replace_binaries" "$mkinitcpio_path" && replace_in_file "$mkinitcpio_search_binaries" "$mkinitcpio_replace_binaries" "$mkinitcpio_path" &&
replace_in_file "$mkinitcpio_search_hooks" "$mkinitcpio_replace_hooks" "$mkinitcpio_path" && replace_in_file "$mkinitcpio_search_hooks" "$mkinitcpio_replace_hooks" "$mkinitcpio_path" &&
@ -582,7 +586,7 @@ if [ "$distribution" != "manjaro" ]
info "Running system specific procedures..." info "Running system specific procedures..."
if [ "$distribution" = "retropie" ] if [ "$distribution" = "retropie" ]
then then
if [ -n "$origin_user_rsa_pub" ] if [ "$copy_ssh_key" == "y" ]
then then
ssh_file="$boot_mount_path""ssh" && ssh_file="$boot_mount_path""ssh" &&
echo "" > "$ssh_file" echo "" > "$ssh_file"