mirror of
https://github.com/kevinveenbirkenbach/linux-image-manager.git
synced 2024-11-21 14:41:04 +01:00
Compare commits
3 Commits
e8581cb448
...
e37d57d569
Author | SHA1 | Date | |
---|---|---|---|
e37d57d569 | |||
c05e804fb5 | |||
e40974f56d |
16
README.md
16
README.md
@ -19,6 +19,22 @@ To install a Linux distribution execute:
|
||||
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
|
||||
|
||||
To chroot into a Linux distribution on a storage execute:
|
||||
|
@ -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]*)
|
||||
|
@ -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
|
||||
|
@ -401,20 +401,13 @@ 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
|
||||
info "Skipped SSH-key copying.."
|
||||
else
|
||||
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" &&
|
||||
@ -424,7 +417,8 @@ if [ "$distribution" != "manjaro" ]
|
||||
chmod -v 700 "$target_user_ssh_folder_path" &&
|
||||
chmod -v 600 "$target_authorized_keys" || error
|
||||
else
|
||||
info "Skipped SSH-key copying.."
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user