In between commit chroot development

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-30 11:55:33 +02:00
parent 40b9034b50
commit 5306287463

View File

@ -43,7 +43,10 @@ destructor(){
error(){ error(){
message "${red_color}" "ERROR" "$1 -> Leaving program." message "${red_color}" "ERROR" "$1 -> Leaving program."
if [ "$2" != "no_destructor" ]
then
destructor destructor
fi
exit 1; exit 1;
} }
@ -191,8 +194,8 @@ if [[ -v image_checksum ]]
fi fi
info "Preparing mount paths..." info "Preparing mount paths..."
boot_mount_path="$working_folder""boot" boot_mount_path="$working_folder""boot/"
root_mount_path="$working_folder""root" root_mount_path="$working_folder""root/"
mkdir -v "$boot_mount_path" mkdir -v "$boot_mount_path"
mkdir -v "$root_mount_path" mkdir -v "$root_mount_path"
@ -309,6 +312,13 @@ if [ -f "$origin_user_rsa_pub" ]
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
info "Start chroot procedures..."
info "Mount chroot environments..."
mount --bind /dev "$root_mount_path""dev/" || error "Mounting /dev failed." "no_destructor"
mount --bind /sys "$root_mount_path""sys/" || error "Mounting /sys failed." "no_destructor"
mount --bind /proc "$root_mount_path""proc/" || error "Mounting /proc failed." "no_destructor"
mount --bind /dev/pts "$root_mount_path""dev/pts" || error "Mounting /dev/pts failed." "no_destructor"
info "Change password of user \"$target_username\"..." info "Change password of user \"$target_username\"..."
(chroot "$root_mount_path" /bin/passwd "$target_username") || error "Password change for \"$target_username\" wasn't possible." (chroot "$root_mount_path" /bin/passwd "$target_username") || error "Password change for \"$target_username\" wasn't possible."